@mint-ui/map 0.4.0-beta → 0.4.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/components/mint-map/MintMap.d.ts +1 -0
- package/dist/components/mint-map/core/MintMapCanvasRenderer.d.ts +4 -0
- package/dist/components/mint-map/core/MintMapCanvasRenderer.js +13 -0
- package/dist/components/mint-map/core/MintMapController.d.ts +4 -1
- package/dist/components/mint-map/core/MintMapController.js +33 -1
- package/dist/components/mint-map/core/MintMapCore.d.ts +1 -1
- package/dist/components/mint-map/core/MintMapCore.js +6 -4
- package/dist/components/mint-map/core/index.d.ts +1 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.d.ts +19 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.js +15 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.d.ts +4 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.js +271 -0
- package/dist/components/mint-map/core/wrapper/index.d.ts +2 -0
- package/dist/components/mint-map/google/GoogleMintMapController.js +1 -6
- package/dist/components/mint-map/kakao/KakaoMintMapController.js +1 -5
- package/dist/components/mint-map/naver/NaverMintMapController.js +3 -8
- package/dist/index.es.js +313 -26
- package/dist/index.js +6 -0
- package/dist/index.umd.js +314 -24
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -45,13 +45,15 @@
|
|
|
45
45
|
visible = _b === void 0 ? true : _b,
|
|
46
46
|
zoomLevel = _a.zoomLevel,
|
|
47
47
|
center = _a.center,
|
|
48
|
+
_c = _a.centerMoveWithPanning,
|
|
49
|
+
centerMoveWithPanning = _c === void 0 ? false : _c,
|
|
48
50
|
children = _a.children;
|
|
49
51
|
var controller = useMintMapController();
|
|
50
52
|
var elementRef = React.useRef(null);
|
|
51
53
|
|
|
52
|
-
var
|
|
53
|
-
mapInitialized =
|
|
54
|
-
setMapInitialized =
|
|
54
|
+
var _d = React.useState(false),
|
|
55
|
+
mapInitialized = _d[0],
|
|
56
|
+
setMapInitialized = _d[1];
|
|
55
57
|
|
|
56
58
|
React.useEffect(function () {
|
|
57
59
|
(function () {
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
var prevCenter = controller.getCenter();
|
|
97
99
|
|
|
98
100
|
if (!Position.equals(prevCenter, center)) {
|
|
99
|
-
controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
101
|
+
centerMoveWithPanning ? controller === null || controller === void 0 ? void 0 : controller.panningTo(center) : controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
}, [center]);
|
|
@@ -346,12 +348,43 @@
|
|
|
346
348
|
return this.type;
|
|
347
349
|
};
|
|
348
350
|
|
|
351
|
+
MintMapController.prototype.positionToOffset = function (position) {
|
|
352
|
+
var div = this.mapDivElement;
|
|
353
|
+
var w = div === null || div === void 0 ? void 0 : div.offsetWidth;
|
|
354
|
+
var h = div === null || div === void 0 ? void 0 : div.offsetHeight;
|
|
355
|
+
var bounds = this.getCurrBounds();
|
|
356
|
+
var maxLng = bounds.ne.lng;
|
|
357
|
+
var minLng = bounds.sw.lng;
|
|
358
|
+
var lng = Math.abs(maxLng - minLng);
|
|
359
|
+
var x = w * (position.lng - minLng) / lng;
|
|
360
|
+
var maxLat = bounds.ne.lat;
|
|
361
|
+
var minLat = bounds.sw.lat;
|
|
362
|
+
var lat = Math.abs(maxLat - minLat);
|
|
363
|
+
var y = h * (maxLat - position.lat) / lat;
|
|
364
|
+
return new Offset(x, y);
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
MintMapController.prototype.offsetToPosition = function (offset) {
|
|
368
|
+
var div = this.mapDivElement;
|
|
369
|
+
var w = div === null || div === void 0 ? void 0 : div.offsetWidth;
|
|
370
|
+
var h = div === null || div === void 0 ? void 0 : div.offsetHeight;
|
|
371
|
+
var bounds = this.getCurrBounds();
|
|
372
|
+
var maxLng = bounds.ne.lng;
|
|
373
|
+
var minLng = bounds.sw.lng;
|
|
374
|
+
var lng = Math.abs(maxLng - minLng);
|
|
375
|
+
var lngVal = offset.x * lng / w + minLng;
|
|
376
|
+
var maxLat = bounds.ne.lat;
|
|
377
|
+
var minLat = bounds.sw.lat;
|
|
378
|
+
var lat = Math.abs(maxLat - minLat);
|
|
379
|
+
var latVal = (offset.y * lat / h - maxLat) * -1;
|
|
380
|
+
return new Position(latVal, lngVal);
|
|
381
|
+
};
|
|
382
|
+
|
|
349
383
|
MintMapController.prototype.loadScript = function (url, id) {
|
|
350
384
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
351
385
|
return tslib.__generator(this, function (_a) {
|
|
352
386
|
return [2, new Promise(function (resolve) {
|
|
353
387
|
if (id && document.getElementById(id)) {
|
|
354
|
-
console.log("already loaded script => ".concat(id));
|
|
355
388
|
resolve();
|
|
356
389
|
return;
|
|
357
390
|
}
|
|
@@ -651,7 +684,6 @@
|
|
|
651
684
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
652
685
|
_this.dragStartPoint = [0, 0];
|
|
653
686
|
_this.dragged = false;
|
|
654
|
-
console.log("".concat(_this.type, " controller loadded"));
|
|
655
687
|
return _this;
|
|
656
688
|
}
|
|
657
689
|
|
|
@@ -937,7 +969,7 @@
|
|
|
937
969
|
var _this = this;
|
|
938
970
|
|
|
939
971
|
return tslib.__generator(this, function (_a) {
|
|
940
|
-
return [2, new Promise(function (resolve) {
|
|
972
|
+
return [2, new Promise(function (resolve, error) {
|
|
941
973
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
942
974
|
var callbackName, loaded, params, ok;
|
|
943
975
|
return tslib.__generator(this, function (_a) {
|
|
@@ -947,7 +979,6 @@
|
|
|
947
979
|
loaded = false;
|
|
948
980
|
|
|
949
981
|
window[callbackName] = function () {
|
|
950
|
-
console.log('naver api loaded');
|
|
951
982
|
loaded = true;
|
|
952
983
|
delete window[callbackName];
|
|
953
984
|
};
|
|
@@ -970,12 +1001,11 @@
|
|
|
970
1001
|
ok = _a.sent();
|
|
971
1002
|
|
|
972
1003
|
if (!ok) {
|
|
973
|
-
|
|
1004
|
+
error('naver script api load failed!!');
|
|
974
1005
|
}
|
|
975
1006
|
|
|
976
1007
|
this.mapApiLoaded = true;
|
|
977
1008
|
resolve(true);
|
|
978
|
-
console.log("".concat(this.type, " map script loaded"));
|
|
979
1009
|
return [2];
|
|
980
1010
|
}
|
|
981
1011
|
});
|
|
@@ -990,6 +1020,7 @@
|
|
|
990
1020
|
var _this = this;
|
|
991
1021
|
|
|
992
1022
|
return tslib.__generator(this, function (_a) {
|
|
1023
|
+
this.mapDivElement = divElement;
|
|
993
1024
|
return [2, new Promise(function (resolve) {
|
|
994
1025
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
995
1026
|
var options, maxZoom, minZoom, map;
|
|
@@ -1082,7 +1113,6 @@
|
|
|
1082
1113
|
});
|
|
1083
1114
|
this.mapInitialized = true;
|
|
1084
1115
|
this.initMarkerPool();
|
|
1085
|
-
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
1086
1116
|
resolve(map);
|
|
1087
1117
|
map.trigger('idle');
|
|
1088
1118
|
return [2];
|
|
@@ -1113,8 +1143,6 @@
|
|
|
1113
1143
|
} catch (e) {
|
|
1114
1144
|
console.log('naver map destroy error', e);
|
|
1115
1145
|
}
|
|
1116
|
-
|
|
1117
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
1118
1146
|
};
|
|
1119
1147
|
|
|
1120
1148
|
NaverMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -1180,11 +1208,8 @@
|
|
|
1180
1208
|
} catch (e) {
|
|
1181
1209
|
console.log('google map destroy error', e);
|
|
1182
1210
|
}
|
|
1183
|
-
|
|
1184
|
-
console.log("".concat(_this.type, " map destroyed"));
|
|
1185
1211
|
};
|
|
1186
1212
|
|
|
1187
|
-
console.log("".concat(_this.type, " controller loadded"));
|
|
1188
1213
|
return _this;
|
|
1189
1214
|
}
|
|
1190
1215
|
|
|
@@ -1480,7 +1505,6 @@
|
|
|
1480
1505
|
loaded = false;
|
|
1481
1506
|
|
|
1482
1507
|
window[callbackName] = function () {
|
|
1483
|
-
console.log('google api loaded');
|
|
1484
1508
|
loaded = true;
|
|
1485
1509
|
delete window[callbackName];
|
|
1486
1510
|
};
|
|
@@ -1509,7 +1533,6 @@
|
|
|
1509
1533
|
|
|
1510
1534
|
this.mapApiLoaded = true;
|
|
1511
1535
|
resolve(true);
|
|
1512
|
-
console.log("".concat(this.type, " map script api loaded"));
|
|
1513
1536
|
return [2];
|
|
1514
1537
|
}
|
|
1515
1538
|
});
|
|
@@ -1524,6 +1547,7 @@
|
|
|
1524
1547
|
var _this = this;
|
|
1525
1548
|
|
|
1526
1549
|
return tslib.__generator(this, function (_a) {
|
|
1550
|
+
this.mapDivElement = divElement;
|
|
1527
1551
|
return [2, new Promise(function (resolve) {
|
|
1528
1552
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
1529
1553
|
var map;
|
|
@@ -1584,7 +1608,6 @@
|
|
|
1584
1608
|
_this.mapProps.onMouseMove(pos);
|
|
1585
1609
|
});
|
|
1586
1610
|
this.mapInitialized = true;
|
|
1587
|
-
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
1588
1611
|
resolve(map);
|
|
1589
1612
|
return [2];
|
|
1590
1613
|
}
|
|
@@ -1659,7 +1682,6 @@
|
|
|
1659
1682
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
1660
1683
|
_this.dragStartPoint = [0, 0];
|
|
1661
1684
|
_this.dragged = false;
|
|
1662
|
-
console.log("".concat(_this.type, " controller loadded"));
|
|
1663
1685
|
return _this;
|
|
1664
1686
|
}
|
|
1665
1687
|
|
|
@@ -1977,7 +1999,6 @@
|
|
|
1977
1999
|
|
|
1978
2000
|
this.mapApiLoaded = true;
|
|
1979
2001
|
resolve(true);
|
|
1980
|
-
console.log("".concat(this.type, " map script loaded"));
|
|
1981
2002
|
return [2];
|
|
1982
2003
|
}
|
|
1983
2004
|
});
|
|
@@ -1992,6 +2013,7 @@
|
|
|
1992
2013
|
var _this = this;
|
|
1993
2014
|
|
|
1994
2015
|
return tslib.__generator(this, function (_a) {
|
|
2016
|
+
this.mapDivElement = divElement;
|
|
1995
2017
|
return [2, new Promise(function (resolve) {
|
|
1996
2018
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
1997
2019
|
var options, maxZoom, minZoom, map;
|
|
@@ -2069,7 +2091,6 @@
|
|
|
2069
2091
|
});
|
|
2070
2092
|
this.mapInitialized = true;
|
|
2071
2093
|
this.initMarkerPool();
|
|
2072
|
-
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
2073
2094
|
resolve(map);
|
|
2074
2095
|
return [2];
|
|
2075
2096
|
}
|
|
@@ -2100,8 +2121,6 @@
|
|
|
2100
2121
|
} catch (e) {
|
|
2101
2122
|
console.log('kakao map destroy error', e);
|
|
2102
2123
|
}
|
|
2103
|
-
|
|
2104
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
2105
2124
|
};
|
|
2106
2125
|
|
|
2107
2126
|
KakaoMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -2426,6 +2445,14 @@
|
|
|
2426
2445
|
}, "".concat(text, " ").concat(pointString)));
|
|
2427
2446
|
}
|
|
2428
2447
|
|
|
2448
|
+
var MintMapCanvasRenderer = function () {
|
|
2449
|
+
function MintMapCanvasRenderer(context) {
|
|
2450
|
+
this.context = context;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
return MintMapCanvasRenderer;
|
|
2454
|
+
}();
|
|
2455
|
+
|
|
2429
2456
|
var AnimationPlayer = function () {
|
|
2430
2457
|
function AnimationPlayer(drawFunction, fps) {
|
|
2431
2458
|
this.prevtime = 0;
|
|
@@ -3201,18 +3228,281 @@
|
|
|
3201
3228
|
return React__default["default"].createElement(React__default["default"].Fragment, null, options && children);
|
|
3202
3229
|
}
|
|
3203
3230
|
|
|
3231
|
+
var console$1 = {
|
|
3232
|
+
log: function () {
|
|
3233
|
+
}
|
|
3234
|
+
};
|
|
3235
|
+
function MapCanvasWrapper(_a) {
|
|
3236
|
+
var children = _a.children;
|
|
3237
|
+
tslib.__rest(_a, ["children"]);
|
|
3238
|
+
var controller = useMintMapController();
|
|
3239
|
+
|
|
3240
|
+
var _b = React.useState(false),
|
|
3241
|
+
renderFlag = _b[0],
|
|
3242
|
+
setRenderFlag = _b[1];
|
|
3243
|
+
|
|
3244
|
+
var invokeRender = React.useCallback(function () {
|
|
3245
|
+
setRenderFlag(!renderFlag);
|
|
3246
|
+
}, []);
|
|
3247
|
+
var renderer = React.useRef();
|
|
3248
|
+
var containerRef = React.useRef(null);
|
|
3249
|
+
var canvasRef = React.useRef(null);
|
|
3250
|
+
var contextRef = React.useRef();
|
|
3251
|
+
var clearRect = React.useCallback(function () {
|
|
3252
|
+
if (contextRef.current && canvasRef.current) {
|
|
3253
|
+
contextRef.current.clearRect(canvasRef.current.width * -1, canvasRef.current.height * -1, canvasRef.current.width * 3, canvasRef.current.height * 3);
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
return true;
|
|
3257
|
+
}, []);
|
|
3258
|
+
var scaleCanvas = React.useCallback(function (containerRef, canvasElement, canvasContext) {
|
|
3259
|
+
var devicePixelRatio = window.devicePixelRatio;
|
|
3260
|
+
var width = containerRef.offsetWidth;
|
|
3261
|
+
var height = containerRef.offsetHeight;
|
|
3262
|
+
canvasElement.width = width * devicePixelRatio;
|
|
3263
|
+
canvasElement.height = height * devicePixelRatio;
|
|
3264
|
+
canvasElement.style.width = "".concat(width, "px");
|
|
3265
|
+
canvasElement.style.height = "".concat(height, "px");
|
|
3266
|
+
canvasContext.scale(devicePixelRatio, devicePixelRatio);
|
|
3267
|
+
}, []);
|
|
3268
|
+
var parseClickParamToPosition = React.useCallback(function (mapType, e) {
|
|
3269
|
+
var latlng = e.latlng || e.latLng;
|
|
3270
|
+
|
|
3271
|
+
if (!latlng) {
|
|
3272
|
+
throw new Error("Map Type ".concat(mapType, " canvas marker click not supported (latlng not found)"));
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
var clickPosition = new Position(0, 0);
|
|
3276
|
+
|
|
3277
|
+
if (mapType === 'naver') {
|
|
3278
|
+
clickPosition.lat = latlng._lat;
|
|
3279
|
+
clickPosition.lng = latlng._lng;
|
|
3280
|
+
} else if (mapType === 'google') {
|
|
3281
|
+
clickPosition.lat = latlng.lat();
|
|
3282
|
+
clickPosition.lng = latlng.lng();
|
|
3283
|
+
} else if (mapType === 'kakao') {
|
|
3284
|
+
clickPosition.lat = latlng.Ma;
|
|
3285
|
+
clickPosition.lng = latlng.La;
|
|
3286
|
+
} else {
|
|
3287
|
+
throw new Error("Map Type ".concat(mapType, " canvas marker click not supported"));
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
return clickPosition;
|
|
3291
|
+
}, []);
|
|
3292
|
+
|
|
3293
|
+
var includes = function (point, targetPoint, width, height) {
|
|
3294
|
+
if (point.x >= targetPoint.x && point.x <= targetPoint.x + width && point.y >= targetPoint.y && point.y <= targetPoint.y + height) {
|
|
3295
|
+
return true;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
return false;
|
|
3299
|
+
};
|
|
3300
|
+
|
|
3301
|
+
var processMouseEvent = React.useCallback(function (clickedOffset, eventName) {
|
|
3302
|
+
var items = renderItemsOnView.current;
|
|
3303
|
+
var hitSet = new Set();
|
|
3304
|
+
|
|
3305
|
+
for (var i = items.length - 1; i >= 0; i--) {
|
|
3306
|
+
var item = items[i];
|
|
3307
|
+
|
|
3308
|
+
if (item.visible === undefined || item.visible) {
|
|
3309
|
+
var event_1 = item[eventName];
|
|
3310
|
+
|
|
3311
|
+
if (!event_1) {
|
|
3312
|
+
continue;
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
var pos = item.position;
|
|
3316
|
+
|
|
3317
|
+
if (pos && !pos.offset) {
|
|
3318
|
+
pos.offset = controller.positionToOffset(pos);
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
if (!pos || !pos.offset || !includes(clickedOffset, pos.offset, item.boxWidth, item.boxHeight)) {
|
|
3322
|
+
continue;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
event_1(clickedOffset);
|
|
3326
|
+
hitSet.add(item);
|
|
3327
|
+
break;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
return hitSet;
|
|
3332
|
+
}, []);
|
|
3333
|
+
React.useEffect(function () {
|
|
3334
|
+
var resizeObserver;
|
|
3335
|
+
|
|
3336
|
+
if (canvasRef.current && containerRef.current) {
|
|
3337
|
+
resizeObserver = new ResizeObserver(function (entries) {
|
|
3338
|
+
var elem = entries[0];
|
|
3339
|
+
canvasRef.current && contextRef.current && scaleCanvas(elem.target, canvasRef.current, contextRef.current);
|
|
3340
|
+
renderMain();
|
|
3341
|
+
});
|
|
3342
|
+
resizeObserver.observe(containerRef.current);
|
|
3343
|
+
var map = controller.getMap();
|
|
3344
|
+
|
|
3345
|
+
if (map) {
|
|
3346
|
+
map.addListener('zooming', function () {
|
|
3347
|
+
clearRect();
|
|
3348
|
+
});
|
|
3349
|
+
map.addListener('zoom_start', function () {
|
|
3350
|
+
clearRect();
|
|
3351
|
+
});
|
|
3352
|
+
map.addListener('center_changed', function () {
|
|
3353
|
+
|
|
3354
|
+
if (containerRef.current) {
|
|
3355
|
+
containerRef.current.style.visibility = 'hidden';
|
|
3356
|
+
}
|
|
3357
|
+
});
|
|
3358
|
+
map.addListener('idle', function () {
|
|
3359
|
+
|
|
3360
|
+
if (containerRef.current) {
|
|
3361
|
+
containerRef.current.style.visibility = '';
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
clearRect();
|
|
3365
|
+
invokeRender();
|
|
3366
|
+
});
|
|
3367
|
+
map.addListener('mousemove', function (e) {
|
|
3368
|
+
var clickPosition = parseClickParamToPosition(controller.getMapType(), e);
|
|
3369
|
+
var clickedOffset = controller.positionToOffset(clickPosition);
|
|
3370
|
+
var hitSet = processMouseEvent(clickedOffset, 'onMouseOver');
|
|
3371
|
+
renderItemsMouseOverStatus.current.forEach(function (item) {
|
|
3372
|
+
if (!hitSet.has(item)) {
|
|
3373
|
+
item.onMouseOut && item.onMouseOut(clickedOffset);
|
|
3374
|
+
}
|
|
3375
|
+
});
|
|
3376
|
+
renderItemsMouseOverStatus.current = hitSet;
|
|
3377
|
+
});
|
|
3378
|
+
map.addListener('click', function (e) {
|
|
3379
|
+
var clickPosition = parseClickParamToPosition(controller.getMapType(), e);
|
|
3380
|
+
var clickedOffset = controller.positionToOffset(clickPosition);
|
|
3381
|
+
processMouseEvent(clickedOffset, 'onClick');
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
contextRef.current = canvasRef.current.getContext('2d');
|
|
3386
|
+
|
|
3387
|
+
if (contextRef.current) {
|
|
3388
|
+
scaleCanvas(containerRef.current, canvasRef.current, contextRef.current);
|
|
3389
|
+
renderer.current = new MintMapCanvasRenderer(contextRef.current);
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
return function () {
|
|
3394
|
+
resizeObserver && resizeObserver.disconnect();
|
|
3395
|
+
};
|
|
3396
|
+
}, []);
|
|
3397
|
+
var renderItems = React.useRef([]);
|
|
3398
|
+
var renderItemsOnView = React.useRef([]);
|
|
3399
|
+
var renderItemsMouseOverStatus = React.useRef(new Set());
|
|
3400
|
+
React.useEffect(function () {
|
|
3401
|
+
renderItems.current = (Array.isArray(children) ? children : [children]).map(function (item) {
|
|
3402
|
+
return item.props;
|
|
3403
|
+
});
|
|
3404
|
+
var zIndexList = [];
|
|
3405
|
+
var undefinedList = [];
|
|
3406
|
+
|
|
3407
|
+
for (var _i = 0, _a = renderItems.current; _i < _a.length; _i++) {
|
|
3408
|
+
var item = _a[_i];
|
|
3409
|
+
|
|
3410
|
+
if (item.zIndex !== undefined) {
|
|
3411
|
+
zIndexList.push(item);
|
|
3412
|
+
} else {
|
|
3413
|
+
undefinedList.push(item);
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
renderItems.current = undefinedList;
|
|
3418
|
+
zIndexList.sort(function (a, b) {
|
|
3419
|
+
return a > b ? 1 : -1;
|
|
3420
|
+
}).forEach(function (item) {
|
|
3421
|
+
renderItems.current.push(item);
|
|
3422
|
+
});
|
|
3423
|
+
}, [children]);
|
|
3424
|
+
var renderMain = React.useCallback(function () {
|
|
3425
|
+
var ctx = contextRef.current;
|
|
3426
|
+
var container = containerRef.current;
|
|
3427
|
+
|
|
3428
|
+
if (!ctx || !container || !renderer.current) {
|
|
3429
|
+
return;
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
clearRect();
|
|
3433
|
+
var t = new Date().getTime();
|
|
3434
|
+
var items = renderItems.current;
|
|
3435
|
+
renderItemsOnView.current.length = 0;
|
|
3436
|
+
var newSet = new Set();
|
|
3437
|
+
|
|
3438
|
+
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
3439
|
+
var item = items_1[_i];
|
|
3440
|
+
|
|
3441
|
+
if (item.visible === undefined || item.visible) {
|
|
3442
|
+
var pos = item.position;
|
|
3443
|
+
pos.offset = controller.positionToOffset(pos);
|
|
3444
|
+
|
|
3445
|
+
if (item.anchor) {
|
|
3446
|
+
pos.offset.x += item.anchor.x;
|
|
3447
|
+
pos.offset.y += item.anchor.y;
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
console$1.log('canvas marker', pos.offset);
|
|
3451
|
+
|
|
3452
|
+
if (pos.offset.x < 0 || pos.offset.x > container.offsetWidth || pos.offset.y < 0 || pos.offset.y > container.offsetHeight) {
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
|
|
3456
|
+
item.renderer(renderer.current, pos.offset, item.payload);
|
|
3457
|
+
renderItemsOnView.current.push(item);
|
|
3458
|
+
newSet.add(item);
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
renderItemsMouseOverStatus.current.forEach(function (item) {
|
|
3463
|
+
if (!newSet.has(item)) {
|
|
3464
|
+
renderItemsMouseOverStatus.current.delete(item);
|
|
3465
|
+
}
|
|
3466
|
+
});
|
|
3467
|
+
console$1.log("[render ends] ".concat(new Date().getTime() - t, " ms"));
|
|
3468
|
+
}, []);
|
|
3469
|
+
renderMain();
|
|
3470
|
+
return React__default["default"].createElement("div", {
|
|
3471
|
+
ref: containerRef,
|
|
3472
|
+
style: {
|
|
3473
|
+
position: 'absolute',
|
|
3474
|
+
width: '100%',
|
|
3475
|
+
height: '100%',
|
|
3476
|
+
zIndex: 2,
|
|
3477
|
+
pointerEvents: 'none'
|
|
3478
|
+
}
|
|
3479
|
+
}, React__default["default"].createElement("canvas", {
|
|
3480
|
+
ref: canvasRef,
|
|
3481
|
+
style: {
|
|
3482
|
+
pointerEvents: 'revert-layer'
|
|
3483
|
+
}
|
|
3484
|
+
}), renderFlag && React__default["default"].createElement(React__default["default"].Fragment, null));
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
function MapCanvasMarkerWrapper(_props) {
|
|
3488
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3204
3491
|
exports.AnimationPlayer = AnimationPlayer;
|
|
3205
3492
|
exports.Bounds = Bounds;
|
|
3206
3493
|
exports.Drawable = Drawable;
|
|
3207
3494
|
exports.GeoCalulator = GeoCalulator;
|
|
3208
3495
|
exports.GoogleMintMapController = GoogleMintMapController;
|
|
3209
3496
|
exports.MapBuildingProjection = MapBuildingProjection;
|
|
3497
|
+
exports.MapCanvasMarkerWrapper = MapCanvasMarkerWrapper;
|
|
3498
|
+
exports.MapCanvasWrapper = MapCanvasWrapper;
|
|
3210
3499
|
exports.MapControlWrapper = MapControlWrapper;
|
|
3211
3500
|
exports.MapMarkerWrapper = MapMarkerWrapper;
|
|
3212
3501
|
exports.MapPolygonWrapper = MapPolygonWrapper;
|
|
3213
3502
|
exports.MapPolylineWrapper = MapPolylineWrapper;
|
|
3214
3503
|
exports.Marker = Marker;
|
|
3215
3504
|
exports.MintMap = MintMap;
|
|
3505
|
+
exports.MintMapCanvasRenderer = MintMapCanvasRenderer;
|
|
3216
3506
|
exports.MintMapController = MintMapController;
|
|
3217
3507
|
exports.MintMapCore = MintMapCore;
|
|
3218
3508
|
exports.MintMapProvider = MintMapProvider;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mint-ui/map",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2-beta",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"browser": "./dist/index.umd.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"repository": "https://github.com/dev-rsquare/mint-ui-map",
|
|
9
9
|
"author": "RSQUARE",
|
|
10
|
-
"keywords": ["react", "map", "google", "naver", "library", "typescript"],
|
|
10
|
+
"keywords": ["react", "react map", "map", "google", "naver", "kakao", "library", "typescript", "canvas", "marker"],
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"private": false,
|
|
13
13
|
"devDependencies": {
|