@mint-ui/map 0.2.1-beta → 0.3.1-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/dist/components/mint-map/MintMap.d.ts +3 -0
- package/dist/components/mint-map/MintMap.js +8 -4
- package/dist/components/mint-map/core/MintMapController.d.ts +2 -0
- package/dist/components/mint-map/core/MintMapController.js +13 -0
- package/dist/components/mint-map/core/util/cluster.d.ts +18 -0
- package/dist/components/mint-map/core/util/cluster.js +139 -0
- package/dist/components/mint-map/core/util/index.d.ts +1 -0
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +1 -1
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +1 -1
- package/dist/components/mint-map/google/GoogleMintMapController.js +30 -4
- package/dist/components/mint-map/naver/NaverMintMapController.js +26 -8
- package/dist/index.es.js +212 -19
- package/dist/index.js +2 -0
- package/dist/index.umd.js +212 -18
- package/package.json +1 -1
|
@@ -12,12 +12,14 @@ export interface MintMapProps extends MintMapEvents {
|
|
|
12
12
|
visible?: boolean;
|
|
13
13
|
markerCache?: boolean;
|
|
14
14
|
markerCachePoolSize?: number;
|
|
15
|
+
boundsChangeThrottlingTime?: number;
|
|
15
16
|
}
|
|
16
17
|
export interface MintMapEvents {
|
|
17
18
|
onBoundsChanged?: (bounds: Bounds) => void;
|
|
18
19
|
onZoomChanged?: (level: number) => void;
|
|
19
20
|
onLoad?: (map: MapVendorType, controller: MintMapController) => void;
|
|
20
21
|
onClick?: (positon: Position) => void;
|
|
22
|
+
onMouseMove?: (positon: Position) => void;
|
|
21
23
|
}
|
|
22
24
|
export declare class Position {
|
|
23
25
|
lat: number;
|
|
@@ -36,6 +38,7 @@ export declare class Bounds {
|
|
|
36
38
|
private covertNWSEtoNESW;
|
|
37
39
|
private covertNESWtoNWSE;
|
|
38
40
|
getCenter(): Position;
|
|
41
|
+
includesPosition(pos: Position): boolean;
|
|
39
42
|
getIncludedPositions(positions: Position[]): Position[];
|
|
40
43
|
includes(positions: Position | Position[]): boolean;
|
|
41
44
|
includesOnlyOnePoint(positions: Position[]): boolean;
|
|
@@ -65,7 +65,11 @@ var Bounds = function () {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
Bounds.prototype.getCenter = function () {
|
|
68
|
-
return new Position(this.
|
|
68
|
+
return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Bounds.prototype.includesPosition = function (pos) {
|
|
72
|
+
return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat;
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
@@ -74,7 +78,7 @@ var Bounds = function () {
|
|
|
74
78
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
75
79
|
var pos = positions_1[_i];
|
|
76
80
|
|
|
77
|
-
if (
|
|
81
|
+
if (this.includesPosition(pos)) {
|
|
78
82
|
result.push(pos);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -88,7 +92,7 @@ var Bounds = function () {
|
|
|
88
92
|
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
89
93
|
var pos = positions_2[_i];
|
|
90
94
|
|
|
91
|
-
if (this.
|
|
95
|
+
if (!this.includesPosition(pos)) {
|
|
92
96
|
return false;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -100,7 +104,7 @@ var Bounds = function () {
|
|
|
100
104
|
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
101
105
|
var pos = positions_3[_i];
|
|
102
106
|
|
|
103
|
-
if (
|
|
107
|
+
if (this.includesPosition(pos)) {
|
|
104
108
|
return true;
|
|
105
109
|
}
|
|
106
110
|
}
|
|
@@ -8,6 +8,7 @@ var MintMapController = function () {
|
|
|
8
8
|
function MintMapController(props) {
|
|
9
9
|
this.mapApiLoaded = false;
|
|
10
10
|
this.mapInitialized = false;
|
|
11
|
+
this.processedTime = 0;
|
|
11
12
|
this.mapProps = props;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -52,6 +53,18 @@ var MintMapController = function () {
|
|
|
52
53
|
return "".concat(baseUrl, "?").concat(params);
|
|
53
54
|
};
|
|
54
55
|
|
|
56
|
+
MintMapController.prototype.checkBoundsChangeThrottleTime = function () {
|
|
57
|
+
if (!this.mapProps.boundsChangeThrottlingTime) return true;
|
|
58
|
+
var time = new Date().getTime();
|
|
59
|
+
|
|
60
|
+
if (this.processedTime > 0 && time - this.processedTime < this.mapProps.boundsChangeThrottlingTime) {
|
|
61
|
+
return false;
|
|
62
|
+
} else {
|
|
63
|
+
this.processedTime = time;
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
55
68
|
return MintMapController;
|
|
56
69
|
}();
|
|
57
70
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Bounds, Position } from "../../MintMap";
|
|
2
|
+
export interface ClusterInfo {
|
|
3
|
+
bounds: Bounds;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
center: boolean;
|
|
6
|
+
centerPosition: Position;
|
|
7
|
+
incList: any;
|
|
8
|
+
itemList: Position[];
|
|
9
|
+
size: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ClusterStatus {
|
|
12
|
+
total: number;
|
|
13
|
+
average: number;
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
}
|
|
17
|
+
export declare type ClusterSizeCalculator = (info: ClusterInfo, status: ClusterStatus) => number;
|
|
18
|
+
export declare const getClusterInfo: (basePixelSize: number, mapBounds: Bounds, mapWidth: number, mapHeight: number, itemList: Position[], sizeFunction?: ClusterSizeCalculator) => (ClusterInfo[] | Bounds[])[];
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var MintMap = require('../../MintMap.js');
|
|
6
|
+
|
|
7
|
+
var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, itemList, sizeFunction) {
|
|
8
|
+
var _a;
|
|
9
|
+
|
|
10
|
+
var rowCount = Number((mapWidth / basePixelSize).toFixed(0)) || 1;
|
|
11
|
+
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1;
|
|
12
|
+
var boundsLineSizeX = Number(((mapBounds.ne.lng - mapBounds.nw.lng) / rowCount).toFixed(7));
|
|
13
|
+
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7));
|
|
14
|
+
var boundsList = [];
|
|
15
|
+
var boundsPos = [];
|
|
16
|
+
var tempX1, tempY1, tempX2, tempY2;
|
|
17
|
+
|
|
18
|
+
for (var i = 0; i < rowCount; i++) {
|
|
19
|
+
tempX1 = mapBounds.nw.lng + boundsLineSizeX * i;
|
|
20
|
+
tempX2 = mapBounds.nw.lng + boundsLineSizeX * (i + 1);
|
|
21
|
+
var rows = [];
|
|
22
|
+
boundsPos.push(rows);
|
|
23
|
+
|
|
24
|
+
for (var k = 0; k < colCount; k++) {
|
|
25
|
+
tempY2 = mapBounds.se.lat + boundsLineSizeY * k;
|
|
26
|
+
tempY1 = mapBounds.se.lat + boundsLineSizeY * (k + 1);
|
|
27
|
+
var thisBounds = MintMap.Bounds.fromNWSE(new MintMap.Position(tempY1, tempX1), new MintMap.Position(tempY2, tempX2));
|
|
28
|
+
var includedList = thisBounds.getIncludedPositions(itemList);
|
|
29
|
+
rows.push({
|
|
30
|
+
bounds: thisBounds,
|
|
31
|
+
checked: false,
|
|
32
|
+
center: false,
|
|
33
|
+
centerPosition: thisBounds.getCenter(),
|
|
34
|
+
incList: [],
|
|
35
|
+
itemList: includedList,
|
|
36
|
+
size: basePixelSize
|
|
37
|
+
});
|
|
38
|
+
boundsList.push(thisBounds);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var centerList = [];
|
|
43
|
+
var totalItemCount = 0;
|
|
44
|
+
var min;
|
|
45
|
+
var max;
|
|
46
|
+
|
|
47
|
+
for (var i = 0; i < boundsPos.length; i++) {
|
|
48
|
+
for (var k = 0; k < boundsPos[i].length; k++) {
|
|
49
|
+
var curr = boundsPos[i][k];
|
|
50
|
+
if (curr.checked) continue;
|
|
51
|
+
curr.checked = true;
|
|
52
|
+
var incList = [];
|
|
53
|
+
|
|
54
|
+
if (boundsPos[i]) {
|
|
55
|
+
boundsPos[i][k - 1] && incList.push(boundsPos[i][k - 1]);
|
|
56
|
+
boundsPos[i][k + 1] && incList.push(boundsPos[i][k + 1]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (boundsPos[i - 1]) {
|
|
60
|
+
boundsPos[i - 1][k - 1] && incList.push(boundsPos[i - 1][k - 1]);
|
|
61
|
+
boundsPos[i - 1][k] && incList.push(boundsPos[i - 1][k]);
|
|
62
|
+
boundsPos[i - 1][k + 1] && incList.push(boundsPos[i - 1][k + 1]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (boundsPos[i + 1]) {
|
|
66
|
+
boundsPos[i + 1][k + 1] && incList.push(boundsPos[i + 1][k + 1]);
|
|
67
|
+
boundsPos[i + 1][k] && incList.push(boundsPos[i + 1][k]);
|
|
68
|
+
boundsPos[i + 1][k - 1] && incList.push(boundsPos[i + 1][k - 1]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (var _i = 0, incList_1 = incList; _i < incList_1.length; _i++) {
|
|
72
|
+
var inc = incList_1[_i];
|
|
73
|
+
if (inc.checked) continue;
|
|
74
|
+
inc.checked = true;
|
|
75
|
+
|
|
76
|
+
if (inc.itemList && inc.itemList.length > 0) {
|
|
77
|
+
curr.incList.push(inc);
|
|
78
|
+
|
|
79
|
+
(_a = curr.itemList).push.apply(_a, inc.itemList);
|
|
80
|
+
|
|
81
|
+
curr.center = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (curr.center) {
|
|
86
|
+
centerList.push(curr);
|
|
87
|
+
var avrLat = calculateAverage(curr.itemList.map(function (item) {
|
|
88
|
+
return item.lat;
|
|
89
|
+
}));
|
|
90
|
+
var avrLng = calculateAverage(curr.itemList.map(function (item) {
|
|
91
|
+
return item.lng;
|
|
92
|
+
}));
|
|
93
|
+
curr.centerPosition = new MintMap.Position(avrLat, avrLng);
|
|
94
|
+
totalItemCount += curr.itemList.length;
|
|
95
|
+
|
|
96
|
+
if (!min || curr.itemList.length < min) {
|
|
97
|
+
min = curr.itemList.length;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!max || curr.itemList.length > max) {
|
|
101
|
+
max = curr.itemList.length;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var status = {
|
|
108
|
+
total: totalItemCount,
|
|
109
|
+
average: totalItemCount / centerList.length,
|
|
110
|
+
min: min,
|
|
111
|
+
max: max
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
sizeFunction = sizeFunction || function (info, status) {
|
|
115
|
+
var minSize = basePixelSize / 4;
|
|
116
|
+
var maxSize = basePixelSize;
|
|
117
|
+
return Math.min(Math.max(basePixelSize * info.itemList.length / status.average, minSize), maxSize);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
for (var _b = 0, centerList_1 = centerList; _b < centerList_1.length; _b++) {
|
|
121
|
+
var center = centerList_1[_b];
|
|
122
|
+
center.size = sizeFunction(center, status);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return [centerList, boundsList];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
var calculateAverage = function (nums) {
|
|
129
|
+
var sum = 0;
|
|
130
|
+
|
|
131
|
+
for (var _i = 0, nums_1 = nums; _i < nums_1.length; _i++) {
|
|
132
|
+
var num = nums_1[_i];
|
|
133
|
+
sum += num;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return Number((sum / nums.length).toFixed(7));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
exports.getClusterInfo = getClusterInfo;
|
|
@@ -19,7 +19,7 @@ function MapPolygonWrapper(_a) {
|
|
|
19
19
|
React.useEffect(function () {
|
|
20
20
|
return function () {
|
|
21
21
|
if (polygonRef.current) {
|
|
22
|
-
|
|
22
|
+
controller.clearDrawable(polygonRef.current);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
}, []);
|
|
@@ -19,7 +19,7 @@ function MapPolylineWrapper(_a) {
|
|
|
19
19
|
React.useEffect(function () {
|
|
20
20
|
return function () {
|
|
21
21
|
if (polylineRef.current) {
|
|
22
|
-
|
|
22
|
+
controller.clearDrawable(polylineRef.current);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
}, []);
|
|
@@ -23,7 +23,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
23
23
|
_this.dragged = false;
|
|
24
24
|
|
|
25
25
|
_this.destroyMap = function () {
|
|
26
|
-
|
|
26
|
+
try {
|
|
27
|
+
_this.map && google.maps.event.clearInstanceListeners(_this.map);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.log('google map destroy error', e);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log("".concat(_this.type, " map destroyed"));
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
console.log("".concat(_this.type, " controller loadded"));
|
|
@@ -137,6 +143,16 @@ var GoogleMintMapController = function (_super) {
|
|
|
137
143
|
GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
138
144
|
if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
|
|
139
145
|
var polygonOption = this.getValidOptions(options);
|
|
146
|
+
|
|
147
|
+
if (this.map && Array.isArray(options.position)) {
|
|
148
|
+
var outLine = options.position.map(function (elem) {
|
|
149
|
+
return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
|
|
150
|
+
});
|
|
151
|
+
var paths = [outLine];
|
|
152
|
+
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
153
|
+
polygonOption.paths = paths;
|
|
154
|
+
}
|
|
155
|
+
|
|
140
156
|
polygon.native.setOptions(polygonOption);
|
|
141
157
|
}
|
|
142
158
|
};
|
|
@@ -368,18 +384,28 @@ var GoogleMintMapController = function (_super) {
|
|
|
368
384
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
369
385
|
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
370
386
|
disableDefaultUI: true,
|
|
371
|
-
gestureHandling: 'greedy'
|
|
387
|
+
gestureHandling: 'greedy',
|
|
388
|
+
clickableIcons: false
|
|
372
389
|
});
|
|
373
390
|
map.addListener('idle', function () {
|
|
374
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
391
|
+
_this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
375
392
|
});
|
|
376
393
|
map.addListener('zoom_changed', function () {
|
|
377
394
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
378
395
|
});
|
|
379
396
|
map.addListener('click', function (e) {
|
|
397
|
+
if (!_this.mapProps.onClick) return;
|
|
398
|
+
var pos = new MintMap.Position(e.latLng.lat(), e.latLng.lng());
|
|
399
|
+
pos.offset = new MintMap.Offset(e.pixel.x, e.pixel.y);
|
|
400
|
+
|
|
401
|
+
_this.mapProps.onClick(pos);
|
|
402
|
+
});
|
|
403
|
+
map.addListener('mousemove', function (e) {
|
|
404
|
+
if (!_this.mapProps.onMouseMove) return;
|
|
380
405
|
var pos = new MintMap.Position(e.latLng.lat(), e.latLng.lng());
|
|
381
406
|
pos.offset = new MintMap.Offset(e.pixel.x, e.pixel.y);
|
|
382
|
-
|
|
407
|
+
|
|
408
|
+
_this.mapProps.onMouseMove(pos);
|
|
383
409
|
});
|
|
384
410
|
this.map = map;
|
|
385
411
|
this.mapInitialized = true;
|
|
@@ -151,8 +151,18 @@ var NaverMintMapController = function (_super) {
|
|
|
151
151
|
|
|
152
152
|
NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
153
153
|
if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
|
|
154
|
+
var paths = void 0;
|
|
155
|
+
|
|
156
|
+
if (Array.isArray(options.position)) {
|
|
157
|
+
var outLine = options.position.map(function (elem) {
|
|
158
|
+
return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
|
|
159
|
+
});
|
|
160
|
+
paths = [outLine];
|
|
161
|
+
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
162
|
+
}
|
|
163
|
+
|
|
154
164
|
polygon.native.setOptions({
|
|
155
|
-
paths: polygon.native.getPaths(),
|
|
165
|
+
paths: paths || polygon.native.getPaths(),
|
|
156
166
|
visible: options.visible === undefined || options.visible,
|
|
157
167
|
strokeColor: options.lineColor,
|
|
158
168
|
strokeWeight: options.lineSize,
|
|
@@ -416,17 +426,25 @@ var NaverMintMapController = function (_super) {
|
|
|
416
426
|
_this.dragged = true;
|
|
417
427
|
}
|
|
418
428
|
});
|
|
419
|
-
map.addListener('idle', function () {
|
|
420
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
429
|
+
map.addListener('idle', function (e) {
|
|
430
|
+
_this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
421
431
|
});
|
|
422
432
|
map.addListener('zoom_changed', function () {
|
|
423
433
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
424
434
|
});
|
|
425
435
|
map.addListener('click', function (e) {
|
|
426
|
-
|
|
436
|
+
if (!_this.mapProps.onClick) return;
|
|
427
437
|
var pos = new MintMap.Position(e.coord.y, e.coord.x);
|
|
428
438
|
pos.offset = new MintMap.Offset(e.offset.x, e.offset.y);
|
|
429
|
-
|
|
439
|
+
|
|
440
|
+
_this.mapProps.onClick(pos);
|
|
441
|
+
});
|
|
442
|
+
map.addListener('mousemove', function (e) {
|
|
443
|
+
if (!_this.mapProps.onMouseMove) return;
|
|
444
|
+
var pos = new MintMap.Position(e.coord.y, e.coord.x);
|
|
445
|
+
pos.offset = new MintMap.Offset(e.offset.x, e.offset.y);
|
|
446
|
+
|
|
447
|
+
_this.mapProps.onMouseMove(pos);
|
|
430
448
|
});
|
|
431
449
|
this.map = map;
|
|
432
450
|
this.mapInitialized = true;
|
|
@@ -455,14 +473,14 @@ var NaverMintMapController = function (_super) {
|
|
|
455
473
|
NaverMintMapController.prototype.destroyMap = function () {
|
|
456
474
|
var _a;
|
|
457
475
|
|
|
458
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
459
|
-
|
|
460
476
|
try {
|
|
461
477
|
this.map && this.map.destroy();
|
|
462
478
|
(_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
463
479
|
} catch (e) {
|
|
464
480
|
console.log('naver map destroy error', e);
|
|
465
481
|
}
|
|
482
|
+
|
|
483
|
+
console.log("".concat(this.type, " map destroyed"));
|
|
466
484
|
};
|
|
467
485
|
|
|
468
486
|
NaverMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -471,7 +489,7 @@ var NaverMintMapController = function (_super) {
|
|
|
471
489
|
}
|
|
472
490
|
|
|
473
491
|
var bounds = this.map.getBounds();
|
|
474
|
-
return MintMap.Bounds.fromNWSE(new MintMap.Position(bounds.
|
|
492
|
+
return MintMap.Bounds.fromNWSE(new MintMap.Position(bounds.getMax().y, bounds.getMin().x), new MintMap.Position(bounds.getMin().y, bounds.getMax().x));
|
|
475
493
|
};
|
|
476
494
|
|
|
477
495
|
NaverMintMapController.prototype.panningTo = function (targetCenter) {
|
package/dist/index.es.js
CHANGED
|
@@ -319,6 +319,7 @@ var MintMapController = function () {
|
|
|
319
319
|
function MintMapController(props) {
|
|
320
320
|
this.mapApiLoaded = false;
|
|
321
321
|
this.mapInitialized = false;
|
|
322
|
+
this.processedTime = 0;
|
|
322
323
|
this.mapProps = props;
|
|
323
324
|
}
|
|
324
325
|
|
|
@@ -363,6 +364,18 @@ var MintMapController = function () {
|
|
|
363
364
|
return "".concat(baseUrl, "?").concat(params);
|
|
364
365
|
};
|
|
365
366
|
|
|
367
|
+
MintMapController.prototype.checkBoundsChangeThrottleTime = function () {
|
|
368
|
+
if (!this.mapProps.boundsChangeThrottlingTime) return true;
|
|
369
|
+
var time = new Date().getTime();
|
|
370
|
+
|
|
371
|
+
if (this.processedTime > 0 && time - this.processedTime < this.mapProps.boundsChangeThrottlingTime) {
|
|
372
|
+
return false;
|
|
373
|
+
} else {
|
|
374
|
+
this.processedTime = time;
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
366
379
|
return MintMapController;
|
|
367
380
|
}();
|
|
368
381
|
|
|
@@ -535,8 +548,18 @@ var NaverMintMapController = function (_super) {
|
|
|
535
548
|
|
|
536
549
|
NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
537
550
|
if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
|
|
551
|
+
var paths = void 0;
|
|
552
|
+
|
|
553
|
+
if (Array.isArray(options.position)) {
|
|
554
|
+
var outLine = options.position.map(function (elem) {
|
|
555
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
556
|
+
});
|
|
557
|
+
paths = [outLine];
|
|
558
|
+
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
559
|
+
}
|
|
560
|
+
|
|
538
561
|
polygon.native.setOptions({
|
|
539
|
-
paths: polygon.native.getPaths(),
|
|
562
|
+
paths: paths || polygon.native.getPaths(),
|
|
540
563
|
visible: options.visible === undefined || options.visible,
|
|
541
564
|
strokeColor: options.lineColor,
|
|
542
565
|
strokeWeight: options.lineSize,
|
|
@@ -800,17 +823,25 @@ var NaverMintMapController = function (_super) {
|
|
|
800
823
|
_this.dragged = true;
|
|
801
824
|
}
|
|
802
825
|
});
|
|
803
|
-
map.addListener('idle', function () {
|
|
804
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
826
|
+
map.addListener('idle', function (e) {
|
|
827
|
+
_this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
805
828
|
});
|
|
806
829
|
map.addListener('zoom_changed', function () {
|
|
807
830
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
808
831
|
});
|
|
809
832
|
map.addListener('click', function (e) {
|
|
810
|
-
|
|
833
|
+
if (!_this.mapProps.onClick) return;
|
|
811
834
|
var pos = new Position(e.coord.y, e.coord.x);
|
|
812
835
|
pos.offset = new Offset(e.offset.x, e.offset.y);
|
|
813
|
-
|
|
836
|
+
|
|
837
|
+
_this.mapProps.onClick(pos);
|
|
838
|
+
});
|
|
839
|
+
map.addListener('mousemove', function (e) {
|
|
840
|
+
if (!_this.mapProps.onMouseMove) return;
|
|
841
|
+
var pos = new Position(e.coord.y, e.coord.x);
|
|
842
|
+
pos.offset = new Offset(e.offset.x, e.offset.y);
|
|
843
|
+
|
|
844
|
+
_this.mapProps.onMouseMove(pos);
|
|
814
845
|
});
|
|
815
846
|
this.map = map;
|
|
816
847
|
this.mapInitialized = true;
|
|
@@ -839,14 +870,14 @@ var NaverMintMapController = function (_super) {
|
|
|
839
870
|
NaverMintMapController.prototype.destroyMap = function () {
|
|
840
871
|
var _a;
|
|
841
872
|
|
|
842
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
843
|
-
|
|
844
873
|
try {
|
|
845
874
|
this.map && this.map.destroy();
|
|
846
875
|
(_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
847
876
|
} catch (e) {
|
|
848
877
|
console.log('naver map destroy error', e);
|
|
849
878
|
}
|
|
879
|
+
|
|
880
|
+
console.log("".concat(this.type, " map destroyed"));
|
|
850
881
|
};
|
|
851
882
|
|
|
852
883
|
NaverMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -855,7 +886,7 @@ var NaverMintMapController = function (_super) {
|
|
|
855
886
|
}
|
|
856
887
|
|
|
857
888
|
var bounds = this.map.getBounds();
|
|
858
|
-
return Bounds.fromNWSE(new Position(bounds.
|
|
889
|
+
return Bounds.fromNWSE(new Position(bounds.getMax().y, bounds.getMin().x), new Position(bounds.getMin().y, bounds.getMax().x));
|
|
859
890
|
};
|
|
860
891
|
|
|
861
892
|
NaverMintMapController.prototype.panningTo = function (targetCenter) {
|
|
@@ -897,7 +928,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
897
928
|
_this.dragged = false;
|
|
898
929
|
|
|
899
930
|
_this.destroyMap = function () {
|
|
900
|
-
|
|
931
|
+
try {
|
|
932
|
+
_this.map && google.maps.event.clearInstanceListeners(_this.map);
|
|
933
|
+
} catch (e) {
|
|
934
|
+
console.log('google map destroy error', e);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
console.log("".concat(_this.type, " map destroyed"));
|
|
901
938
|
};
|
|
902
939
|
|
|
903
940
|
console.log("".concat(_this.type, " controller loadded"));
|
|
@@ -1011,6 +1048,16 @@ var GoogleMintMapController = function (_super) {
|
|
|
1011
1048
|
GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
1012
1049
|
if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
|
|
1013
1050
|
var polygonOption = this.getValidOptions(options);
|
|
1051
|
+
|
|
1052
|
+
if (this.map && Array.isArray(options.position)) {
|
|
1053
|
+
var outLine = options.position.map(function (elem) {
|
|
1054
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
1055
|
+
});
|
|
1056
|
+
var paths = [outLine];
|
|
1057
|
+
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
1058
|
+
polygonOption.paths = paths;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1014
1061
|
polygon.native.setOptions(polygonOption);
|
|
1015
1062
|
}
|
|
1016
1063
|
};
|
|
@@ -1242,18 +1289,28 @@ var GoogleMintMapController = function (_super) {
|
|
|
1242
1289
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
1243
1290
|
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
1244
1291
|
disableDefaultUI: true,
|
|
1245
|
-
gestureHandling: 'greedy'
|
|
1292
|
+
gestureHandling: 'greedy',
|
|
1293
|
+
clickableIcons: false
|
|
1246
1294
|
});
|
|
1247
1295
|
map.addListener('idle', function () {
|
|
1248
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1296
|
+
_this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1249
1297
|
});
|
|
1250
1298
|
map.addListener('zoom_changed', function () {
|
|
1251
1299
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
1252
1300
|
});
|
|
1253
1301
|
map.addListener('click', function (e) {
|
|
1302
|
+
if (!_this.mapProps.onClick) return;
|
|
1254
1303
|
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1255
1304
|
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1256
|
-
|
|
1305
|
+
|
|
1306
|
+
_this.mapProps.onClick(pos);
|
|
1307
|
+
});
|
|
1308
|
+
map.addListener('mousemove', function (e) {
|
|
1309
|
+
if (!_this.mapProps.onMouseMove) return;
|
|
1310
|
+
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1311
|
+
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1312
|
+
|
|
1313
|
+
_this.mapProps.onMouseMove(pos);
|
|
1257
1314
|
});
|
|
1258
1315
|
this.map = map;
|
|
1259
1316
|
this.mapInitialized = true;
|
|
@@ -1355,7 +1412,11 @@ var Bounds = function () {
|
|
|
1355
1412
|
};
|
|
1356
1413
|
|
|
1357
1414
|
Bounds.prototype.getCenter = function () {
|
|
1358
|
-
return new Position(this.
|
|
1415
|
+
return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
Bounds.prototype.includesPosition = function (pos) {
|
|
1419
|
+
return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat;
|
|
1359
1420
|
};
|
|
1360
1421
|
|
|
1361
1422
|
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
@@ -1364,7 +1425,7 @@ var Bounds = function () {
|
|
|
1364
1425
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
1365
1426
|
var pos = positions_1[_i];
|
|
1366
1427
|
|
|
1367
|
-
if (
|
|
1428
|
+
if (this.includesPosition(pos)) {
|
|
1368
1429
|
result.push(pos);
|
|
1369
1430
|
}
|
|
1370
1431
|
}
|
|
@@ -1378,7 +1439,7 @@ var Bounds = function () {
|
|
|
1378
1439
|
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
1379
1440
|
var pos = positions_2[_i];
|
|
1380
1441
|
|
|
1381
|
-
if (this.
|
|
1442
|
+
if (!this.includesPosition(pos)) {
|
|
1382
1443
|
return false;
|
|
1383
1444
|
}
|
|
1384
1445
|
}
|
|
@@ -1390,7 +1451,7 @@ var Bounds = function () {
|
|
|
1390
1451
|
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
1391
1452
|
var pos = positions_3[_i];
|
|
1392
1453
|
|
|
1393
|
-
if (
|
|
1454
|
+
if (this.includesPosition(pos)) {
|
|
1394
1455
|
return true;
|
|
1395
1456
|
}
|
|
1396
1457
|
}
|
|
@@ -1930,7 +1991,7 @@ function MapPolygonWrapper(_a) {
|
|
|
1930
1991
|
useEffect(function () {
|
|
1931
1992
|
return function () {
|
|
1932
1993
|
if (polygonRef.current) {
|
|
1933
|
-
|
|
1994
|
+
controller.clearDrawable(polygonRef.current);
|
|
1934
1995
|
}
|
|
1935
1996
|
};
|
|
1936
1997
|
}, []);
|
|
@@ -2106,6 +2167,138 @@ function MapBuildingProjection(props) {
|
|
|
2106
2167
|
}, "".concat(title, " (").concat(numberOfFloor, "\uCE35)")))));
|
|
2107
2168
|
}
|
|
2108
2169
|
|
|
2170
|
+
var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, itemList, sizeFunction) {
|
|
2171
|
+
var _a;
|
|
2172
|
+
|
|
2173
|
+
var rowCount = Number((mapWidth / basePixelSize).toFixed(0)) || 1;
|
|
2174
|
+
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1;
|
|
2175
|
+
var boundsLineSizeX = Number(((mapBounds.ne.lng - mapBounds.nw.lng) / rowCount).toFixed(7));
|
|
2176
|
+
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7));
|
|
2177
|
+
var boundsList = [];
|
|
2178
|
+
var boundsPos = [];
|
|
2179
|
+
var tempX1, tempY1, tempX2, tempY2;
|
|
2180
|
+
|
|
2181
|
+
for (var i = 0; i < rowCount; i++) {
|
|
2182
|
+
tempX1 = mapBounds.nw.lng + boundsLineSizeX * i;
|
|
2183
|
+
tempX2 = mapBounds.nw.lng + boundsLineSizeX * (i + 1);
|
|
2184
|
+
var rows = [];
|
|
2185
|
+
boundsPos.push(rows);
|
|
2186
|
+
|
|
2187
|
+
for (var k = 0; k < colCount; k++) {
|
|
2188
|
+
tempY2 = mapBounds.se.lat + boundsLineSizeY * k;
|
|
2189
|
+
tempY1 = mapBounds.se.lat + boundsLineSizeY * (k + 1);
|
|
2190
|
+
var thisBounds = Bounds.fromNWSE(new Position(tempY1, tempX1), new Position(tempY2, tempX2));
|
|
2191
|
+
var includedList = thisBounds.getIncludedPositions(itemList);
|
|
2192
|
+
rows.push({
|
|
2193
|
+
bounds: thisBounds,
|
|
2194
|
+
checked: false,
|
|
2195
|
+
center: false,
|
|
2196
|
+
centerPosition: thisBounds.getCenter(),
|
|
2197
|
+
incList: [],
|
|
2198
|
+
itemList: includedList,
|
|
2199
|
+
size: basePixelSize
|
|
2200
|
+
});
|
|
2201
|
+
boundsList.push(thisBounds);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
var centerList = [];
|
|
2206
|
+
var totalItemCount = 0;
|
|
2207
|
+
var min;
|
|
2208
|
+
var max;
|
|
2209
|
+
|
|
2210
|
+
for (var i = 0; i < boundsPos.length; i++) {
|
|
2211
|
+
for (var k = 0; k < boundsPos[i].length; k++) {
|
|
2212
|
+
var curr = boundsPos[i][k];
|
|
2213
|
+
if (curr.checked) continue;
|
|
2214
|
+
curr.checked = true;
|
|
2215
|
+
var incList = [];
|
|
2216
|
+
|
|
2217
|
+
if (boundsPos[i]) {
|
|
2218
|
+
boundsPos[i][k - 1] && incList.push(boundsPos[i][k - 1]);
|
|
2219
|
+
boundsPos[i][k + 1] && incList.push(boundsPos[i][k + 1]);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
if (boundsPos[i - 1]) {
|
|
2223
|
+
boundsPos[i - 1][k - 1] && incList.push(boundsPos[i - 1][k - 1]);
|
|
2224
|
+
boundsPos[i - 1][k] && incList.push(boundsPos[i - 1][k]);
|
|
2225
|
+
boundsPos[i - 1][k + 1] && incList.push(boundsPos[i - 1][k + 1]);
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
if (boundsPos[i + 1]) {
|
|
2229
|
+
boundsPos[i + 1][k + 1] && incList.push(boundsPos[i + 1][k + 1]);
|
|
2230
|
+
boundsPos[i + 1][k] && incList.push(boundsPos[i + 1][k]);
|
|
2231
|
+
boundsPos[i + 1][k - 1] && incList.push(boundsPos[i + 1][k - 1]);
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
for (var _i = 0, incList_1 = incList; _i < incList_1.length; _i++) {
|
|
2235
|
+
var inc = incList_1[_i];
|
|
2236
|
+
if (inc.checked) continue;
|
|
2237
|
+
inc.checked = true;
|
|
2238
|
+
|
|
2239
|
+
if (inc.itemList && inc.itemList.length > 0) {
|
|
2240
|
+
curr.incList.push(inc);
|
|
2241
|
+
|
|
2242
|
+
(_a = curr.itemList).push.apply(_a, inc.itemList);
|
|
2243
|
+
|
|
2244
|
+
curr.center = true;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
if (curr.center) {
|
|
2249
|
+
centerList.push(curr);
|
|
2250
|
+
var avrLat = calculateAverage(curr.itemList.map(function (item) {
|
|
2251
|
+
return item.lat;
|
|
2252
|
+
}));
|
|
2253
|
+
var avrLng = calculateAverage(curr.itemList.map(function (item) {
|
|
2254
|
+
return item.lng;
|
|
2255
|
+
}));
|
|
2256
|
+
curr.centerPosition = new Position(avrLat, avrLng);
|
|
2257
|
+
totalItemCount += curr.itemList.length;
|
|
2258
|
+
|
|
2259
|
+
if (!min || curr.itemList.length < min) {
|
|
2260
|
+
min = curr.itemList.length;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
if (!max || curr.itemList.length > max) {
|
|
2264
|
+
max = curr.itemList.length;
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
var status = {
|
|
2271
|
+
total: totalItemCount,
|
|
2272
|
+
average: totalItemCount / centerList.length,
|
|
2273
|
+
min: min,
|
|
2274
|
+
max: max
|
|
2275
|
+
};
|
|
2276
|
+
|
|
2277
|
+
sizeFunction = sizeFunction || function (info, status) {
|
|
2278
|
+
var minSize = basePixelSize / 4;
|
|
2279
|
+
var maxSize = basePixelSize;
|
|
2280
|
+
return Math.min(Math.max(basePixelSize * info.itemList.length / status.average, minSize), maxSize);
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
for (var _b = 0, centerList_1 = centerList; _b < centerList_1.length; _b++) {
|
|
2284
|
+
var center = centerList_1[_b];
|
|
2285
|
+
center.size = sizeFunction(center, status);
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
return [centerList, boundsList];
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
var calculateAverage = function (nums) {
|
|
2292
|
+
var sum = 0;
|
|
2293
|
+
|
|
2294
|
+
for (var _i = 0, nums_1 = nums; _i < nums_1.length; _i++) {
|
|
2295
|
+
var num = nums_1[_i];
|
|
2296
|
+
sum += num;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
return Number((sum / nums.length).toFixed(7));
|
|
2300
|
+
};
|
|
2301
|
+
|
|
2109
2302
|
var css_248z = ".MintMapWrapper-module_mint-map-control-wrapper__DDb4y {\n position: absolute;\n z-index: 101;\n}\n\n.MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV {\n position: absolute;\n z-index: 1;\n}";
|
|
2110
2303
|
var styles = {"mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
|
|
2111
2304
|
styleInject(css_248z);
|
|
@@ -2183,7 +2376,7 @@ function MapPolylineWrapper(_a) {
|
|
|
2183
2376
|
useEffect(function () {
|
|
2184
2377
|
return function () {
|
|
2185
2378
|
if (polylineRef.current) {
|
|
2186
|
-
|
|
2379
|
+
controller.clearDrawable(polylineRef.current);
|
|
2187
2380
|
}
|
|
2188
2381
|
};
|
|
2189
2382
|
}, []);
|
|
@@ -2202,4 +2395,4 @@ function MapPolylineWrapper(_a) {
|
|
|
2202
2395
|
return React.createElement(React.Fragment, null, options && children);
|
|
2203
2396
|
}
|
|
2204
2397
|
|
|
2205
|
-
export { AnimationPlayer, Bounds, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapControlWrapper, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, Marker, MintMap, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, Polygon, PolygonCalculator, Polyline, Position, useMarkerMoving, useMintMapController, waiting };
|
|
2398
|
+
export { AnimationPlayer, Bounds, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapControlWrapper, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, Marker, MintMap, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, Polygon, PolygonCalculator, Polyline, Position, getClusterInfo, useMarkerMoving, useMintMapController, waiting };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var MintMapProvider = require('./components/mint-map/core/provider/MintMapProvid
|
|
|
11
11
|
var animation = require('./components/mint-map/core/util/animation.js');
|
|
12
12
|
var calculate = require('./components/mint-map/core/util/calculate.js');
|
|
13
13
|
var waiting = require('./components/mint-map/core/util/waiting.js');
|
|
14
|
+
var cluster = require('./components/mint-map/core/util/cluster.js');
|
|
14
15
|
var MapControlWrapper = require('./components/mint-map/core/wrapper/MapControlWrapper.js');
|
|
15
16
|
var MapMarkerWrapper = require('./components/mint-map/core/wrapper/MapMarkerWrapper.js');
|
|
16
17
|
var MapPolygonWrapper = require('./components/mint-map/core/wrapper/MapPolygonWrapper.js');
|
|
@@ -38,6 +39,7 @@ exports.AnimationPlayer = animation.AnimationPlayer;
|
|
|
38
39
|
exports.GeoCalulator = calculate.GeoCalulator;
|
|
39
40
|
exports.PolygonCalculator = calculate.PolygonCalculator;
|
|
40
41
|
exports.waiting = waiting.waiting;
|
|
42
|
+
exports.getClusterInfo = cluster.getClusterInfo;
|
|
41
43
|
exports.MapControlWrapper = MapControlWrapper.MapControlWrapper;
|
|
42
44
|
exports.MapMarkerWrapper = MapMarkerWrapper.MapMarkerWrapper;
|
|
43
45
|
exports.MapPolygonWrapper = MapPolygonWrapper.MapPolygonWrapper;
|
package/dist/index.umd.js
CHANGED
|
@@ -324,6 +324,7 @@
|
|
|
324
324
|
function MintMapController(props) {
|
|
325
325
|
this.mapApiLoaded = false;
|
|
326
326
|
this.mapInitialized = false;
|
|
327
|
+
this.processedTime = 0;
|
|
327
328
|
this.mapProps = props;
|
|
328
329
|
}
|
|
329
330
|
|
|
@@ -368,6 +369,18 @@
|
|
|
368
369
|
return "".concat(baseUrl, "?").concat(params);
|
|
369
370
|
};
|
|
370
371
|
|
|
372
|
+
MintMapController.prototype.checkBoundsChangeThrottleTime = function () {
|
|
373
|
+
if (!this.mapProps.boundsChangeThrottlingTime) return true;
|
|
374
|
+
var time = new Date().getTime();
|
|
375
|
+
|
|
376
|
+
if (this.processedTime > 0 && time - this.processedTime < this.mapProps.boundsChangeThrottlingTime) {
|
|
377
|
+
return false;
|
|
378
|
+
} else {
|
|
379
|
+
this.processedTime = time;
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
371
384
|
return MintMapController;
|
|
372
385
|
}();
|
|
373
386
|
|
|
@@ -540,8 +553,18 @@
|
|
|
540
553
|
|
|
541
554
|
NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
542
555
|
if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
|
|
556
|
+
var paths = void 0;
|
|
557
|
+
|
|
558
|
+
if (Array.isArray(options.position)) {
|
|
559
|
+
var outLine = options.position.map(function (elem) {
|
|
560
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
561
|
+
});
|
|
562
|
+
paths = [outLine];
|
|
563
|
+
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
564
|
+
}
|
|
565
|
+
|
|
543
566
|
polygon.native.setOptions({
|
|
544
|
-
paths: polygon.native.getPaths(),
|
|
567
|
+
paths: paths || polygon.native.getPaths(),
|
|
545
568
|
visible: options.visible === undefined || options.visible,
|
|
546
569
|
strokeColor: options.lineColor,
|
|
547
570
|
strokeWeight: options.lineSize,
|
|
@@ -805,17 +828,25 @@
|
|
|
805
828
|
_this.dragged = true;
|
|
806
829
|
}
|
|
807
830
|
});
|
|
808
|
-
map.addListener('idle', function () {
|
|
809
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
831
|
+
map.addListener('idle', function (e) {
|
|
832
|
+
_this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
810
833
|
});
|
|
811
834
|
map.addListener('zoom_changed', function () {
|
|
812
835
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
813
836
|
});
|
|
814
837
|
map.addListener('click', function (e) {
|
|
815
|
-
|
|
838
|
+
if (!_this.mapProps.onClick) return;
|
|
816
839
|
var pos = new Position(e.coord.y, e.coord.x);
|
|
817
840
|
pos.offset = new Offset(e.offset.x, e.offset.y);
|
|
818
|
-
|
|
841
|
+
|
|
842
|
+
_this.mapProps.onClick(pos);
|
|
843
|
+
});
|
|
844
|
+
map.addListener('mousemove', function (e) {
|
|
845
|
+
if (!_this.mapProps.onMouseMove) return;
|
|
846
|
+
var pos = new Position(e.coord.y, e.coord.x);
|
|
847
|
+
pos.offset = new Offset(e.offset.x, e.offset.y);
|
|
848
|
+
|
|
849
|
+
_this.mapProps.onMouseMove(pos);
|
|
819
850
|
});
|
|
820
851
|
this.map = map;
|
|
821
852
|
this.mapInitialized = true;
|
|
@@ -844,14 +875,14 @@
|
|
|
844
875
|
NaverMintMapController.prototype.destroyMap = function () {
|
|
845
876
|
var _a;
|
|
846
877
|
|
|
847
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
848
|
-
|
|
849
878
|
try {
|
|
850
879
|
this.map && this.map.destroy();
|
|
851
880
|
(_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
852
881
|
} catch (e) {
|
|
853
882
|
console.log('naver map destroy error', e);
|
|
854
883
|
}
|
|
884
|
+
|
|
885
|
+
console.log("".concat(this.type, " map destroyed"));
|
|
855
886
|
};
|
|
856
887
|
|
|
857
888
|
NaverMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -860,7 +891,7 @@
|
|
|
860
891
|
}
|
|
861
892
|
|
|
862
893
|
var bounds = this.map.getBounds();
|
|
863
|
-
return Bounds.fromNWSE(new Position(bounds.
|
|
894
|
+
return Bounds.fromNWSE(new Position(bounds.getMax().y, bounds.getMin().x), new Position(bounds.getMin().y, bounds.getMax().x));
|
|
864
895
|
};
|
|
865
896
|
|
|
866
897
|
NaverMintMapController.prototype.panningTo = function (targetCenter) {
|
|
@@ -902,7 +933,13 @@
|
|
|
902
933
|
_this.dragged = false;
|
|
903
934
|
|
|
904
935
|
_this.destroyMap = function () {
|
|
905
|
-
|
|
936
|
+
try {
|
|
937
|
+
_this.map && google.maps.event.clearInstanceListeners(_this.map);
|
|
938
|
+
} catch (e) {
|
|
939
|
+
console.log('google map destroy error', e);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
console.log("".concat(_this.type, " map destroyed"));
|
|
906
943
|
};
|
|
907
944
|
|
|
908
945
|
console.log("".concat(_this.type, " controller loadded"));
|
|
@@ -1016,6 +1053,16 @@
|
|
|
1016
1053
|
GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
1017
1054
|
if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
|
|
1018
1055
|
var polygonOption = this.getValidOptions(options);
|
|
1056
|
+
|
|
1057
|
+
if (this.map && Array.isArray(options.position)) {
|
|
1058
|
+
var outLine = options.position.map(function (elem) {
|
|
1059
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
1060
|
+
});
|
|
1061
|
+
var paths = [outLine];
|
|
1062
|
+
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
1063
|
+
polygonOption.paths = paths;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1019
1066
|
polygon.native.setOptions(polygonOption);
|
|
1020
1067
|
}
|
|
1021
1068
|
};
|
|
@@ -1247,18 +1294,28 @@
|
|
|
1247
1294
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
1248
1295
|
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
1249
1296
|
disableDefaultUI: true,
|
|
1250
|
-
gestureHandling: 'greedy'
|
|
1297
|
+
gestureHandling: 'greedy',
|
|
1298
|
+
clickableIcons: false
|
|
1251
1299
|
});
|
|
1252
1300
|
map.addListener('idle', function () {
|
|
1253
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1301
|
+
_this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1254
1302
|
});
|
|
1255
1303
|
map.addListener('zoom_changed', function () {
|
|
1256
1304
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
1257
1305
|
});
|
|
1258
1306
|
map.addListener('click', function (e) {
|
|
1307
|
+
if (!_this.mapProps.onClick) return;
|
|
1259
1308
|
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1260
1309
|
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1261
|
-
|
|
1310
|
+
|
|
1311
|
+
_this.mapProps.onClick(pos);
|
|
1312
|
+
});
|
|
1313
|
+
map.addListener('mousemove', function (e) {
|
|
1314
|
+
if (!_this.mapProps.onMouseMove) return;
|
|
1315
|
+
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1316
|
+
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1317
|
+
|
|
1318
|
+
_this.mapProps.onMouseMove(pos);
|
|
1262
1319
|
});
|
|
1263
1320
|
this.map = map;
|
|
1264
1321
|
this.mapInitialized = true;
|
|
@@ -1360,7 +1417,11 @@
|
|
|
1360
1417
|
};
|
|
1361
1418
|
|
|
1362
1419
|
Bounds.prototype.getCenter = function () {
|
|
1363
|
-
return new Position(this.
|
|
1420
|
+
return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
Bounds.prototype.includesPosition = function (pos) {
|
|
1424
|
+
return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat;
|
|
1364
1425
|
};
|
|
1365
1426
|
|
|
1366
1427
|
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
@@ -1369,7 +1430,7 @@
|
|
|
1369
1430
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
1370
1431
|
var pos = positions_1[_i];
|
|
1371
1432
|
|
|
1372
|
-
if (
|
|
1433
|
+
if (this.includesPosition(pos)) {
|
|
1373
1434
|
result.push(pos);
|
|
1374
1435
|
}
|
|
1375
1436
|
}
|
|
@@ -1383,7 +1444,7 @@
|
|
|
1383
1444
|
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
1384
1445
|
var pos = positions_2[_i];
|
|
1385
1446
|
|
|
1386
|
-
if (this.
|
|
1447
|
+
if (!this.includesPosition(pos)) {
|
|
1387
1448
|
return false;
|
|
1388
1449
|
}
|
|
1389
1450
|
}
|
|
@@ -1395,7 +1456,7 @@
|
|
|
1395
1456
|
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
1396
1457
|
var pos = positions_3[_i];
|
|
1397
1458
|
|
|
1398
|
-
if (
|
|
1459
|
+
if (this.includesPosition(pos)) {
|
|
1399
1460
|
return true;
|
|
1400
1461
|
}
|
|
1401
1462
|
}
|
|
@@ -1935,7 +1996,7 @@
|
|
|
1935
1996
|
React.useEffect(function () {
|
|
1936
1997
|
return function () {
|
|
1937
1998
|
if (polygonRef.current) {
|
|
1938
|
-
|
|
1999
|
+
controller.clearDrawable(polygonRef.current);
|
|
1939
2000
|
}
|
|
1940
2001
|
};
|
|
1941
2002
|
}, []);
|
|
@@ -2111,6 +2172,138 @@
|
|
|
2111
2172
|
}, "".concat(title, " (").concat(numberOfFloor, "\uCE35)")))));
|
|
2112
2173
|
}
|
|
2113
2174
|
|
|
2175
|
+
var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, itemList, sizeFunction) {
|
|
2176
|
+
var _a;
|
|
2177
|
+
|
|
2178
|
+
var rowCount = Number((mapWidth / basePixelSize).toFixed(0)) || 1;
|
|
2179
|
+
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1;
|
|
2180
|
+
var boundsLineSizeX = Number(((mapBounds.ne.lng - mapBounds.nw.lng) / rowCount).toFixed(7));
|
|
2181
|
+
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7));
|
|
2182
|
+
var boundsList = [];
|
|
2183
|
+
var boundsPos = [];
|
|
2184
|
+
var tempX1, tempY1, tempX2, tempY2;
|
|
2185
|
+
|
|
2186
|
+
for (var i = 0; i < rowCount; i++) {
|
|
2187
|
+
tempX1 = mapBounds.nw.lng + boundsLineSizeX * i;
|
|
2188
|
+
tempX2 = mapBounds.nw.lng + boundsLineSizeX * (i + 1);
|
|
2189
|
+
var rows = [];
|
|
2190
|
+
boundsPos.push(rows);
|
|
2191
|
+
|
|
2192
|
+
for (var k = 0; k < colCount; k++) {
|
|
2193
|
+
tempY2 = mapBounds.se.lat + boundsLineSizeY * k;
|
|
2194
|
+
tempY1 = mapBounds.se.lat + boundsLineSizeY * (k + 1);
|
|
2195
|
+
var thisBounds = Bounds.fromNWSE(new Position(tempY1, tempX1), new Position(tempY2, tempX2));
|
|
2196
|
+
var includedList = thisBounds.getIncludedPositions(itemList);
|
|
2197
|
+
rows.push({
|
|
2198
|
+
bounds: thisBounds,
|
|
2199
|
+
checked: false,
|
|
2200
|
+
center: false,
|
|
2201
|
+
centerPosition: thisBounds.getCenter(),
|
|
2202
|
+
incList: [],
|
|
2203
|
+
itemList: includedList,
|
|
2204
|
+
size: basePixelSize
|
|
2205
|
+
});
|
|
2206
|
+
boundsList.push(thisBounds);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
var centerList = [];
|
|
2211
|
+
var totalItemCount = 0;
|
|
2212
|
+
var min;
|
|
2213
|
+
var max;
|
|
2214
|
+
|
|
2215
|
+
for (var i = 0; i < boundsPos.length; i++) {
|
|
2216
|
+
for (var k = 0; k < boundsPos[i].length; k++) {
|
|
2217
|
+
var curr = boundsPos[i][k];
|
|
2218
|
+
if (curr.checked) continue;
|
|
2219
|
+
curr.checked = true;
|
|
2220
|
+
var incList = [];
|
|
2221
|
+
|
|
2222
|
+
if (boundsPos[i]) {
|
|
2223
|
+
boundsPos[i][k - 1] && incList.push(boundsPos[i][k - 1]);
|
|
2224
|
+
boundsPos[i][k + 1] && incList.push(boundsPos[i][k + 1]);
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
if (boundsPos[i - 1]) {
|
|
2228
|
+
boundsPos[i - 1][k - 1] && incList.push(boundsPos[i - 1][k - 1]);
|
|
2229
|
+
boundsPos[i - 1][k] && incList.push(boundsPos[i - 1][k]);
|
|
2230
|
+
boundsPos[i - 1][k + 1] && incList.push(boundsPos[i - 1][k + 1]);
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
if (boundsPos[i + 1]) {
|
|
2234
|
+
boundsPos[i + 1][k + 1] && incList.push(boundsPos[i + 1][k + 1]);
|
|
2235
|
+
boundsPos[i + 1][k] && incList.push(boundsPos[i + 1][k]);
|
|
2236
|
+
boundsPos[i + 1][k - 1] && incList.push(boundsPos[i + 1][k - 1]);
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
for (var _i = 0, incList_1 = incList; _i < incList_1.length; _i++) {
|
|
2240
|
+
var inc = incList_1[_i];
|
|
2241
|
+
if (inc.checked) continue;
|
|
2242
|
+
inc.checked = true;
|
|
2243
|
+
|
|
2244
|
+
if (inc.itemList && inc.itemList.length > 0) {
|
|
2245
|
+
curr.incList.push(inc);
|
|
2246
|
+
|
|
2247
|
+
(_a = curr.itemList).push.apply(_a, inc.itemList);
|
|
2248
|
+
|
|
2249
|
+
curr.center = true;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
if (curr.center) {
|
|
2254
|
+
centerList.push(curr);
|
|
2255
|
+
var avrLat = calculateAverage(curr.itemList.map(function (item) {
|
|
2256
|
+
return item.lat;
|
|
2257
|
+
}));
|
|
2258
|
+
var avrLng = calculateAverage(curr.itemList.map(function (item) {
|
|
2259
|
+
return item.lng;
|
|
2260
|
+
}));
|
|
2261
|
+
curr.centerPosition = new Position(avrLat, avrLng);
|
|
2262
|
+
totalItemCount += curr.itemList.length;
|
|
2263
|
+
|
|
2264
|
+
if (!min || curr.itemList.length < min) {
|
|
2265
|
+
min = curr.itemList.length;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
if (!max || curr.itemList.length > max) {
|
|
2269
|
+
max = curr.itemList.length;
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
var status = {
|
|
2276
|
+
total: totalItemCount,
|
|
2277
|
+
average: totalItemCount / centerList.length,
|
|
2278
|
+
min: min,
|
|
2279
|
+
max: max
|
|
2280
|
+
};
|
|
2281
|
+
|
|
2282
|
+
sizeFunction = sizeFunction || function (info, status) {
|
|
2283
|
+
var minSize = basePixelSize / 4;
|
|
2284
|
+
var maxSize = basePixelSize;
|
|
2285
|
+
return Math.min(Math.max(basePixelSize * info.itemList.length / status.average, minSize), maxSize);
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2288
|
+
for (var _b = 0, centerList_1 = centerList; _b < centerList_1.length; _b++) {
|
|
2289
|
+
var center = centerList_1[_b];
|
|
2290
|
+
center.size = sizeFunction(center, status);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
return [centerList, boundsList];
|
|
2294
|
+
};
|
|
2295
|
+
|
|
2296
|
+
var calculateAverage = function (nums) {
|
|
2297
|
+
var sum = 0;
|
|
2298
|
+
|
|
2299
|
+
for (var _i = 0, nums_1 = nums; _i < nums_1.length; _i++) {
|
|
2300
|
+
var num = nums_1[_i];
|
|
2301
|
+
sum += num;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
return Number((sum / nums.length).toFixed(7));
|
|
2305
|
+
};
|
|
2306
|
+
|
|
2114
2307
|
var css_248z = ".MintMapWrapper-module_mint-map-control-wrapper__DDb4y {\n position: absolute;\n z-index: 101;\n}\n\n.MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV {\n position: absolute;\n z-index: 1;\n}";
|
|
2115
2308
|
var styles = {"mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
|
|
2116
2309
|
styleInject__default["default"](css_248z);
|
|
@@ -2188,7 +2381,7 @@
|
|
|
2188
2381
|
React.useEffect(function () {
|
|
2189
2382
|
return function () {
|
|
2190
2383
|
if (polylineRef.current) {
|
|
2191
|
-
|
|
2384
|
+
controller.clearDrawable(polylineRef.current);
|
|
2192
2385
|
}
|
|
2193
2386
|
};
|
|
2194
2387
|
}, []);
|
|
@@ -2228,6 +2421,7 @@
|
|
|
2228
2421
|
exports.PolygonCalculator = PolygonCalculator;
|
|
2229
2422
|
exports.Polyline = Polyline;
|
|
2230
2423
|
exports.Position = Position;
|
|
2424
|
+
exports.getClusterInfo = getClusterInfo;
|
|
2231
2425
|
exports.useMarkerMoving = useMarkerMoving;
|
|
2232
2426
|
exports.useMintMapController = useMintMapController;
|
|
2233
2427
|
exports.waiting = waiting;
|