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