@mint-ui/map 0.4.6-beta → 0.5.0-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/core/MintMapController.d.ts +6 -0
- package/dist/components/mint-map/core/advanced/index.d.ts +1 -0
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.d.ts +20 -0
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.js +137 -0
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.d.ts +23 -0
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.js +188 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.d.ts +8 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.js +54 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.d.ts +12 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.js +152 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.d.ts +10 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.js +60 -0
- package/dist/components/mint-map/core/advanced/shapes/base/index.d.ts +3 -0
- package/dist/components/mint-map/core/advanced/shapes/index.d.ts +3 -0
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.js +4 -1
- package/dist/components/mint-map/core/util/calculate.d.ts +28 -1
- package/dist/components/mint-map/core/util/calculate.js +174 -7
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +2 -1
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +25 -6
- package/dist/components/mint-map/google/GoogleMintMapController.d.ts +9 -0
- package/dist/components/mint-map/google/GoogleMintMapController.js +134 -0
- package/dist/components/mint-map/kakao/KakaoMintMapController.d.ts +8 -0
- package/dist/components/mint-map/kakao/KakaoMintMapController.js +118 -1
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +8 -0
- package/dist/components/mint-map/naver/NaverMintMapController.js +101 -1
- package/dist/components/mint-map/types/MapEventTypes.d.ts +41 -0
- package/dist/components/mint-map/types/MapEventTypes.js +57 -0
- package/dist/components/mint-map/types/MapTypes.d.ts +1 -0
- package/dist/components/mint-map/types/MapTypes.js +4 -0
- package/dist/components/mint-map/types/index.d.ts +1 -0
- package/dist/index.es.js +1438 -334
- package/dist/index.js +13 -0
- package/dist/index.umd.js +1444 -333
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -39,7 +39,7 @@ var PolygonCalculator =
|
|
|
39
39
|
function () {
|
|
40
40
|
function PolygonCalculator() {}
|
|
41
41
|
|
|
42
|
-
PolygonCalculator.
|
|
42
|
+
PolygonCalculator.getRegionInfo = function (positions) {
|
|
43
43
|
var maxX, minX, maxY, minY;
|
|
44
44
|
|
|
45
45
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
@@ -60,11 +60,43 @@ function () {
|
|
|
60
60
|
if (minY === undefined || pos.lng < minY) {
|
|
61
61
|
minY = pos.lng;
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
maxLat: maxX,
|
|
67
|
+
minLat: minX,
|
|
68
|
+
maxLng: maxY,
|
|
69
|
+
minLng: minY,
|
|
70
|
+
centerLat: minX && maxX ? minX + (maxX - minX) / 2 : undefined,
|
|
71
|
+
centerLng: minY && maxY ? minY + (maxY - minY) / 2 : undefined
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
PolygonCalculator.getRegionStart = function (positions) {
|
|
76
|
+
var info = this.getRegionInfo(positions);
|
|
77
|
+
|
|
78
|
+
if (info.minLat && info.minLng) {
|
|
79
|
+
return new PositionMirror(info.minLat, info.minLng);
|
|
80
|
+
}
|
|
64
81
|
|
|
82
|
+
throw new Error('Calculate RegionStart Error!!!');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
PolygonCalculator.getRegionEnd = function (positions) {
|
|
86
|
+
var info = this.getRegionInfo(positions);
|
|
87
|
+
|
|
88
|
+
if (info.maxLat && info.maxLng) {
|
|
89
|
+
return new PositionMirror(info.maxLat, info.maxLng);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
throw new Error('Calculate RegionEnd Error!!!');
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
PolygonCalculator.getCenter = function (positions) {
|
|
96
|
+
var info = this.getRegionInfo(positions);
|
|
65
97
|
|
|
66
|
-
if (
|
|
67
|
-
return new PositionMirror(
|
|
98
|
+
if (info.centerLat && info.centerLng) {
|
|
99
|
+
return new PositionMirror(info.centerLat, info.centerLng);
|
|
68
100
|
}
|
|
69
101
|
|
|
70
102
|
throw new Error('Calculate Center Error!!!');
|
|
@@ -175,6 +207,90 @@ function () {
|
|
|
175
207
|
return false;
|
|
176
208
|
};
|
|
177
209
|
|
|
210
|
+
PolygonCalculator.simplifyPoints = function (polygon, tolerance, lastRepeated) {
|
|
211
|
+
var target = lastRepeated ? polygon.slice(0, polygon.length - 1) : polygon;
|
|
212
|
+
return this.simplify(target.map(function (position) {
|
|
213
|
+
return [position.lng, position.lat];
|
|
214
|
+
}), tolerance !== undefined ? tolerance : this.TOLERANCE_NAVER_STYLE).map(function (point) {
|
|
215
|
+
return new PositionMirror(point[1], point[0]);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
PolygonCalculator.simplify = function (points, tolerance) {
|
|
220
|
+
if (points.length <= 2) {
|
|
221
|
+
return points;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var dMax = 0;
|
|
225
|
+
var index = 0; // Find the point with the maximum distance from the line segment
|
|
226
|
+
|
|
227
|
+
for (var i = 1; i < points.length - 1; i++) {
|
|
228
|
+
var d = this.perpendicularDistance(points[i], points[0], points[points.length - 1]);
|
|
229
|
+
|
|
230
|
+
if (d > dMax) {
|
|
231
|
+
dMax = d;
|
|
232
|
+
index = i;
|
|
233
|
+
}
|
|
234
|
+
} // If the maximum distance is greater than the tolerance, recursively simplify
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
if (dMax > tolerance) {
|
|
238
|
+
var left = this.simplify(points.slice(0, index + 1), tolerance);
|
|
239
|
+
var right = this.simplify(points.slice(index), tolerance); // Concatenate the simplified left and right segments
|
|
240
|
+
|
|
241
|
+
return left.slice(0, left.length - 1).concat(right);
|
|
242
|
+
} else {
|
|
243
|
+
// If the maximum distance is less than or equal to the tolerance, return the endpoints
|
|
244
|
+
return [points[0], points[points.length - 1]];
|
|
245
|
+
}
|
|
246
|
+
}; // Calculate the perpendicular distance from a point to a line segment
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
PolygonCalculator.perpendicularDistance = function (point, lineStart, lineEnd) {
|
|
250
|
+
var x = point[0];
|
|
251
|
+
var y = point[1];
|
|
252
|
+
var x1 = lineStart[0];
|
|
253
|
+
var y1 = lineStart[1];
|
|
254
|
+
var x2 = lineEnd[0];
|
|
255
|
+
var y2 = lineEnd[1];
|
|
256
|
+
var numerator = Math.abs((y2 - y1) * x - (x2 - x1) * y + x2 * y1 - y2 * x1);
|
|
257
|
+
var denominator = Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2));
|
|
258
|
+
return numerator / denominator;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
PolygonCalculator.calculatePolygonSize = function (polygon, innerPolygons) {
|
|
262
|
+
var _this = this;
|
|
263
|
+
|
|
264
|
+
var outer = this.calculatePolygonSizeMain(polygon);
|
|
265
|
+
var inner = 0;
|
|
266
|
+
innerPolygons && innerPolygons.map(function (innerPolygon) {
|
|
267
|
+
inner += _this.calculatePolygonSizeMain(innerPolygon);
|
|
268
|
+
});
|
|
269
|
+
return outer - inner;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
PolygonCalculator.calculatePolygonSizeMain = function (polygon) {
|
|
273
|
+
var vertices = polygon.map(function (pos) {
|
|
274
|
+
return {
|
|
275
|
+
x: GeoCalulator.convertLongitudeToMeterValue(pos.lat, pos.lng),
|
|
276
|
+
y: GeoCalulator.convertLatitudeToMeterValue(pos.lat)
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
var n = vertices.length;
|
|
280
|
+
var sum = 0;
|
|
281
|
+
|
|
282
|
+
for (var i = 0; i < n; i++) {
|
|
283
|
+
var currentVertex = vertices[i];
|
|
284
|
+
var nextVertex = vertices[(i + 1) % n];
|
|
285
|
+
sum += currentVertex.x * nextVertex.y - currentVertex.y * nextVertex.x;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
var area = Math.abs(sum) / 2;
|
|
289
|
+
return area;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
PolygonCalculator.TOLERANCE_NAVER_STYLE = 0.0001;
|
|
293
|
+
PolygonCalculator.TOLERANCE_GOOGLE_STYLE = 0.00001;
|
|
178
294
|
return PolygonCalculator;
|
|
179
295
|
}();
|
|
180
296
|
|
|
@@ -188,7 +304,7 @@ function () {
|
|
|
188
304
|
var dLon = this.deg2rad(pos2.lng - pos1.lng);
|
|
189
305
|
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.deg2rad(pos1.lat)) * Math.cos(this.deg2rad(pos2.lat)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
190
306
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
191
|
-
var d = this.
|
|
307
|
+
var d = this.EARTH_EQUATORIAL_RADIUS_KM * c; // Distance in km
|
|
192
308
|
|
|
193
309
|
return d;
|
|
194
310
|
};
|
|
@@ -201,6 +317,53 @@ function () {
|
|
|
201
317
|
return meter * this.LATITUDE_POSITION_VALUE_PER_METER;
|
|
202
318
|
};
|
|
203
319
|
|
|
320
|
+
GeoCalulator.convertLatitudeToMeterValue = function (lat) {
|
|
321
|
+
return lat * this.METER_VALUE_PER_LATITUDE;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
GeoCalulator.convertLongitudeToMeterValue = function (lat, lng) {
|
|
325
|
+
return lng * this.calculateLongitudeValueWithLatitudeInMeter(lat);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
GeoCalulator.getCacheUnitOfLongitudeValueWithLatitudeInMeter = function (lat) {
|
|
329
|
+
return lat.toFixed(2);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
GeoCalulator.getCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit) {
|
|
333
|
+
return this.CACHE_OF_LNG_PER_METER.get(latUnit);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
GeoCalulator.setCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit, lngValue) {
|
|
337
|
+
if (this.CACHE_OF_LNG_PER_METER.size > 10) {
|
|
338
|
+
this.CACHE_OF_LNG_PER_METER.clear();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
this.CACHE_OF_LNG_PER_METER.set(latUnit, lngValue);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
GeoCalulator.calculateLongitudeValueWithLatitudeInMeter = function (lat) {
|
|
345
|
+
// const t = Date.now()
|
|
346
|
+
// Cache check
|
|
347
|
+
var latUnit = this.getCacheUnitOfLongitudeValueWithLatitudeInMeter(lat);
|
|
348
|
+
var fromCache = this.getCacheOfLongitudeValueWithLatitudeInMeter(latUnit);
|
|
349
|
+
|
|
350
|
+
if (fromCache !== undefined) {
|
|
351
|
+
// console.log(`cache hit!! ${Date.now() - t} ms`, fromCache, latUnit, this.CACHE_OF_LNG_PER_METER.size);
|
|
352
|
+
return fromCache;
|
|
353
|
+
} // Convert latitude and longitude to radians
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
var latRad = lat * Math.PI / 180; // Calculate Earth's radius at the given latitude
|
|
357
|
+
|
|
358
|
+
var radius = this.EARTH_EQUATORIAL_RADIUS * Math.sqrt(1 - Math.pow(this.EARTH_ECCENTRICITY * Math.sin(latRad), 2)); // Calculate the length of one degree of longitude in meters
|
|
359
|
+
|
|
360
|
+
var distance = 2 * Math.PI * radius * Math.cos(latRad) / 360; // Cache set
|
|
361
|
+
|
|
362
|
+
this.setCacheOfLongitudeValueWithLatitudeInMeter(latUnit, distance); // console.log(`calculated ${Date.now() - t} ms`)
|
|
363
|
+
|
|
364
|
+
return distance;
|
|
365
|
+
};
|
|
366
|
+
|
|
204
367
|
GeoCalulator.computeNextPositionAndDistances = function (context) {
|
|
205
368
|
var pos1 = context.pos1,
|
|
206
369
|
pos2 = context.pos2,
|
|
@@ -262,10 +425,14 @@ function () {
|
|
|
262
425
|
return context;
|
|
263
426
|
};
|
|
264
427
|
|
|
265
|
-
GeoCalulator.
|
|
428
|
+
GeoCalulator.EARTH_EQUATORIAL_RADIUS = 6378137; //meter (6,378,137 m)
|
|
266
429
|
|
|
267
|
-
GeoCalulator.
|
|
430
|
+
GeoCalulator.EARTH_EQUATORIAL_RADIUS_KM = GeoCalulator.EARTH_EQUATORIAL_RADIUS / 1000;
|
|
431
|
+
GeoCalulator.EARTH_ECCENTRICITY = 0.08181919;
|
|
432
|
+
GeoCalulator.METER_VALUE_PER_LATITUDE = 110.32 * 1000; //위도 기준 1도는 110.32km
|
|
268
433
|
|
|
434
|
+
GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / GeoCalulator.METER_VALUE_PER_LATITUDE;
|
|
435
|
+
GeoCalulator.CACHE_OF_LNG_PER_METER = new Map();
|
|
269
436
|
GeoCalulator.MS_FROM_HOUR = 60 * 60 * 1000;
|
|
270
437
|
return GeoCalulator;
|
|
271
438
|
}();
|
|
@@ -409,6 +576,10 @@ function () {
|
|
|
409
576
|
this.y = y;
|
|
410
577
|
}
|
|
411
578
|
|
|
579
|
+
Offset.prototype.equals = function (other) {
|
|
580
|
+
return other && this.x === other.x && this.y === other.y;
|
|
581
|
+
};
|
|
582
|
+
|
|
412
583
|
return Offset;
|
|
413
584
|
}();
|
|
414
585
|
|
|
@@ -912,6 +1083,57 @@ function waiting(evaluation, timeoutSeconds) {
|
|
|
912
1083
|
});
|
|
913
1084
|
}
|
|
914
1085
|
|
|
1086
|
+
// export type MapEvent = 'bounds_changed'|'center_changed'|'idle'|'zoom_changed'|'zoomstart'
|
|
1087
|
+
// export type MapUIEvent = 'click'|'dblclick'|''
|
|
1088
|
+
var MapEvent =
|
|
1089
|
+
/** @class */
|
|
1090
|
+
function () {
|
|
1091
|
+
function MapEvent() {
|
|
1092
|
+
this.BOUNDS_CHANGED = 'bounds_changed';
|
|
1093
|
+
this.CENTER_CHANGED = 'center_changed';
|
|
1094
|
+
this.IDLE = 'idle';
|
|
1095
|
+
this.ZOOM_CHANGED = 'zoom_changed';
|
|
1096
|
+
this.ZOOMSTART = 'zoomstart';
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
MapEvent.prototype.get = function (eventName) {
|
|
1100
|
+
var value = this[eventName];
|
|
1101
|
+
|
|
1102
|
+
if (typeof value === 'string') {
|
|
1103
|
+
return value;
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
return MapEvent;
|
|
1108
|
+
}();
|
|
1109
|
+
|
|
1110
|
+
var MapUIEvent =
|
|
1111
|
+
/** @class */
|
|
1112
|
+
function () {
|
|
1113
|
+
function MapUIEvent() {
|
|
1114
|
+
this.CLICK = 'click';
|
|
1115
|
+
this.DBLCLICK = 'dblclick';
|
|
1116
|
+
this.MOUSEDOWN = 'mousedown';
|
|
1117
|
+
this.MOUSEUP = 'mouseup';
|
|
1118
|
+
this.MOUSEOUT = 'mouseout';
|
|
1119
|
+
this.MOUSEMOVE = 'mousemove';
|
|
1120
|
+
this.MOUSEOVER = 'mouseover';
|
|
1121
|
+
this.DRAG = 'drag';
|
|
1122
|
+
this.DRAGSTART = 'dragstart';
|
|
1123
|
+
this.DRAGEND = 'dragend';
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
MapUIEvent.prototype.get = function (eventName) {
|
|
1127
|
+
var value = this[eventName];
|
|
1128
|
+
|
|
1129
|
+
if (typeof value === 'string') {
|
|
1130
|
+
return value;
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
return MapUIEvent;
|
|
1135
|
+
}();
|
|
1136
|
+
|
|
915
1137
|
var NaverMintMapController =
|
|
916
1138
|
/** @class */
|
|
917
1139
|
function (_super) {
|
|
@@ -923,12 +1145,18 @@ function (_super) {
|
|
|
923
1145
|
_this.type = 'naver';
|
|
924
1146
|
_this.map = null;
|
|
925
1147
|
_this.scriptUrl = 'https://openapi.map.naver.com/openapi/v3/maps.js';
|
|
926
|
-
_this.scriptModules = ['drawing'];
|
|
1148
|
+
_this.scriptModules = ['drawing']; // , 'geocoder' , 'panorama' , 'visualization']
|
|
1149
|
+
|
|
1150
|
+
_this.mapEvent = new MapEvent();
|
|
1151
|
+
_this.mapUIEvent = new MapUIEvent();
|
|
927
1152
|
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
928
1153
|
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
929
1154
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
930
1155
|
_this.dragStartPoint = [0, 0];
|
|
931
1156
|
_this.dragged = false;
|
|
1157
|
+
_this.eventMap = new Map();
|
|
1158
|
+
Object.freeze(_this.mapEvent);
|
|
1159
|
+
Object.freeze(_this.mapUIEvent);
|
|
932
1160
|
return _this; // console.log(`${this.type} controller loadded`);
|
|
933
1161
|
}
|
|
934
1162
|
|
|
@@ -1478,6 +1706,7 @@ function (_super) {
|
|
|
1478
1706
|
var _a;
|
|
1479
1707
|
|
|
1480
1708
|
try {
|
|
1709
|
+
this.removeAllEventListener();
|
|
1481
1710
|
this.map && this.map.destroy();
|
|
1482
1711
|
(_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1483
1712
|
} catch (e) {
|
|
@@ -1525,6 +1754,98 @@ function (_super) {
|
|
|
1525
1754
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
1526
1755
|
};
|
|
1527
1756
|
|
|
1757
|
+
NaverMintMapController.prototype.addEventListener = function (eventName, callback) {
|
|
1758
|
+
var _this = this;
|
|
1759
|
+
|
|
1760
|
+
var naverEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
|
|
1761
|
+
|
|
1762
|
+
if (!naverEventName) {
|
|
1763
|
+
console.warn("MapEventName ".concat(eventName, " is not supported"));
|
|
1764
|
+
return;
|
|
1765
|
+
} // console.log(`${eventName} add`);
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
var map = this.eventMap.get(eventName);
|
|
1769
|
+
|
|
1770
|
+
if (!map) {
|
|
1771
|
+
map = new Map();
|
|
1772
|
+
this.eventMap.set(eventName, map);
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
var wrappingCallback = function (e) {
|
|
1776
|
+
if (eventName in _this.mapEvent) {
|
|
1777
|
+
var bounds = _this.getCurrBounds();
|
|
1778
|
+
|
|
1779
|
+
var param = {
|
|
1780
|
+
name: eventName,
|
|
1781
|
+
mapType: 'naver',
|
|
1782
|
+
vendorEventName: naverEventName,
|
|
1783
|
+
param: {
|
|
1784
|
+
bounds: bounds,
|
|
1785
|
+
center: bounds.getCenter(),
|
|
1786
|
+
zoomLevel: _this.getZoomLevel()
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
callback(param);
|
|
1790
|
+
} else if (eventName in _this.mapUIEvent) {
|
|
1791
|
+
var position = new Position(e.coord.y, e.coord.x);
|
|
1792
|
+
position.offset = new Offset(e.offset.x, e.offset.y);
|
|
1793
|
+
var param = {
|
|
1794
|
+
name: eventName,
|
|
1795
|
+
mapType: 'naver',
|
|
1796
|
+
vendorEventName: naverEventName,
|
|
1797
|
+
param: {
|
|
1798
|
+
position: position,
|
|
1799
|
+
offset: position.offset
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
callback(param);
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
|
|
1806
|
+
var naverEventListener = naver.maps.Event.addListener(this.map, naverEventName, wrappingCallback);
|
|
1807
|
+
map.set(callback, naverEventListener);
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1810
|
+
NaverMintMapController.prototype.removeEventListener = function (eventName, callback) {
|
|
1811
|
+
var map = this.eventMap.get(eventName);
|
|
1812
|
+
|
|
1813
|
+
if (map) {
|
|
1814
|
+
var naverEventListener = map.get(callback);
|
|
1815
|
+
|
|
1816
|
+
if (naverEventListener) {
|
|
1817
|
+
// console.log(`${naverEventListener.eventName} remove`);
|
|
1818
|
+
naver.maps.Event.removeListener(naverEventListener);
|
|
1819
|
+
map.delete(callback);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
|
|
1824
|
+
NaverMintMapController.prototype.removeAllEventListener = function (eventName) {
|
|
1825
|
+
var _this = this;
|
|
1826
|
+
|
|
1827
|
+
if (eventName) {
|
|
1828
|
+
this.clearEventListener(eventName);
|
|
1829
|
+
} else {
|
|
1830
|
+
this.eventMap.forEach(function (_map, eventName) {
|
|
1831
|
+
_this.clearEventListener(eventName);
|
|
1832
|
+
});
|
|
1833
|
+
this.eventMap.clear();
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
|
|
1837
|
+
NaverMintMapController.prototype.clearEventListener = function (eventName) {
|
|
1838
|
+
var map = this.eventMap.get(eventName);
|
|
1839
|
+
|
|
1840
|
+
if (map) {
|
|
1841
|
+
map.forEach(function (naverEventListener) {
|
|
1842
|
+
// console.log(`${naverEventListener.eventName} remove`);
|
|
1843
|
+
naver.maps.Event.removeListener(naverEventListener);
|
|
1844
|
+
});
|
|
1845
|
+
this.eventMap.delete(eventName);
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1528
1849
|
return NaverMintMapController;
|
|
1529
1850
|
}(MintMapController);
|
|
1530
1851
|
|
|
@@ -1541,13 +1862,18 @@ function (_super) {
|
|
|
1541
1862
|
_this.scriptUrl = 'https://maps.googleapis.com/maps/api/js';
|
|
1542
1863
|
_this.scriptModules = ['marker']; //'drawing' , 'geometry' , 'journeySharing' , 'localContext' , 'places' , 'visualization']
|
|
1543
1864
|
|
|
1865
|
+
_this.mapEvent = new MapEvent();
|
|
1866
|
+
_this.mapUIEvent = new MapUIEvent();
|
|
1544
1867
|
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
1545
1868
|
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
1546
1869
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
1547
1870
|
_this.dragged = false;
|
|
1871
|
+
_this.lastMousePosition = null;
|
|
1548
1872
|
|
|
1549
1873
|
_this.destroyMap = function () {
|
|
1550
1874
|
try {
|
|
1875
|
+
_this.removeAllEventListener();
|
|
1876
|
+
|
|
1551
1877
|
_this.map && google.maps.event.clearInstanceListeners(_this.map);
|
|
1552
1878
|
} catch (e) {
|
|
1553
1879
|
console.log('google map destroy error', e);
|
|
@@ -1555,6 +1881,12 @@ function (_super) {
|
|
|
1555
1881
|
|
|
1556
1882
|
};
|
|
1557
1883
|
|
|
1884
|
+
_this.eventMap = new Map(); //google 은 zoomstart 가 없으므로 zoom_changed 로 대체 (하지만 zooming 되는 내내 여러번 호출됨)
|
|
1885
|
+
//나중에 naver 와 마찬가지로 zoomstart 1번 zoom_changed 1번 호출되도록 바꾸는것 고려중
|
|
1886
|
+
|
|
1887
|
+
_this.mapEvent.ZOOMSTART = 'zoom_changed';
|
|
1888
|
+
Object.freeze(_this.mapEvent);
|
|
1889
|
+
Object.freeze(_this.mapUIEvent);
|
|
1558
1890
|
return _this; // console.log(`${this.type} controller loadded`);
|
|
1559
1891
|
}
|
|
1560
1892
|
|
|
@@ -1994,6 +2326,20 @@ function (_super) {
|
|
|
1994
2326
|
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1995
2327
|
|
|
1996
2328
|
_this.mapProps.onClick(pos);
|
|
2329
|
+
}); //@ts-ignore
|
|
2330
|
+
|
|
2331
|
+
map.addListener('mousedown', function (e) {
|
|
2332
|
+
// console.log('map click', e)
|
|
2333
|
+
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
2334
|
+
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
2335
|
+
_this.lastMousePosition = pos;
|
|
2336
|
+
}); //@ts-ignore
|
|
2337
|
+
|
|
2338
|
+
map.addListener('mouseup', function (e) {
|
|
2339
|
+
// console.log('map click', e)
|
|
2340
|
+
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
2341
|
+
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
2342
|
+
_this.lastMousePosition = pos;
|
|
1997
2343
|
});
|
|
1998
2344
|
map.addListener('mousemove', function (e) {
|
|
1999
2345
|
if (!_this.mapProps.onMouseMove) return;
|
|
@@ -2062,6 +2408,114 @@ function (_super) {
|
|
|
2062
2408
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
2063
2409
|
};
|
|
2064
2410
|
|
|
2411
|
+
GoogleMintMapController.prototype.addEventListener = function (eventName, callback) {
|
|
2412
|
+
var _this = this;
|
|
2413
|
+
|
|
2414
|
+
if (!this.map) {
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
var googleEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
|
|
2419
|
+
|
|
2420
|
+
if (!googleEventName) {
|
|
2421
|
+
console.warn("MapEventName ".concat(eventName, " is not supported"));
|
|
2422
|
+
return;
|
|
2423
|
+
} // console.log(`${eventName} add`);
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
var map = this.eventMap.get(eventName);
|
|
2427
|
+
|
|
2428
|
+
if (!map) {
|
|
2429
|
+
map = new Map();
|
|
2430
|
+
this.eventMap.set(eventName, map);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
var wrappingCallback = function (e) {
|
|
2434
|
+
if (eventName in _this.mapEvent) {
|
|
2435
|
+
var bounds = _this.getCurrBounds();
|
|
2436
|
+
|
|
2437
|
+
var param = {
|
|
2438
|
+
name: eventName,
|
|
2439
|
+
mapType: 'google',
|
|
2440
|
+
vendorEventName: googleEventName,
|
|
2441
|
+
param: {
|
|
2442
|
+
bounds: bounds,
|
|
2443
|
+
center: bounds.getCenter(),
|
|
2444
|
+
zoomLevel: _this.getZoomLevel()
|
|
2445
|
+
}
|
|
2446
|
+
};
|
|
2447
|
+
callback(param);
|
|
2448
|
+
} else if (eventName in _this.mapUIEvent) {
|
|
2449
|
+
if (eventName.startsWith('DRAG')) console.log(eventName, e);
|
|
2450
|
+
var position = null;
|
|
2451
|
+
|
|
2452
|
+
if (e) {
|
|
2453
|
+
position = new Position(e.latLng.lat(), e.latLng.lng());
|
|
2454
|
+
position.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
2455
|
+
} else {
|
|
2456
|
+
position = _this.lastMousePosition;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
var param = {
|
|
2460
|
+
name: eventName,
|
|
2461
|
+
mapType: 'google',
|
|
2462
|
+
vendorEventName: googleEventName,
|
|
2463
|
+
param: {
|
|
2464
|
+
position: position,
|
|
2465
|
+
offset: position === null || position === void 0 ? void 0 : position.offset
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
callback(param);
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
|
|
2472
|
+
var googleEventListener = this.map.addListener(googleEventName, wrappingCallback);
|
|
2473
|
+
map.set(callback, googleEventListener);
|
|
2474
|
+
};
|
|
2475
|
+
|
|
2476
|
+
GoogleMintMapController.prototype.removeEventListener = function (eventName, callback) {
|
|
2477
|
+
var map = this.eventMap.get(eventName);
|
|
2478
|
+
|
|
2479
|
+
if (map) {
|
|
2480
|
+
var listenerMap = this.eventMap.get(eventName);
|
|
2481
|
+
|
|
2482
|
+
if (listenerMap) {
|
|
2483
|
+
var googleEventListener = listenerMap.get(callback);
|
|
2484
|
+
|
|
2485
|
+
if (googleEventListener) {
|
|
2486
|
+
// console.log(`${eventName} remove`);
|
|
2487
|
+
google.maps.event.removeListener(googleEventListener);
|
|
2488
|
+
listenerMap.delete(callback);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
GoogleMintMapController.prototype.removeAllEventListener = function (eventName) {
|
|
2495
|
+
var _this = this;
|
|
2496
|
+
|
|
2497
|
+
if (eventName) {
|
|
2498
|
+
this.clearEventListener(eventName);
|
|
2499
|
+
} else {
|
|
2500
|
+
this.eventMap.forEach(function (_map, eventName) {
|
|
2501
|
+
_this.clearEventListener(eventName);
|
|
2502
|
+
});
|
|
2503
|
+
this.eventMap.clear();
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
|
|
2507
|
+
GoogleMintMapController.prototype.clearEventListener = function (eventName) {
|
|
2508
|
+
var map = this.eventMap.get(eventName);
|
|
2509
|
+
|
|
2510
|
+
if (map) {
|
|
2511
|
+
map.forEach(function (googleEventListener) {
|
|
2512
|
+
// console.log(`${eventName} remove`);
|
|
2513
|
+
google.maps.event.removeListener(googleEventListener);
|
|
2514
|
+
});
|
|
2515
|
+
this.eventMap.delete(eventName);
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
|
|
2065
2519
|
return GoogleMintMapController;
|
|
2066
2520
|
}(MintMapController);
|
|
2067
2521
|
|
|
@@ -2076,12 +2530,20 @@ function (_super) {
|
|
|
2076
2530
|
_this.type = 'kakao';
|
|
2077
2531
|
_this.map = null;
|
|
2078
2532
|
_this.scriptUrl = 'https://dapi.kakao.com/v2/maps/sdk.js';
|
|
2079
|
-
_this.scriptModules = ['services', 'clusterer'];
|
|
2533
|
+
_this.scriptModules = ['services', 'clusterer']; // , 'geocoder' , 'panorama' , 'visualization']
|
|
2534
|
+
|
|
2535
|
+
_this.mapEvent = new MapEvent();
|
|
2536
|
+
_this.mapUIEvent = new MapUIEvent();
|
|
2080
2537
|
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
2081
2538
|
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
2082
2539
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
2083
2540
|
_this.dragStartPoint = [0, 0];
|
|
2084
2541
|
_this.dragged = false;
|
|
2542
|
+
_this.eventMap = new Map(); //kakao only 이벤트이름 재정의 zoom_start
|
|
2543
|
+
|
|
2544
|
+
_this.mapEvent.ZOOMSTART = 'zoom_start';
|
|
2545
|
+
Object.freeze(_this.mapEvent);
|
|
2546
|
+
Object.freeze(_this.mapUIEvent);
|
|
2085
2547
|
return _this; // console.log(`${this.type} controller loadded`);
|
|
2086
2548
|
}
|
|
2087
2549
|
|
|
@@ -2655,6 +3117,114 @@ function (_super) {
|
|
|
2655
3117
|
return latLng ? new Position(latLng.getLat(), latLng.getLng()) : new Position(0, 0);
|
|
2656
3118
|
};
|
|
2657
3119
|
|
|
3120
|
+
KakaoMintMapController.prototype.addEventListener = function (eventName, callback) {
|
|
3121
|
+
var _this = this;
|
|
3122
|
+
|
|
3123
|
+
var kakaoEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
|
|
3124
|
+
|
|
3125
|
+
if (!kakaoEventName) {
|
|
3126
|
+
console.warn("MapEventName ".concat(eventName, " is not supported"));
|
|
3127
|
+
return;
|
|
3128
|
+
} // console.log(`${eventName} add`);
|
|
3129
|
+
|
|
3130
|
+
|
|
3131
|
+
var map = this.eventMap.get(eventName);
|
|
3132
|
+
|
|
3133
|
+
if (!map) {
|
|
3134
|
+
map = new Map();
|
|
3135
|
+
this.eventMap.set(eventName, map);
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
var wrappingCallback = function (e) {
|
|
3139
|
+
if (eventName in _this.mapEvent) {
|
|
3140
|
+
var bounds = _this.getCurrBounds();
|
|
3141
|
+
|
|
3142
|
+
var param = {
|
|
3143
|
+
name: eventName,
|
|
3144
|
+
mapType: 'kakao',
|
|
3145
|
+
vendorEventName: kakaoEventName,
|
|
3146
|
+
param: {
|
|
3147
|
+
bounds: bounds,
|
|
3148
|
+
center: bounds.getCenter(),
|
|
3149
|
+
zoomLevel: _this.getZoomLevel()
|
|
3150
|
+
}
|
|
3151
|
+
};
|
|
3152
|
+
callback(param);
|
|
3153
|
+
} else if (eventName in _this.mapUIEvent) {
|
|
3154
|
+
var position = new Position(e.latLng.getLat(), e.latLng.getLng());
|
|
3155
|
+
position.offset = new Offset(e.point.x, e.point.y);
|
|
3156
|
+
var param = {
|
|
3157
|
+
name: eventName,
|
|
3158
|
+
mapType: 'kakao',
|
|
3159
|
+
vendorEventName: kakaoEventName,
|
|
3160
|
+
param: {
|
|
3161
|
+
position: position,
|
|
3162
|
+
offset: position.offset
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
callback(param);
|
|
3166
|
+
}
|
|
3167
|
+
};
|
|
3168
|
+
|
|
3169
|
+
kakao.maps.event.addListener(this.map, kakaoEventName, wrappingCallback);
|
|
3170
|
+
map.set(callback, wrappingCallback);
|
|
3171
|
+
};
|
|
3172
|
+
|
|
3173
|
+
KakaoMintMapController.prototype.removeEventListener = function (eventName, callback) {
|
|
3174
|
+
var kakaoEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
|
|
3175
|
+
|
|
3176
|
+
if (!kakaoEventName) {
|
|
3177
|
+
console.warn("MapEventName ".concat(eventName, " is not supported"));
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
var map = this.eventMap.get(eventName);
|
|
3182
|
+
|
|
3183
|
+
if (map) {
|
|
3184
|
+
var wrappingCallback = map.get(callback);
|
|
3185
|
+
|
|
3186
|
+
if (wrappingCallback) {
|
|
3187
|
+
// console.log(`${naverEventListener.eventName} remove`);
|
|
3188
|
+
kakao.maps.event.removeListener(this.map, kakaoEventName, wrappingCallback);
|
|
3189
|
+
map.delete(callback);
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3194
|
+
KakaoMintMapController.prototype.removeAllEventListener = function (eventName) {
|
|
3195
|
+
var _this = this;
|
|
3196
|
+
|
|
3197
|
+
if (eventName) {
|
|
3198
|
+
this.clearEventListener(eventName);
|
|
3199
|
+
} else {
|
|
3200
|
+
this.eventMap.forEach(function (_map, eventName) {
|
|
3201
|
+
_this.clearEventListener(eventName);
|
|
3202
|
+
});
|
|
3203
|
+
this.eventMap.clear();
|
|
3204
|
+
}
|
|
3205
|
+
};
|
|
3206
|
+
|
|
3207
|
+
KakaoMintMapController.prototype.clearEventListener = function (eventName) {
|
|
3208
|
+
var _this = this;
|
|
3209
|
+
|
|
3210
|
+
var kakaoEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
|
|
3211
|
+
|
|
3212
|
+
if (!kakaoEventName) {
|
|
3213
|
+
console.warn("MapEventName ".concat(eventName, " is not supported"));
|
|
3214
|
+
return;
|
|
3215
|
+
}
|
|
3216
|
+
|
|
3217
|
+
var map = this.eventMap.get(eventName);
|
|
3218
|
+
|
|
3219
|
+
if (map) {
|
|
3220
|
+
map.forEach(function (wrappingCallback) {
|
|
3221
|
+
// console.log(`${naverEventListener.eventName} remove`);
|
|
3222
|
+
kakao.maps.event.removeListener(_this.map, kakaoEventName, wrappingCallback);
|
|
3223
|
+
});
|
|
3224
|
+
this.eventMap.delete(eventName);
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
|
|
2658
3228
|
return KakaoMintMapController;
|
|
2659
3229
|
}(MintMapController);
|
|
2660
3230
|
|
|
@@ -2783,28 +3353,258 @@ function () {
|
|
|
2783
3353
|
return MintMapCanvasRenderer;
|
|
2784
3354
|
}();
|
|
2785
3355
|
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
this.draw = drawFunction;
|
|
2797
|
-
this.fps = fps || null;
|
|
3356
|
+
function SVGCircle(_a) {
|
|
3357
|
+
var _b = _a.radius,
|
|
3358
|
+
radius = _b === void 0 ? 100 : _b,
|
|
3359
|
+
_c = _a.background,
|
|
3360
|
+
background = _c === void 0 ? 'lightgreen' : _c,
|
|
3361
|
+
children = _a.children,
|
|
3362
|
+
_d = _a.svgProperties,
|
|
3363
|
+
svgProperties = _d === void 0 ? {} : _d,
|
|
3364
|
+
_e = _a.shapeProperties,
|
|
3365
|
+
shapeProperties = _e === void 0 ? {} : _e;
|
|
2798
3366
|
|
|
2799
|
-
|
|
2800
|
-
|
|
3367
|
+
var _f = useState(radius * 2),
|
|
3368
|
+
boxSize = _f[0],
|
|
3369
|
+
setBoxSize = _f[1];
|
|
3370
|
+
|
|
3371
|
+
useEffect(function () {
|
|
3372
|
+
// console.log('SVGCircle radius', radius);
|
|
3373
|
+
setBoxSize(radius * 2);
|
|
3374
|
+
}, [radius]);
|
|
3375
|
+
return React.createElement(React.Fragment, null, React.createElement("svg", __assign({
|
|
3376
|
+
pointerEvents: "none",
|
|
3377
|
+
width: boxSize,
|
|
3378
|
+
height: boxSize,
|
|
3379
|
+
viewBox: "0 0 100 100"
|
|
3380
|
+
}, svgProperties), React.createElement("circle", __assign({
|
|
3381
|
+
pointerEvents: "visiblepainted",
|
|
3382
|
+
cx: '50',
|
|
3383
|
+
cy: '50',
|
|
3384
|
+
r: '50',
|
|
3385
|
+
fill: background
|
|
3386
|
+
}, shapeProperties))), React.createElement("div", {
|
|
3387
|
+
style: {
|
|
3388
|
+
pointerEvents: 'none',
|
|
3389
|
+
position: 'absolute',
|
|
3390
|
+
left: '0px',
|
|
3391
|
+
top: '0px',
|
|
3392
|
+
width: "".concat(boxSize, "px"),
|
|
3393
|
+
height: "".concat(boxSize, "px")
|
|
2801
3394
|
}
|
|
3395
|
+
}, children));
|
|
3396
|
+
}
|
|
2802
3397
|
|
|
2803
|
-
|
|
2804
|
-
|
|
3398
|
+
function SVGPolygon(_a) {
|
|
3399
|
+
var path = _a.path,
|
|
3400
|
+
_b = _a.innerPath,
|
|
3401
|
+
innerPath = _b === void 0 ? [] : _b,
|
|
3402
|
+
_c = _a.background,
|
|
3403
|
+
background = _c === void 0 ? 'lightblue' : _c,
|
|
3404
|
+
_d = _a.svgProperties,
|
|
3405
|
+
svgProperties = _d === void 0 ? {} : _d,
|
|
3406
|
+
_e = _a.shapeProperties,
|
|
3407
|
+
shapeProperties = _e === void 0 ? {} : _e,
|
|
3408
|
+
_f = _a.mode,
|
|
3409
|
+
mode = _f === void 0 ? 'POLYGON' : _f,
|
|
3410
|
+
children = _a.children;
|
|
3411
|
+
var getPolygonInfo = useCallback(function (path) {
|
|
3412
|
+
var maxX, minX, maxY, minY;
|
|
2805
3413
|
|
|
2806
|
-
|
|
2807
|
-
|
|
3414
|
+
for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
|
|
3415
|
+
var offset = path_1[_i];
|
|
3416
|
+
|
|
3417
|
+
if (maxX === undefined || offset.x > maxX) {
|
|
3418
|
+
maxX = offset.x;
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
if (minX === undefined || offset.x < minX) {
|
|
3422
|
+
minX = offset.x;
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
if (maxY === undefined || offset.y > maxY) {
|
|
3426
|
+
maxY = offset.y;
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
if (minY === undefined || offset.y < minY) {
|
|
3430
|
+
minY = offset.y;
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
if (!maxX || !minX || !maxY || !minY) {
|
|
3435
|
+
return {
|
|
3436
|
+
containerLeft: 0,
|
|
3437
|
+
containerTop: 0,
|
|
3438
|
+
containerWidth: 0,
|
|
3439
|
+
containerHeight: 0
|
|
3440
|
+
};
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
var width = maxX - minX;
|
|
3444
|
+
var height = maxY - minY;
|
|
3445
|
+
return {
|
|
3446
|
+
containerLeft: Math.floor(minX),
|
|
3447
|
+
containerTop: Math.floor(minY),
|
|
3448
|
+
containerWidth: Math.floor(width),
|
|
3449
|
+
containerHeight: Math.floor(height)
|
|
3450
|
+
};
|
|
3451
|
+
}, []);
|
|
3452
|
+
var getD = useCallback(function (_a) {
|
|
3453
|
+
var path = _a.path,
|
|
3454
|
+
containerLeft = _a.containerLeft,
|
|
3455
|
+
containerTop = _a.containerTop,
|
|
3456
|
+
mode = _a.mode;
|
|
3457
|
+
var left = containerLeft;
|
|
3458
|
+
var top = containerTop;
|
|
3459
|
+
var isPolygon = mode === 'POLYGON';
|
|
3460
|
+
var out = ''; //path
|
|
3461
|
+
|
|
3462
|
+
out += getLine(path, left, top, isPolygon); //inner path
|
|
3463
|
+
|
|
3464
|
+
for (var _i = 0, innerPath_1 = innerPath; _i < innerPath_1.length; _i++) {
|
|
3465
|
+
var inner = innerPath_1[_i];
|
|
3466
|
+
out += ' ' + getLine(inner, left, top, isPolygon);
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
return out;
|
|
3470
|
+
}, []);
|
|
3471
|
+
var getLine = useCallback(function (path, offsetLeft, offsetTop, closePath) {
|
|
3472
|
+
return path.map(function (offset, idx) {
|
|
3473
|
+
if (idx === 0) {
|
|
3474
|
+
return "M ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
|
|
3475
|
+
} else if (idx === 1) {
|
|
3476
|
+
return "L ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
|
|
3477
|
+
} else {
|
|
3478
|
+
if (offset.equals(path[idx - 1])) {
|
|
3479
|
+
return '';
|
|
3480
|
+
} else {
|
|
3481
|
+
return "".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
}).join(' ') + " ".concat(closePath ? 'Z' : '');
|
|
3485
|
+
}, []);
|
|
3486
|
+
|
|
3487
|
+
var _g = useState(0),
|
|
3488
|
+
width = _g[0],
|
|
3489
|
+
setWidth = _g[1];
|
|
3490
|
+
|
|
3491
|
+
var _h = useState(0),
|
|
3492
|
+
height = _h[0],
|
|
3493
|
+
setHeight = _h[1];
|
|
3494
|
+
|
|
3495
|
+
var _j = useState('M0 0'),
|
|
3496
|
+
d = _j[0],
|
|
3497
|
+
setD = _j[1];
|
|
3498
|
+
|
|
3499
|
+
useEffect(function () {
|
|
3500
|
+
var info = getPolygonInfo(path);
|
|
3501
|
+
setWidth(info.containerWidth);
|
|
3502
|
+
setHeight(info.containerHeight);
|
|
3503
|
+
setD(getD(__assign(__assign({}, info), {
|
|
3504
|
+
path: path,
|
|
3505
|
+
innerPath: innerPath,
|
|
3506
|
+
mode: mode
|
|
3507
|
+
})));
|
|
3508
|
+
}, [path, innerPath]);
|
|
3509
|
+
return React.createElement(React.Fragment, null, React.createElement("svg", __assign({
|
|
3510
|
+
pointerEvents: "none",
|
|
3511
|
+
width: width,
|
|
3512
|
+
height: height,
|
|
3513
|
+
viewBox: "0 0 ".concat(width, " ").concat(height)
|
|
3514
|
+
}, svgProperties), React.createElement("path", __assign({
|
|
3515
|
+
fillRule: "evenodd",
|
|
3516
|
+
pointerEvents: "visiblepainted",
|
|
3517
|
+
x: "0",
|
|
3518
|
+
y: "0",
|
|
3519
|
+
width: width,
|
|
3520
|
+
height: height,
|
|
3521
|
+
fill: mode === 'POLYLINE' ? 'none' : background,
|
|
3522
|
+
stroke: mode === 'POLYLINE' ? 'black' : 'green',
|
|
3523
|
+
strokeLinejoin: "round",
|
|
3524
|
+
strokeLinecap: "butt",
|
|
3525
|
+
d: d
|
|
3526
|
+
}, shapeProperties))), React.createElement("div", {
|
|
3527
|
+
style: {
|
|
3528
|
+
pointerEvents: 'none',
|
|
3529
|
+
position: 'absolute',
|
|
3530
|
+
left: '0px',
|
|
3531
|
+
top: '0px',
|
|
3532
|
+
width: "".concat(width, "px"),
|
|
3533
|
+
height: "".concat(height, "px")
|
|
3534
|
+
}
|
|
3535
|
+
}, children));
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
function SVGRect(_a) {
|
|
3539
|
+
var _b = _a.width,
|
|
3540
|
+
width = _b === void 0 ? 100 : _b,
|
|
3541
|
+
_c = _a.height,
|
|
3542
|
+
height = _c === void 0 ? 100 : _c,
|
|
3543
|
+
_d = _a.background,
|
|
3544
|
+
background = _d === void 0 ? 'lightblue' : _d,
|
|
3545
|
+
_e = _a.svgProperties,
|
|
3546
|
+
svgProperties = _e === void 0 ? {} : _e,
|
|
3547
|
+
_f = _a.shapeProperties,
|
|
3548
|
+
shapeProperties = _f === void 0 ? {} : _f,
|
|
3549
|
+
children = _a.children;
|
|
3550
|
+
var getViewHeight = useCallback(function (width, height) {
|
|
3551
|
+
return Number((100 * height / width).toFixed(0));
|
|
3552
|
+
}, []);
|
|
3553
|
+
var viewWidth = useRef(100);
|
|
3554
|
+
|
|
3555
|
+
var _g = useState(getViewHeight(width, height)),
|
|
3556
|
+
viewHeight = _g[0],
|
|
3557
|
+
setViewHeight = _g[1];
|
|
3558
|
+
|
|
3559
|
+
useEffect(function () {
|
|
3560
|
+
setViewHeight(getViewHeight(width, height));
|
|
3561
|
+
}, [width, height]);
|
|
3562
|
+
return React.createElement(React.Fragment, null, React.createElement("svg", __assign({
|
|
3563
|
+
pointerEvents: "none",
|
|
3564
|
+
width: width,
|
|
3565
|
+
height: height,
|
|
3566
|
+
viewBox: "0 0 ".concat(viewWidth.current, " ").concat(viewHeight)
|
|
3567
|
+
}, svgProperties), React.createElement("rect", __assign({
|
|
3568
|
+
pointerEvents: "visiblepainted",
|
|
3569
|
+
x: "0",
|
|
3570
|
+
y: "0",
|
|
3571
|
+
width: viewWidth.current,
|
|
3572
|
+
height: viewHeight,
|
|
3573
|
+
fill: background
|
|
3574
|
+
}, shapeProperties))), React.createElement("div", {
|
|
3575
|
+
style: {
|
|
3576
|
+
pointerEvents: 'none',
|
|
3577
|
+
position: 'absolute',
|
|
3578
|
+
left: '0px',
|
|
3579
|
+
top: '0px',
|
|
3580
|
+
width: "".concat(width, "px"),
|
|
3581
|
+
height: "".concat(height, "px")
|
|
3582
|
+
}
|
|
3583
|
+
}, children));
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
var AnimationPlayer =
|
|
3587
|
+
/** @class */
|
|
3588
|
+
function () {
|
|
3589
|
+
function AnimationPlayer(drawFunction, fps) {
|
|
3590
|
+
this.prevtime = 0;
|
|
3591
|
+
this.elapsedTime = 0;
|
|
3592
|
+
this.fps = null;
|
|
3593
|
+
this.baseDrawGapTime = null;
|
|
3594
|
+
this.deltaTime = 0;
|
|
3595
|
+
this.playing = false;
|
|
3596
|
+
this.draw = drawFunction;
|
|
3597
|
+
this.fps = fps || null;
|
|
3598
|
+
|
|
3599
|
+
if (fps !== undefined) {
|
|
3600
|
+
this.baseDrawGapTime = 1000 / fps;
|
|
3601
|
+
}
|
|
3602
|
+
|
|
3603
|
+
this.init();
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
AnimationPlayer.prototype.init = function () {
|
|
3607
|
+
this.deltaTime = 0;
|
|
2808
3608
|
this.prevtime = 0;
|
|
2809
3609
|
this.elapsedTime = 0;
|
|
2810
3610
|
this.playing = false;
|
|
@@ -2857,6 +3657,86 @@ function () {
|
|
|
2857
3657
|
return AnimationPlayer;
|
|
2858
3658
|
}();
|
|
2859
3659
|
|
|
3660
|
+
var Drawable =
|
|
3661
|
+
/** @class */
|
|
3662
|
+
function () {
|
|
3663
|
+
function Drawable() {}
|
|
3664
|
+
|
|
3665
|
+
return Drawable;
|
|
3666
|
+
}();
|
|
3667
|
+
|
|
3668
|
+
var Marker =
|
|
3669
|
+
/** @class */
|
|
3670
|
+
function (_super) {
|
|
3671
|
+
__extends(Marker, _super);
|
|
3672
|
+
/**
|
|
3673
|
+
* 지도에 표시할 마커정보
|
|
3674
|
+
*/
|
|
3675
|
+
|
|
3676
|
+
|
|
3677
|
+
function Marker(options) {
|
|
3678
|
+
var _this = _super.call(this) || this;
|
|
3679
|
+
|
|
3680
|
+
_this.options = options;
|
|
3681
|
+
return _this;
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
return Marker;
|
|
3685
|
+
}(Drawable);
|
|
3686
|
+
|
|
3687
|
+
var Polyline =
|
|
3688
|
+
/** @class */
|
|
3689
|
+
function (_super) {
|
|
3690
|
+
__extends(Polyline, _super);
|
|
3691
|
+
/**
|
|
3692
|
+
* 지도에 표시할 폴리곤정보
|
|
3693
|
+
*/
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
function Polyline(options) {
|
|
3697
|
+
var _this = _super.call(this) || this;
|
|
3698
|
+
|
|
3699
|
+
_this.options = options;
|
|
3700
|
+
return _this;
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
return Polyline;
|
|
3704
|
+
}(Drawable);
|
|
3705
|
+
|
|
3706
|
+
var Polygon =
|
|
3707
|
+
/** @class */
|
|
3708
|
+
function (_super) {
|
|
3709
|
+
__extends(Polygon, _super);
|
|
3710
|
+
/**
|
|
3711
|
+
* 지도에 표시할 폴리곤정보
|
|
3712
|
+
*/
|
|
3713
|
+
|
|
3714
|
+
|
|
3715
|
+
function Polygon(options) {
|
|
3716
|
+
var _this = _super.call(this) || this;
|
|
3717
|
+
|
|
3718
|
+
_this.options = options;
|
|
3719
|
+
return _this;
|
|
3720
|
+
}
|
|
3721
|
+
/**
|
|
3722
|
+
* 폴리곤의 중점을 구한다.
|
|
3723
|
+
*/
|
|
3724
|
+
|
|
3725
|
+
|
|
3726
|
+
Polygon.prototype.getCenter = function () {
|
|
3727
|
+
if (Array.isArray(this.options.position) && this.options.position.length > 0) {
|
|
3728
|
+
var paths = this.options.position.map(function (elem) {
|
|
3729
|
+
return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
|
|
3730
|
+
});
|
|
3731
|
+
return PolygonCalculator.getCenter(paths);
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
throw new Error('center 를 찾을 수 없습니다.');
|
|
3735
|
+
};
|
|
3736
|
+
|
|
3737
|
+
return Polygon;
|
|
3738
|
+
}(Drawable);
|
|
3739
|
+
|
|
2860
3740
|
function nextIndex(array, currIdx) {
|
|
2861
3741
|
var next = currIdx + 1;
|
|
2862
3742
|
|
|
@@ -2948,7 +3828,7 @@ function useMarkerMoving(_a) {
|
|
|
2948
3828
|
}
|
|
2949
3829
|
}
|
|
2950
3830
|
|
|
2951
|
-
nextOption_1.position = context_1.nextPos;
|
|
3831
|
+
nextOption_1.position = new Position(context_1.nextPos.lat, context_1.nextPos.lng);
|
|
2952
3832
|
marker.options.position = nextOption_1.position;
|
|
2953
3833
|
controller.updateMarker(marker, nextOption_1);
|
|
2954
3834
|
|
|
@@ -3001,86 +3881,6 @@ function useMarkerMoving(_a) {
|
|
|
3001
3881
|
return [start, stop, resume];
|
|
3002
3882
|
}
|
|
3003
3883
|
|
|
3004
|
-
var Drawable =
|
|
3005
|
-
/** @class */
|
|
3006
|
-
function () {
|
|
3007
|
-
function Drawable() {}
|
|
3008
|
-
|
|
3009
|
-
return Drawable;
|
|
3010
|
-
}();
|
|
3011
|
-
|
|
3012
|
-
var Marker =
|
|
3013
|
-
/** @class */
|
|
3014
|
-
function (_super) {
|
|
3015
|
-
__extends(Marker, _super);
|
|
3016
|
-
/**
|
|
3017
|
-
* 지도에 표시할 마커정보
|
|
3018
|
-
*/
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
function Marker(options) {
|
|
3022
|
-
var _this = _super.call(this) || this;
|
|
3023
|
-
|
|
3024
|
-
_this.options = options;
|
|
3025
|
-
return _this;
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
return Marker;
|
|
3029
|
-
}(Drawable);
|
|
3030
|
-
|
|
3031
|
-
var Polyline =
|
|
3032
|
-
/** @class */
|
|
3033
|
-
function (_super) {
|
|
3034
|
-
__extends(Polyline, _super);
|
|
3035
|
-
/**
|
|
3036
|
-
* 지도에 표시할 폴리곤정보
|
|
3037
|
-
*/
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
function Polyline(options) {
|
|
3041
|
-
var _this = _super.call(this) || this;
|
|
3042
|
-
|
|
3043
|
-
_this.options = options;
|
|
3044
|
-
return _this;
|
|
3045
|
-
}
|
|
3046
|
-
|
|
3047
|
-
return Polyline;
|
|
3048
|
-
}(Drawable);
|
|
3049
|
-
|
|
3050
|
-
var Polygon =
|
|
3051
|
-
/** @class */
|
|
3052
|
-
function (_super) {
|
|
3053
|
-
__extends(Polygon, _super);
|
|
3054
|
-
/**
|
|
3055
|
-
* 지도에 표시할 폴리곤정보
|
|
3056
|
-
*/
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
function Polygon(options) {
|
|
3060
|
-
var _this = _super.call(this) || this;
|
|
3061
|
-
|
|
3062
|
-
_this.options = options;
|
|
3063
|
-
return _this;
|
|
3064
|
-
}
|
|
3065
|
-
/**
|
|
3066
|
-
* 폴리곤의 중점을 구한다.
|
|
3067
|
-
*/
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
Polygon.prototype.getCenter = function () {
|
|
3071
|
-
if (Array.isArray(this.options.position) && this.options.position.length > 0) {
|
|
3072
|
-
var paths = this.options.position.map(function (elem) {
|
|
3073
|
-
return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
|
|
3074
|
-
});
|
|
3075
|
-
return PolygonCalculator.getCenter(paths);
|
|
3076
|
-
}
|
|
3077
|
-
|
|
3078
|
-
throw new Error('center 를 찾을 수 없습니다.');
|
|
3079
|
-
};
|
|
3080
|
-
|
|
3081
|
-
return Polygon;
|
|
3082
|
-
}(Drawable);
|
|
3083
|
-
|
|
3084
3884
|
var offsetCalibration = function (mapType, divElement, options) {
|
|
3085
3885
|
//google 맵의 anchor 보정 (네이버와 같이 왼쪽/위 기준으로 처리)
|
|
3086
3886
|
if (mapType === 'google') {
|
|
@@ -3106,8 +3906,10 @@ function MapMarkerWrapper(_a) {
|
|
|
3106
3906
|
_c = _a.topOnHover,
|
|
3107
3907
|
topOnHover = _c === void 0 ? false : _c,
|
|
3108
3908
|
movingAnimation = _a.movingAnimation,
|
|
3909
|
+
_d = _a.disablePointerEvent,
|
|
3910
|
+
disablePointerEvent = _d === void 0 ? false : _d,
|
|
3109
3911
|
children = _a.children,
|
|
3110
|
-
options = __rest(_a, ["startAnimationClassName", "endAnimationClassName", "topOnClick", "topOnHover", "movingAnimation", "children"]); //controller
|
|
3912
|
+
options = __rest(_a, ["startAnimationClassName", "endAnimationClassName", "topOnClick", "topOnHover", "movingAnimation", "disablePointerEvent", "children"]); //controller
|
|
3111
3913
|
|
|
3112
3914
|
|
|
3113
3915
|
var controller = useMintMapController(); //element
|
|
@@ -3119,9 +3921,9 @@ function MapMarkerWrapper(_a) {
|
|
|
3119
3921
|
|
|
3120
3922
|
var markerRef = useRef(); //moving animation
|
|
3121
3923
|
|
|
3122
|
-
var
|
|
3123
|
-
movingState =
|
|
3124
|
-
setMovingState =
|
|
3924
|
+
var _e = useState({}),
|
|
3925
|
+
movingState = _e[0],
|
|
3926
|
+
setMovingState = _e[1];
|
|
3125
3927
|
|
|
3126
3928
|
useEffect(function () {
|
|
3127
3929
|
// console.log('movingState', movingState);
|
|
@@ -3159,120 +3961,557 @@ function MapMarkerWrapper(_a) {
|
|
|
3159
3961
|
|
|
3160
3962
|
next && !topOnHover && topOnClick && controller.markerToTheTop(marker);
|
|
3161
3963
|
}
|
|
3162
|
-
};
|
|
3964
|
+
};
|
|
3965
|
+
|
|
3966
|
+
var onMouseOverHandler = function (e) {
|
|
3967
|
+
var _a;
|
|
3968
|
+
|
|
3969
|
+
var marker = markerRef.current; //console.log('onMouseOverHandler', marker);
|
|
3970
|
+
|
|
3971
|
+
if (marker) {
|
|
3972
|
+
var mouseOverHandler = (_a = options === null || options === void 0 ? void 0 : options.event) === null || _a === void 0 ? void 0 : _a.get('mouseover');
|
|
3973
|
+
var next = true;
|
|
3974
|
+
|
|
3975
|
+
if (mouseOverHandler) {
|
|
3976
|
+
var hasNext = mouseOverHandler(e);
|
|
3977
|
+
hasNext !== undefined && (next = hasNext);
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
next && topOnHover && controller.markerToTheTop(marker);
|
|
3981
|
+
}
|
|
3982
|
+
}; //create object
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
useEffect(function () {
|
|
3986
|
+
// console.log('drawable created')
|
|
3987
|
+
divElement.style.display = 'flex';
|
|
3988
|
+
divElement.style.justifyContent = 'flex-start';
|
|
3989
|
+
divElement.style.alignItems = 'flex-start';
|
|
3990
|
+
divElement.style.flexDirection = 'column';
|
|
3991
|
+
divElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
|
|
3992
|
+
divElement.addEventListener('click', onClickHandler);
|
|
3993
|
+
divElement.addEventListener('mouseover', onMouseOverHandler);
|
|
3994
|
+
return function () {
|
|
3995
|
+
//** kakao 는 viewport 안에 있는 마커만 렌더링하므로,
|
|
3996
|
+
//마커 해제가 되더라도 애니메이션 이벤트가 일어나지 않아서 해지된 마커가 잠시 보이는 현상이 있음
|
|
3997
|
+
//그래서 kakao 일때는 endAnimationClassName 영향을 받지 않도록 처리함
|
|
3998
|
+
if (divCloneRef.current && endAnimationClassName && controller.getMapType() !== 'kakao') {
|
|
3999
|
+
divCloneRef.current.classList.add(endAnimationClassName);
|
|
4000
|
+
|
|
4001
|
+
var aniListener_1 = function () {
|
|
4002
|
+
//console.log('animationend!!!', divCloneRef.current);
|
|
4003
|
+
divCloneRef.current && divCloneRef.current.removeEventListener('animationend', aniListener_1);
|
|
4004
|
+
|
|
4005
|
+
if (markerRef.current) {
|
|
4006
|
+
controller.clearDrawable(markerRef.current); // console.log('drawable cleared')
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
divCloneRef.current = undefined;
|
|
4010
|
+
};
|
|
4011
|
+
|
|
4012
|
+
divCloneRef.current.addEventListener('animationend', aniListener_1);
|
|
4013
|
+
divElement.append(divCloneRef.current);
|
|
4014
|
+
} else {
|
|
4015
|
+
divElement.removeEventListener('click', onClickHandler);
|
|
4016
|
+
divElement.removeEventListener('mouseover', onMouseOverHandler);
|
|
4017
|
+
|
|
4018
|
+
if (markerRef.current) {
|
|
4019
|
+
controller.clearDrawable(markerRef.current); // console.log('drawable cleared')
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
4023
|
+
}, []); //create / update object
|
|
4024
|
+
|
|
4025
|
+
useEffect(function () {
|
|
4026
|
+
if (options) {
|
|
4027
|
+
if (markerRef.current) {
|
|
4028
|
+
//console.log('update Marker')
|
|
4029
|
+
controller.updateMarker(markerRef.current, options); //disablePointerEvent 처리
|
|
4030
|
+
|
|
4031
|
+
if (divElement.parentElement) {
|
|
4032
|
+
divElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
|
|
4033
|
+
divElement.parentElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
|
|
4034
|
+
} //marker offset 보정
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
offsetCalibration(controller.getMapType(), divElement, options); //z-index 처리
|
|
4038
|
+
|
|
4039
|
+
if (options.zIndex !== undefined) {
|
|
4040
|
+
controller.setMarkerZIndex(markerRef.current, options.zIndex);
|
|
4041
|
+
}
|
|
4042
|
+
} else {
|
|
4043
|
+
//console.log('create Marker')
|
|
4044
|
+
markerRef.current = new Marker(options);
|
|
4045
|
+
markerRef.current.element = divElement;
|
|
4046
|
+
controller.createMarker(markerRef.current); //disablePointerEvent 처리
|
|
4047
|
+
|
|
4048
|
+
if (divElement.parentElement) {
|
|
4049
|
+
divElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
|
|
4050
|
+
divElement.parentElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
|
|
4051
|
+
} //marker offset 보정
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
offsetCalibration(controller.getMapType(), divElement, options); //z-index 처리
|
|
4055
|
+
|
|
4056
|
+
if (options.zIndex !== undefined) {
|
|
4057
|
+
controller.setMarkerZIndex(markerRef.current, options.zIndex);
|
|
4058
|
+
} //moving 애니메이션 시작
|
|
4059
|
+
|
|
4060
|
+
|
|
4061
|
+
if (movingAnimation) {
|
|
4062
|
+
setMovingState(__assign(__assign({}, movingAnimation), {
|
|
4063
|
+
marker: markerRef.current
|
|
4064
|
+
}));
|
|
4065
|
+
} //start animation
|
|
4066
|
+
|
|
4067
|
+
|
|
4068
|
+
if (startAnimationClassName) {
|
|
4069
|
+
divElement.style.visibility = 'hidden';
|
|
4070
|
+
setTimeout(function () {
|
|
4071
|
+
var _a, _b;
|
|
4072
|
+
|
|
4073
|
+
divCloneRef.current = divElement.firstElementChild;
|
|
4074
|
+
divElement.style.visibility = 'visible';
|
|
4075
|
+
(_a = divElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.classList.add(startAnimationClassName);
|
|
4076
|
+
|
|
4077
|
+
var aniListener = function () {
|
|
4078
|
+
var _a, _b;
|
|
4079
|
+
|
|
4080
|
+
(_a = divElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.classList.remove(startAnimationClassName);
|
|
4081
|
+
(_b = divElement.firstElementChild) === null || _b === void 0 ? void 0 : _b.removeEventListener('animationend', aniListener);
|
|
4082
|
+
};
|
|
4083
|
+
|
|
4084
|
+
(_b = divElement.firstElementChild) === null || _b === void 0 ? void 0 : _b.addEventListener('animationend', aniListener);
|
|
4085
|
+
});
|
|
4086
|
+
} else {
|
|
4087
|
+
setTimeout(function () {
|
|
4088
|
+
divCloneRef.current = divElement.firstElementChild;
|
|
4089
|
+
});
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
}
|
|
4093
|
+
}, [options]);
|
|
4094
|
+
return createPortal(children, divElement);
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, itemList, sizeFunction) {
|
|
4098
|
+
var _a; //1. basePixelSize 기준으로 현재 지도 크기를 베이스로 영역 갯수 정하기
|
|
4099
|
+
|
|
4100
|
+
|
|
4101
|
+
var rowCount = Number((mapWidth / basePixelSize).toFixed(0)) || 1;
|
|
4102
|
+
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1; //console.log('rowCount', rowCount, 'colCount', colCount)
|
|
4103
|
+
|
|
4104
|
+
var boundsLineSizeX = Number(((mapBounds.ne.lng - mapBounds.nw.lng) / rowCount).toFixed(7));
|
|
4105
|
+
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7)); //console.log('boundsLineSize', boundsLineSizeX, boundsLineSizeY)
|
|
4106
|
+
var boundsPos = [];
|
|
4107
|
+
var tempX1, tempY1, tempX2, tempY2;
|
|
4108
|
+
|
|
4109
|
+
for (var i = 0; i < rowCount; i++) {
|
|
4110
|
+
tempX1 = mapBounds.nw.lng + boundsLineSizeX * i;
|
|
4111
|
+
tempX2 = mapBounds.nw.lng + boundsLineSizeX * (i + 1);
|
|
4112
|
+
var rows = [];
|
|
4113
|
+
boundsPos.push(rows);
|
|
4114
|
+
|
|
4115
|
+
for (var k = 0; k < colCount; k++) {
|
|
4116
|
+
tempY2 = mapBounds.se.lat + boundsLineSizeY * k;
|
|
4117
|
+
tempY1 = mapBounds.se.lat + boundsLineSizeY * (k + 1);
|
|
4118
|
+
var thisBounds = Bounds.fromNWSE(new Position(tempY1, tempX1), new Position(tempY2, tempX2));
|
|
4119
|
+
var includedList = thisBounds.getIncludedPositions(itemList);
|
|
4120
|
+
rows.push({
|
|
4121
|
+
bounds: thisBounds,
|
|
4122
|
+
checked: false,
|
|
4123
|
+
center: false,
|
|
4124
|
+
centerPosition: thisBounds.getCenter(),
|
|
4125
|
+
incList: [],
|
|
4126
|
+
itemList: includedList,
|
|
4127
|
+
size: basePixelSize
|
|
4128
|
+
});
|
|
4129
|
+
}
|
|
4130
|
+
} //좌표마다 검사해서 인접셀 병합 처리
|
|
4131
|
+
|
|
4132
|
+
|
|
4133
|
+
var centerList = [];
|
|
4134
|
+
var totalItemCount = 0;
|
|
4135
|
+
var min;
|
|
4136
|
+
var max;
|
|
4137
|
+
|
|
4138
|
+
for (var i = 0; i < boundsPos.length; i++) {
|
|
4139
|
+
for (var k = 0; k < boundsPos[i].length; k++) {
|
|
4140
|
+
var curr = boundsPos[i][k];
|
|
4141
|
+
if (curr.checked) continue;
|
|
4142
|
+
curr.checked = true; //현재기준 8방향 객체 모으기
|
|
4143
|
+
|
|
4144
|
+
var incList = [];
|
|
4145
|
+
|
|
4146
|
+
if (boundsPos[i]) {
|
|
4147
|
+
boundsPos[i][k - 1] && incList.push(boundsPos[i][k - 1]);
|
|
4148
|
+
boundsPos[i][k + 1] && incList.push(boundsPos[i][k + 1]);
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
if (boundsPos[i - 1]) {
|
|
4152
|
+
boundsPos[i - 1][k - 1] && incList.push(boundsPos[i - 1][k - 1]);
|
|
4153
|
+
boundsPos[i - 1][k] && incList.push(boundsPos[i - 1][k]);
|
|
4154
|
+
boundsPos[i - 1][k + 1] && incList.push(boundsPos[i - 1][k + 1]);
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
if (boundsPos[i + 1]) {
|
|
4158
|
+
boundsPos[i + 1][k + 1] && incList.push(boundsPos[i + 1][k + 1]);
|
|
4159
|
+
boundsPos[i + 1][k] && incList.push(boundsPos[i + 1][k]);
|
|
4160
|
+
boundsPos[i + 1][k - 1] && incList.push(boundsPos[i + 1][k - 1]);
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
for (var _i = 0, incList_1 = incList; _i < incList_1.length; _i++) {
|
|
4164
|
+
var inc = incList_1[_i];
|
|
4165
|
+
if (inc.checked) continue;
|
|
4166
|
+
inc.checked = true;
|
|
4167
|
+
|
|
4168
|
+
if (inc.itemList && inc.itemList.length > 0) {
|
|
4169
|
+
curr.incList.push(inc);
|
|
4170
|
+
|
|
4171
|
+
(_a = curr.itemList).push.apply(_a, inc.itemList);
|
|
4172
|
+
|
|
4173
|
+
curr.center = true;
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4177
|
+
if (curr.center) {
|
|
4178
|
+
centerList.push(curr);
|
|
4179
|
+
var avrLat = calculateAverage(curr.itemList.map(function (item) {
|
|
4180
|
+
return item.lat;
|
|
4181
|
+
}));
|
|
4182
|
+
var avrLng = calculateAverage(curr.itemList.map(function (item) {
|
|
4183
|
+
return item.lng;
|
|
4184
|
+
}));
|
|
4185
|
+
curr.centerPosition = new Position(avrLat, avrLng);
|
|
4186
|
+
totalItemCount += curr.itemList.length;
|
|
4187
|
+
|
|
4188
|
+
if (!min || curr.itemList.length < min) {
|
|
4189
|
+
min = curr.itemList.length;
|
|
4190
|
+
}
|
|
4191
|
+
|
|
4192
|
+
if (!max || curr.itemList.length > max) {
|
|
4193
|
+
max = curr.itemList.length;
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
var status = {
|
|
4200
|
+
total: totalItemCount,
|
|
4201
|
+
average: totalItemCount / centerList.length,
|
|
4202
|
+
min: min,
|
|
4203
|
+
max: max
|
|
4204
|
+
};
|
|
4205
|
+
|
|
4206
|
+
sizeFunction = sizeFunction || function (info, status) {
|
|
4207
|
+
var minSize = basePixelSize / 4;
|
|
4208
|
+
var maxSize = basePixelSize;
|
|
4209
|
+
return Math.min(Math.max(basePixelSize * info.itemList.length / status.average, minSize), maxSize);
|
|
4210
|
+
};
|
|
4211
|
+
|
|
4212
|
+
for (var _b = 0, centerList_1 = centerList; _b < centerList_1.length; _b++) {
|
|
4213
|
+
var center = centerList_1[_b];
|
|
4214
|
+
center.size = sizeFunction(center, status);
|
|
4215
|
+
} // console.log('centerList', centerList, status);
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
return centerList;
|
|
4219
|
+
};
|
|
4220
|
+
|
|
4221
|
+
var calculateAverage = function (nums) {
|
|
4222
|
+
var sum = 0;
|
|
4223
|
+
|
|
4224
|
+
for (var _i = 0, nums_1 = nums; _i < nums_1.length; _i++) {
|
|
4225
|
+
var num = nums_1[_i];
|
|
4226
|
+
sum += num;
|
|
4227
|
+
}
|
|
4228
|
+
|
|
4229
|
+
return Number((sum / nums.length).toFixed(7));
|
|
4230
|
+
};
|
|
4231
|
+
|
|
4232
|
+
/**
|
|
4233
|
+
* CircleMarker
|
|
4234
|
+
*
|
|
4235
|
+
* @param {CircleMarkerProps} CircleMarkerProps
|
|
4236
|
+
*
|
|
4237
|
+
* @returns {JSX.Element} JSX
|
|
4238
|
+
*/
|
|
4239
|
+
|
|
4240
|
+
function CircleMarker(_a) {
|
|
4241
|
+
var children = _a.children,
|
|
4242
|
+
center = _a.center,
|
|
4243
|
+
radius = _a.radius,
|
|
4244
|
+
_b = _a.radiusUnit,
|
|
4245
|
+
radiusUnit = _b === void 0 ? 'PIXEL' : _b,
|
|
4246
|
+
_c = _a.background,
|
|
4247
|
+
background = _c === void 0 ? 'lightgreen' : _c,
|
|
4248
|
+
_d = _a.svgProperties,
|
|
4249
|
+
svgProperties = _d === void 0 ? {} : _d,
|
|
4250
|
+
_e = _a.shapeProperties,
|
|
4251
|
+
shapeProperties = _e === void 0 ? {} : _e,
|
|
4252
|
+
_f = _a.visible,
|
|
4253
|
+
visible = _f === void 0 ? true : _f,
|
|
4254
|
+
zIndex = _a.zIndex; //controller
|
|
4255
|
+
|
|
4256
|
+
var controller = useMintMapController(); //zoom start event
|
|
4257
|
+
|
|
4258
|
+
var onZoomStart = useCallback(function () {
|
|
4259
|
+
setMapVisible(false);
|
|
4260
|
+
}, []); //idle event
|
|
4261
|
+
|
|
4262
|
+
var onIdle = useCallback(function () {
|
|
4263
|
+
var newZoomLevel = controller.getZoomLevel();
|
|
4264
|
+
|
|
4265
|
+
if (zoomLevel.current !== newZoomLevel) {
|
|
4266
|
+
zoomLevel.current = newZoomLevel;
|
|
4267
|
+
renderCircleBase();
|
|
4268
|
+
setTimeout(function () {
|
|
4269
|
+
setMapVisible(true);
|
|
4270
|
+
});
|
|
4271
|
+
}
|
|
4272
|
+
}, []);
|
|
4273
|
+
var zoomLevel = useRef(controller.getZoomLevel());
|
|
4274
|
+
useEffect(function () {
|
|
4275
|
+
controller.addEventListener("ZOOMSTART", onZoomStart);
|
|
4276
|
+
controller.addEventListener("IDLE", onIdle);
|
|
4277
|
+
return function () {
|
|
4278
|
+
controller.removeEventListener("ZOOMSTART", onZoomStart);
|
|
4279
|
+
controller.removeEventListener("IDLE", onIdle);
|
|
4280
|
+
};
|
|
4281
|
+
}, []); //offsets
|
|
3163
4282
|
|
|
3164
|
-
var
|
|
3165
|
-
|
|
4283
|
+
var _g = useState(),
|
|
4284
|
+
computedRadius = _g[0],
|
|
4285
|
+
setComputedRadius = _g[1];
|
|
3166
4286
|
|
|
3167
|
-
|
|
4287
|
+
var _h = useState(new Offset(0, 0)),
|
|
4288
|
+
anchor = _h[0],
|
|
4289
|
+
setAnchor = _h[1]; //circle props ref
|
|
3168
4290
|
|
|
3169
|
-
if (marker) {
|
|
3170
|
-
var mouseOverHandler = (_a = options === null || options === void 0 ? void 0 : options.event) === null || _a === void 0 ? void 0 : _a.get('mouseover');
|
|
3171
|
-
var next = true;
|
|
3172
4291
|
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
4292
|
+
var circlePropsRef = useRef({
|
|
4293
|
+
center: center,
|
|
4294
|
+
radius: radius,
|
|
4295
|
+
radiusUnit: radiusUnit
|
|
4296
|
+
}); //circle 생성 effect
|
|
3177
4297
|
|
|
3178
|
-
|
|
4298
|
+
useEffect(function () {
|
|
4299
|
+
circlePropsRef.current = {
|
|
4300
|
+
center: center,
|
|
4301
|
+
radius: radius,
|
|
4302
|
+
radiusUnit: radiusUnit
|
|
4303
|
+
};
|
|
4304
|
+
renderCircleBase();
|
|
4305
|
+
}, [center, radius, radiusUnit]); //render
|
|
4306
|
+
|
|
4307
|
+
var _j = useState(true),
|
|
4308
|
+
mapVisible = _j[0],
|
|
4309
|
+
setMapVisible = _j[1];
|
|
4310
|
+
|
|
4311
|
+
var renderCircleBase = useCallback(function () {
|
|
4312
|
+
var _a = circlePropsRef.current,
|
|
4313
|
+
center = _a.center,
|
|
4314
|
+
radius = _a.radius,
|
|
4315
|
+
radiusUnit = _a.radiusUnit;
|
|
4316
|
+
|
|
4317
|
+
if (radiusUnit === 'METER') {
|
|
4318
|
+
var latMargin = GeoCalulator.convertMeterToLatitudeValue(radius);
|
|
4319
|
+
var targetPos = new Position(center.lat + latMargin, center.lng);
|
|
4320
|
+
var tempComputedRadius = calcRadius(center, targetPos);
|
|
4321
|
+
setComputedRadius(tempComputedRadius);
|
|
4322
|
+
setAnchor(new Offset(tempComputedRadius, tempComputedRadius)); // console.log(`${radius} meter => `, tempComputedRadius);
|
|
4323
|
+
} else {
|
|
4324
|
+
setComputedRadius(radius);
|
|
4325
|
+
setAnchor(new Offset(radius, radius)); // console.log(`${radius} pixel => `, radius);
|
|
3179
4326
|
}
|
|
3180
|
-
};
|
|
4327
|
+
}, []);
|
|
4328
|
+
var calcRadius = useCallback(function (center, targetPos) {
|
|
4329
|
+
var c = controller.positionToOffset(center);
|
|
4330
|
+
var t = controller.positionToOffset(targetPos);
|
|
4331
|
+
return Math.round(Math.sqrt(Math.pow(Math.abs(c.x - t.x), 2) + Math.pow(Math.abs(c.y - t.y), 2)));
|
|
4332
|
+
}, []);
|
|
4333
|
+
return React.createElement(React.Fragment, null, computedRadius && React.createElement(MapMarkerWrapper, {
|
|
4334
|
+
position: center,
|
|
4335
|
+
anchor: anchor,
|
|
4336
|
+
visible: visible,
|
|
4337
|
+
disablePointerEvent: true,
|
|
4338
|
+
zIndex: zIndex
|
|
4339
|
+
}, mapVisible && React.createElement(SVGCircle, {
|
|
4340
|
+
radius: computedRadius,
|
|
4341
|
+
background: background,
|
|
4342
|
+
shapeProperties: __assign({
|
|
4343
|
+
pointerEvents: 'none'
|
|
4344
|
+
}, shapeProperties),
|
|
4345
|
+
svgProperties: svgProperties
|
|
4346
|
+
}, children)));
|
|
4347
|
+
}
|
|
3181
4348
|
|
|
4349
|
+
/**
|
|
4350
|
+
*PolygonMarker
|
|
4351
|
+
*
|
|
4352
|
+
* @param {PolygonMarkerProps} PolygonMarkerProps
|
|
4353
|
+
*
|
|
4354
|
+
* @returns {JSX.Element} JSX
|
|
4355
|
+
*/
|
|
3182
4356
|
|
|
4357
|
+
function PolygonMarker(_a) {
|
|
4358
|
+
var children = _a.children,
|
|
4359
|
+
position = _a.position,
|
|
4360
|
+
_b = _a.background,
|
|
4361
|
+
background = _b === void 0 ? 'lightgreen' : _b,
|
|
4362
|
+
innerPositions = _a.innerPositions,
|
|
4363
|
+
_c = _a.simplifyPath,
|
|
4364
|
+
simplifyPath = _c === void 0 ? true : _c,
|
|
4365
|
+
simplifyTolerance = _a.simplifyTolerance,
|
|
4366
|
+
_d = _a.lastReapeated,
|
|
4367
|
+
lastReapeated = _d === void 0 ? false : _d,
|
|
4368
|
+
_e = _a.svgProperties,
|
|
4369
|
+
svgProperties = _e === void 0 ? {} : _e,
|
|
4370
|
+
_f = _a.shapeProperties,
|
|
4371
|
+
shapeProperties = _f === void 0 ? {} : _f,
|
|
4372
|
+
_g = _a.visible,
|
|
4373
|
+
visible = _g === void 0 ? true : _g,
|
|
4374
|
+
zIndex = _a.zIndex,
|
|
4375
|
+
_h = _a.mode,
|
|
4376
|
+
mode = _h === void 0 ? 'POLYGON' : _h; //controller
|
|
4377
|
+
|
|
4378
|
+
var controller = useMintMapController(); //zoom start event
|
|
4379
|
+
|
|
4380
|
+
var onZoomStart = useCallback(function () {
|
|
4381
|
+
setMapVisible(false);
|
|
4382
|
+
}, []); //idle event
|
|
4383
|
+
|
|
4384
|
+
var onIdle = useCallback(function () {
|
|
4385
|
+
var newZoomLevel = controller.getZoomLevel();
|
|
4386
|
+
|
|
4387
|
+
if (zoomLevel.current !== newZoomLevel) {
|
|
4388
|
+
zoomLevel.current = newZoomLevel;
|
|
4389
|
+
renderPolygonBase();
|
|
4390
|
+
setTimeout(function () {
|
|
4391
|
+
setMapVisible(true);
|
|
4392
|
+
});
|
|
4393
|
+
}
|
|
4394
|
+
}, []);
|
|
4395
|
+
var zoomLevel = useRef(controller.getZoomLevel());
|
|
3183
4396
|
useEffect(function () {
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
divElement.addEventListener('mouseover', onMouseOverHandler);
|
|
4397
|
+
controller.addEventListener("ZOOMSTART", onZoomStart);
|
|
4398
|
+
controller.addEventListener("IDLE", onIdle);
|
|
3187
4399
|
return function () {
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
divCloneRef.current.classList.add(endAnimationClassName);
|
|
3193
|
-
|
|
3194
|
-
var aniListener_1 = function () {
|
|
3195
|
-
//console.log('animationend!!!', divCloneRef.current);
|
|
3196
|
-
divCloneRef.current && divCloneRef.current.removeEventListener('animationend', aniListener_1);
|
|
4400
|
+
controller.removeEventListener("ZOOMSTART", onZoomStart);
|
|
4401
|
+
controller.removeEventListener("IDLE", onIdle);
|
|
4402
|
+
};
|
|
4403
|
+
}, []); //center
|
|
3197
4404
|
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
4405
|
+
var _j = useState(),
|
|
4406
|
+
polygonStart = _j[0],
|
|
4407
|
+
setPolygonStart = _j[1]; //offsets
|
|
3201
4408
|
|
|
3202
|
-
divCloneRef.current = undefined;
|
|
3203
|
-
};
|
|
3204
4409
|
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
divElement.removeEventListener('click', onClickHandler);
|
|
3209
|
-
divElement.removeEventListener('mouseover', onMouseOverHandler);
|
|
4410
|
+
var _k = useState([]),
|
|
4411
|
+
offsets = _k[0],
|
|
4412
|
+
setOffsets = _k[1]; //inner offsets
|
|
3210
4413
|
|
|
3211
|
-
if (markerRef.current) {
|
|
3212
|
-
controller.clearDrawable(markerRef.current); // console.log('drawable cleared')
|
|
3213
|
-
}
|
|
3214
|
-
}
|
|
3215
|
-
};
|
|
3216
|
-
}, []); //create / update object
|
|
3217
4414
|
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
//console.log('update Marker')
|
|
3222
|
-
controller.updateMarker(markerRef.current, options); //marker offset 보정
|
|
4415
|
+
var _l = useState([]),
|
|
4416
|
+
innerOffsets = _l[0],
|
|
4417
|
+
setInnerOffsets = _l[1]; //offset cache
|
|
3223
4418
|
|
|
3224
|
-
offsetCalibration(controller.getMapType(), divElement, options); //z-index 처리
|
|
3225
4419
|
|
|
3226
|
-
|
|
3227
|
-
controller.setMarkerZIndex(markerRef.current, options.zIndex);
|
|
3228
|
-
}
|
|
3229
|
-
} else {
|
|
3230
|
-
//console.log('create Marker')
|
|
3231
|
-
markerRef.current = new Marker(options);
|
|
3232
|
-
markerRef.current.element = divElement;
|
|
3233
|
-
controller.createMarker(markerRef.current); //marker offset 보정
|
|
4420
|
+
var offsetCache = useRef(new Map()); //polygon props ref
|
|
3234
4421
|
|
|
3235
|
-
|
|
4422
|
+
var polygonPropsRef = useRef({
|
|
4423
|
+
position: position,
|
|
4424
|
+
innerPositions: innerPositions,
|
|
4425
|
+
simplifyPath: simplifyPath,
|
|
4426
|
+
simplifyTolerance: simplifyTolerance,
|
|
4427
|
+
lastReapeated: lastReapeated
|
|
4428
|
+
}); //polygon 생성 effect
|
|
3236
4429
|
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
4430
|
+
useEffect(function () {
|
|
4431
|
+
// console.log('polygon changed');
|
|
4432
|
+
offsetCache.current.clear();
|
|
4433
|
+
polygonPropsRef.current = {
|
|
4434
|
+
position: position,
|
|
4435
|
+
innerPositions: innerPositions,
|
|
4436
|
+
simplifyPath: simplifyPath,
|
|
4437
|
+
simplifyTolerance: simplifyTolerance,
|
|
4438
|
+
lastReapeated: lastReapeated
|
|
4439
|
+
};
|
|
4440
|
+
renderPolygonBase();
|
|
4441
|
+
}, [position, innerPositions, simplifyPath, simplifyTolerance, lastReapeated]); //render
|
|
3240
4442
|
|
|
4443
|
+
var _m = useState(true),
|
|
4444
|
+
mapVisible = _m[0],
|
|
4445
|
+
setMapVisible = _m[1];
|
|
3241
4446
|
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
4447
|
+
var renderPolygonBase = useCallback(function () {
|
|
4448
|
+
// console.log('renderPolygonBase');
|
|
4449
|
+
var _a = polygonPropsRef.current,
|
|
4450
|
+
position = _a.position,
|
|
4451
|
+
innerPositions = _a.innerPositions,
|
|
4452
|
+
simplifyPath = _a.simplifyPath,
|
|
4453
|
+
simplifyTolerance = _a.simplifyTolerance,
|
|
4454
|
+
lastReapeated = _a.lastReapeated;
|
|
4455
|
+
var prevCache = offsetCache.current.get(zoomLevel.current);
|
|
4456
|
+
|
|
4457
|
+
if (prevCache) {
|
|
4458
|
+
var offsets_1 = [];
|
|
4459
|
+
offsets_1.push.apply(offsets_1, prevCache.offsets);
|
|
4460
|
+
setOffsets(offsets_1);
|
|
4461
|
+
var innerOffsets_1 = [];
|
|
4462
|
+
innerOffsets_1.push.apply(innerOffsets_1, prevCache.innerOffsets);
|
|
4463
|
+
setInnerOffsets(innerOffsets_1);
|
|
4464
|
+
setPolygonStart(prevCache.start);
|
|
4465
|
+
} else {
|
|
4466
|
+
// path
|
|
4467
|
+
var simplified = simplifyPath ? PolygonCalculator.simplifyPoints(position, simplifyTolerance, lastReapeated) : position;
|
|
4468
|
+
var offsets_2 = simplified.map(function (pos) {
|
|
4469
|
+
var off = controller.positionToOffset(pos);
|
|
4470
|
+
return new Offset(Math.floor(off.x), Math.floor(off.y));
|
|
4471
|
+
});
|
|
4472
|
+
setOffsets(offsets_2); //inner path
|
|
3247
4473
|
|
|
4474
|
+
var innerPath = [];
|
|
3248
4475
|
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
4476
|
+
if (innerPositions) {
|
|
4477
|
+
for (var _i = 0, innerPositions_1 = innerPositions; _i < innerPositions_1.length; _i++) {
|
|
4478
|
+
var innerPosition = innerPositions_1[_i];
|
|
4479
|
+
var simplified_1 = simplifyPath ? PolygonCalculator.simplifyPoints(innerPosition, simplifyTolerance, lastReapeated) : innerPosition;
|
|
4480
|
+
var offsets_3 = simplified_1.map(function (pos) {
|
|
4481
|
+
var off = controller.positionToOffset(pos);
|
|
4482
|
+
return new Offset(Math.floor(off.x), Math.floor(off.y));
|
|
4483
|
+
});
|
|
4484
|
+
innerPath.push(offsets_3);
|
|
4485
|
+
}
|
|
3253
4486
|
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
(_a = divElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.classList.add(startAnimationClassName);
|
|
4487
|
+
setInnerOffsets(innerPath);
|
|
4488
|
+
} //start point
|
|
3257
4489
|
|
|
3258
|
-
var aniListener = function () {
|
|
3259
|
-
var _a, _b;
|
|
3260
4490
|
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
4491
|
+
var regionInfo = PolygonCalculator.getRegionInfo(simplified);
|
|
4492
|
+
var startPosition = regionInfo.maxLat && regionInfo.minLng ? new Position(regionInfo.maxLat, regionInfo.minLng) : undefined;
|
|
4493
|
+
setPolygonStart(startPosition); //cache set
|
|
3264
4494
|
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
});
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
4495
|
+
offsetCache.current.set(zoomLevel.current, {
|
|
4496
|
+
start: startPosition,
|
|
4497
|
+
offsets: offsets_2,
|
|
4498
|
+
innerOffsets: innerPath
|
|
4499
|
+
});
|
|
3273
4500
|
}
|
|
3274
|
-
}, [
|
|
3275
|
-
return
|
|
4501
|
+
}, []);
|
|
4502
|
+
return React.createElement(React.Fragment, null, polygonStart && React.createElement(MapMarkerWrapper, {
|
|
4503
|
+
position: polygonStart,
|
|
4504
|
+
visible: visible,
|
|
4505
|
+
disablePointerEvent: true,
|
|
4506
|
+
zIndex: zIndex
|
|
4507
|
+
}, mapVisible && React.createElement(SVGPolygon, {
|
|
4508
|
+
path: offsets,
|
|
4509
|
+
innerPath: innerOffsets,
|
|
4510
|
+
mode: mode,
|
|
4511
|
+
background: background,
|
|
4512
|
+
shapeProperties: shapeProperties,
|
|
4513
|
+
svgProperties: svgProperties
|
|
4514
|
+
}, children)));
|
|
3276
4515
|
}
|
|
3277
4516
|
|
|
3278
4517
|
/**
|
|
@@ -3720,141 +4959,6 @@ function LoadingImage(_a) {
|
|
|
3720
4959
|
}))));
|
|
3721
4960
|
}
|
|
3722
4961
|
|
|
3723
|
-
var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, itemList, sizeFunction) {
|
|
3724
|
-
var _a; //1. basePixelSize 기준으로 현재 지도 크기를 베이스로 영역 갯수 정하기
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
var rowCount = Number((mapWidth / basePixelSize).toFixed(0)) || 1;
|
|
3728
|
-
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1; //console.log('rowCount', rowCount, 'colCount', colCount)
|
|
3729
|
-
|
|
3730
|
-
var boundsLineSizeX = Number(((mapBounds.ne.lng - mapBounds.nw.lng) / rowCount).toFixed(7));
|
|
3731
|
-
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7)); //console.log('boundsLineSize', boundsLineSizeX, boundsLineSizeY)
|
|
3732
|
-
var boundsPos = [];
|
|
3733
|
-
var tempX1, tempY1, tempX2, tempY2;
|
|
3734
|
-
|
|
3735
|
-
for (var i = 0; i < rowCount; i++) {
|
|
3736
|
-
tempX1 = mapBounds.nw.lng + boundsLineSizeX * i;
|
|
3737
|
-
tempX2 = mapBounds.nw.lng + boundsLineSizeX * (i + 1);
|
|
3738
|
-
var rows = [];
|
|
3739
|
-
boundsPos.push(rows);
|
|
3740
|
-
|
|
3741
|
-
for (var k = 0; k < colCount; k++) {
|
|
3742
|
-
tempY2 = mapBounds.se.lat + boundsLineSizeY * k;
|
|
3743
|
-
tempY1 = mapBounds.se.lat + boundsLineSizeY * (k + 1);
|
|
3744
|
-
var thisBounds = Bounds.fromNWSE(new Position(tempY1, tempX1), new Position(tempY2, tempX2));
|
|
3745
|
-
var includedList = thisBounds.getIncludedPositions(itemList);
|
|
3746
|
-
rows.push({
|
|
3747
|
-
bounds: thisBounds,
|
|
3748
|
-
checked: false,
|
|
3749
|
-
center: false,
|
|
3750
|
-
centerPosition: thisBounds.getCenter(),
|
|
3751
|
-
incList: [],
|
|
3752
|
-
itemList: includedList,
|
|
3753
|
-
size: basePixelSize
|
|
3754
|
-
});
|
|
3755
|
-
}
|
|
3756
|
-
} //좌표마다 검사해서 인접셀 병합 처리
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
var centerList = [];
|
|
3760
|
-
var totalItemCount = 0;
|
|
3761
|
-
var min;
|
|
3762
|
-
var max;
|
|
3763
|
-
|
|
3764
|
-
for (var i = 0; i < boundsPos.length; i++) {
|
|
3765
|
-
for (var k = 0; k < boundsPos[i].length; k++) {
|
|
3766
|
-
var curr = boundsPos[i][k];
|
|
3767
|
-
if (curr.checked) continue;
|
|
3768
|
-
curr.checked = true; //현재기준 8방향 객체 모으기
|
|
3769
|
-
|
|
3770
|
-
var incList = [];
|
|
3771
|
-
|
|
3772
|
-
if (boundsPos[i]) {
|
|
3773
|
-
boundsPos[i][k - 1] && incList.push(boundsPos[i][k - 1]);
|
|
3774
|
-
boundsPos[i][k + 1] && incList.push(boundsPos[i][k + 1]);
|
|
3775
|
-
}
|
|
3776
|
-
|
|
3777
|
-
if (boundsPos[i - 1]) {
|
|
3778
|
-
boundsPos[i - 1][k - 1] && incList.push(boundsPos[i - 1][k - 1]);
|
|
3779
|
-
boundsPos[i - 1][k] && incList.push(boundsPos[i - 1][k]);
|
|
3780
|
-
boundsPos[i - 1][k + 1] && incList.push(boundsPos[i - 1][k + 1]);
|
|
3781
|
-
}
|
|
3782
|
-
|
|
3783
|
-
if (boundsPos[i + 1]) {
|
|
3784
|
-
boundsPos[i + 1][k + 1] && incList.push(boundsPos[i + 1][k + 1]);
|
|
3785
|
-
boundsPos[i + 1][k] && incList.push(boundsPos[i + 1][k]);
|
|
3786
|
-
boundsPos[i + 1][k - 1] && incList.push(boundsPos[i + 1][k - 1]);
|
|
3787
|
-
}
|
|
3788
|
-
|
|
3789
|
-
for (var _i = 0, incList_1 = incList; _i < incList_1.length; _i++) {
|
|
3790
|
-
var inc = incList_1[_i];
|
|
3791
|
-
if (inc.checked) continue;
|
|
3792
|
-
inc.checked = true;
|
|
3793
|
-
|
|
3794
|
-
if (inc.itemList && inc.itemList.length > 0) {
|
|
3795
|
-
curr.incList.push(inc);
|
|
3796
|
-
|
|
3797
|
-
(_a = curr.itemList).push.apply(_a, inc.itemList);
|
|
3798
|
-
|
|
3799
|
-
curr.center = true;
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
|
|
3803
|
-
if (curr.center) {
|
|
3804
|
-
centerList.push(curr);
|
|
3805
|
-
var avrLat = calculateAverage(curr.itemList.map(function (item) {
|
|
3806
|
-
return item.lat;
|
|
3807
|
-
}));
|
|
3808
|
-
var avrLng = calculateAverage(curr.itemList.map(function (item) {
|
|
3809
|
-
return item.lng;
|
|
3810
|
-
}));
|
|
3811
|
-
curr.centerPosition = new Position(avrLat, avrLng);
|
|
3812
|
-
totalItemCount += curr.itemList.length;
|
|
3813
|
-
|
|
3814
|
-
if (!min || curr.itemList.length < min) {
|
|
3815
|
-
min = curr.itemList.length;
|
|
3816
|
-
}
|
|
3817
|
-
|
|
3818
|
-
if (!max || curr.itemList.length > max) {
|
|
3819
|
-
max = curr.itemList.length;
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
}
|
|
3823
|
-
}
|
|
3824
|
-
|
|
3825
|
-
var status = {
|
|
3826
|
-
total: totalItemCount,
|
|
3827
|
-
average: totalItemCount / centerList.length,
|
|
3828
|
-
min: min,
|
|
3829
|
-
max: max
|
|
3830
|
-
};
|
|
3831
|
-
|
|
3832
|
-
sizeFunction = sizeFunction || function (info, status) {
|
|
3833
|
-
var minSize = basePixelSize / 4;
|
|
3834
|
-
var maxSize = basePixelSize;
|
|
3835
|
-
return Math.min(Math.max(basePixelSize * info.itemList.length / status.average, minSize), maxSize);
|
|
3836
|
-
};
|
|
3837
|
-
|
|
3838
|
-
for (var _b = 0, centerList_1 = centerList; _b < centerList_1.length; _b++) {
|
|
3839
|
-
var center = centerList_1[_b];
|
|
3840
|
-
center.size = sizeFunction(center, status);
|
|
3841
|
-
} // console.log('centerList', centerList, status);
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
return centerList;
|
|
3845
|
-
};
|
|
3846
|
-
|
|
3847
|
-
var calculateAverage = function (nums) {
|
|
3848
|
-
var sum = 0;
|
|
3849
|
-
|
|
3850
|
-
for (var _i = 0, nums_1 = nums; _i < nums_1.length; _i++) {
|
|
3851
|
-
var num = nums_1[_i];
|
|
3852
|
-
sum += num;
|
|
3853
|
-
}
|
|
3854
|
-
|
|
3855
|
-
return Number((sum / nums.length).toFixed(7));
|
|
3856
|
-
};
|
|
3857
|
-
|
|
3858
4962
|
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}";
|
|
3859
4963
|
var styles = {"mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
|
|
3860
4964
|
styleInject(css_248z);
|
|
@@ -4314,4 +5418,4 @@ function MapCanvasMarkerWrapper(_props) {
|
|
|
4314
5418
|
return React.createElement(React.Fragment, null);
|
|
4315
5419
|
}
|
|
4316
5420
|
|
|
4317
|
-
export { AnimationPlayer, Bounds, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapCanvasMarkerWrapper, MapCanvasWrapper, MapControlWrapper, MapLoadingWithImage, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, Marker, MintMap, MintMapCanvasRenderer, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, PointLoading, Polygon, PolygonCalculator, Polyline, Position, getClusterInfo, useMarkerMoving, useMintMapController, waiting };
|
|
5421
|
+
export { AnimationPlayer, Bounds, CircleMarker, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapCanvasMarkerWrapper, MapCanvasWrapper, MapControlWrapper, MapEvent, MapLoadingWithImage, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, MapUIEvent, Marker, MintMap, MintMapCanvasRenderer, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, PointLoading, Polygon, PolygonCalculator, PolygonMarker, Polyline, Position, SVGCircle, SVGPolygon, SVGRect, getClusterInfo, useMarkerMoving, useMintMapController, waiting };
|