@mint-ui/map 0.3.5-beta → 0.3.7-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/index.umd.js CHANGED
@@ -43,7 +43,8 @@
43
43
  var onLoad = _a.onLoad,
44
44
  _b = _a.visible,
45
45
  visible = _b === void 0 ? true : _b,
46
- base = _a.base,
46
+ zoomLevel = _a.zoomLevel,
47
+ center = _a.center,
47
48
  children = _a.children;
48
49
  var controller = useMintMapController();
49
50
  var elementRef = React.useRef(null);
@@ -82,21 +83,30 @@
82
83
  };
83
84
  }, [controller, elementRef]);
84
85
  React.useEffect(function () {
85
- if ((base === null || base === void 0 ? void 0 : base.zoomLevel) && controller && mapInitialized) {
86
+ if (zoomLevel && controller && mapInitialized) {
86
87
  var prevZoomLevel = controller === null || controller === void 0 ? void 0 : controller.getZoomLevel();
87
88
 
88
- if (prevZoomLevel !== base.zoomLevel) {
89
- controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(base.zoomLevel);
89
+ if (prevZoomLevel !== zoomLevel) {
90
+ controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(zoomLevel);
90
91
  }
91
92
  }
92
- }, [base]);
93
- return React__default["default"].createElement("div", {
94
- className: cn$2('mint-map-root'),
95
- style: {
96
- visibility: visible ? 'inherit' : 'hidden'
93
+ }, [zoomLevel]);
94
+ React.useEffect(function () {
95
+ if (center && controller && mapInitialized) {
96
+ var prevCenter = controller.getCenter();
97
+
98
+ if (!Position.equals(prevCenter, center)) {
99
+ controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
100
+ }
97
101
  }
102
+ }, [center]);
103
+ return React__default["default"].createElement("div", {
104
+ className: cn$2('mint-map-root')
98
105
  }, mapInitialized && children, React__default["default"].createElement("div", {
99
106
  className: cn$2('mint-map-container'),
107
+ style: {
108
+ visibility: visible ? 'inherit' : 'hidden'
109
+ },
100
110
  ref: elementRef
101
111
  }));
102
112
  }
@@ -381,9 +391,225 @@
381
391
  }
382
392
  };
383
393
 
394
+ MintMapController.prototype.getBaseToMapZoom = function (zoomBase) {
395
+ var baseMap = MapZoomInfo.BASE_TO_MAP.get(zoomBase);
396
+
397
+ if (baseMap) {
398
+ var mapZoomInfo = baseMap.get(this.getMapType());
399
+
400
+ if (mapZoomInfo) {
401
+ return mapZoomInfo.level;
402
+ }
403
+ }
404
+
405
+ throw new Error("[getBaseToMapZoom][".concat(zoomBase, "] is not valid zoom level"));
406
+ };
407
+
408
+ MintMapController.prototype.getMapToBaseZoom = function (mapZoom) {
409
+ var baseZoom = MapZoomInfo.MAP_TO_BASE.get(this.getMapType() + mapZoom);
410
+
411
+ if (baseZoom) {
412
+ return baseZoom;
413
+ }
414
+
415
+ throw new Error("[getMapToBaseZoom][".concat(mapZoom, "] is not valid zoom level"));
416
+ };
417
+
384
418
  return MintMapController;
385
419
  }();
386
420
 
421
+ var MapZoomInfo = function () {
422
+ function MapZoomInfo() {}
423
+
424
+ MapZoomInfo.BASE_TO_MAP = new Map([[1, new Map([['google', {
425
+ level: 1
426
+ }], ['naver', {
427
+ level: 6
428
+ }], ['kakao', {
429
+ level: 14
430
+ }]])], [2, new Map([['google', {
431
+ level: 2,
432
+ distance: 2000,
433
+ unit: 'km'
434
+ }], ['naver', {
435
+ level: 6
436
+ }], ['kakao', {
437
+ level: 14
438
+ }]])], [3, new Map([['google', {
439
+ level: 3,
440
+ distance: 1000,
441
+ unit: 'km'
442
+ }], ['naver', {
443
+ level: 6
444
+ }], ['kakao', {
445
+ level: 14
446
+ }]])], [4, new Map([['google', {
447
+ level: 4,
448
+ distance: 500,
449
+ unit: 'km'
450
+ }], ['naver', {
451
+ level: 6
452
+ }], ['kakao', {
453
+ level: 14
454
+ }]])], [5, new Map([['google', {
455
+ level: 5,
456
+ distance: 200,
457
+ unit: 'km'
458
+ }], ['naver', {
459
+ level: 6
460
+ }], ['kakao', {
461
+ level: 14
462
+ }]])], [6, new Map([['google', {
463
+ level: 6,
464
+ distance: 100,
465
+ unit: 'km'
466
+ }], ['naver', {
467
+ level: 6
468
+ }], ['kakao', {
469
+ level: 14
470
+ }]])], [7, new Map([['google', {
471
+ level: 7,
472
+ distance: 50,
473
+ unit: 'km'
474
+ }], ['naver', {
475
+ level: 7
476
+ }], ['kakao', {
477
+ level: 13
478
+ }]])], [8, new Map([['google', {
479
+ level: 8,
480
+ distance: 20,
481
+ unit: 'km'
482
+ }], ['naver', {
483
+ level: 8
484
+ }], ['kakao', {
485
+ level: 12
486
+ }]])], [9, new Map([['google', {
487
+ level: 9,
488
+ distance: 10,
489
+ unit: 'km'
490
+ }], ['naver', {
491
+ level: 9
492
+ }], ['kakao', {
493
+ level: 11
494
+ }]])], [10, new Map([['google', {
495
+ level: 10,
496
+ distance: 5,
497
+ unit: 'km'
498
+ }], ['naver', {
499
+ level: 10
500
+ }], ['kakao', {
501
+ level: 10
502
+ }]])], [11, new Map([['google', {
503
+ level: 11,
504
+ distance: 2,
505
+ unit: 'km'
506
+ }], ['naver', {
507
+ level: 11
508
+ }], ['kakao', {
509
+ level: 9
510
+ }]])], [12, new Map([['google', {
511
+ level: 12,
512
+ distance: 1,
513
+ unit: 'km'
514
+ }], ['naver', {
515
+ level: 12
516
+ }], ['kakao', {
517
+ level: 8
518
+ }]])], [13, new Map([['google', {
519
+ level: 13,
520
+ distance: 500,
521
+ unit: 'm'
522
+ }], ['naver', {
523
+ level: 13
524
+ }], ['kakao', {
525
+ level: 7
526
+ }]])], [14, new Map([['google', {
527
+ level: 14,
528
+ distance: 500,
529
+ unit: 'm'
530
+ }], ['naver', {
531
+ level: 14
532
+ }], ['kakao', {
533
+ level: 6
534
+ }]])], [15, new Map([['google', {
535
+ level: 15,
536
+ distance: 500,
537
+ unit: 'm'
538
+ }], ['naver', {
539
+ level: 15
540
+ }], ['kakao', {
541
+ level: 5
542
+ }]])], [16, new Map([['google', {
543
+ level: 16,
544
+ distance: 500,
545
+ unit: 'm'
546
+ }], ['naver', {
547
+ level: 16
548
+ }], ['kakao', {
549
+ level: 4
550
+ }]])], [17, new Map([['google', {
551
+ level: 17,
552
+ distance: 500,
553
+ unit: 'm'
554
+ }], ['naver', {
555
+ level: 17
556
+ }], ['kakao', {
557
+ level: 3
558
+ }]])], [18, new Map([['google', {
559
+ level: 18,
560
+ distance: 500,
561
+ unit: 'm'
562
+ }], ['naver', {
563
+ level: 18
564
+ }], ['kakao', {
565
+ level: 2
566
+ }]])], [19, new Map([['google', {
567
+ level: 19,
568
+ distance: 500,
569
+ unit: 'm'
570
+ }], ['naver', {
571
+ level: 19
572
+ }], ['kakao', {
573
+ level: 1
574
+ }]])], [20, new Map([['google', {
575
+ level: 20,
576
+ distance: 500,
577
+ unit: 'm'
578
+ }], ['naver', {
579
+ level: 20
580
+ }], ['kakao', {
581
+ level: 1
582
+ }]])], [21, new Map([['google', {
583
+ level: 21,
584
+ distance: 500,
585
+ unit: 'm'
586
+ }], ['naver', {
587
+ level: 21
588
+ }], ['kakao', {
589
+ level: 1
590
+ }]])], [22, new Map([['google', {
591
+ level: 22,
592
+ distance: 500,
593
+ unit: 'm'
594
+ }], ['naver', {
595
+ level: 21
596
+ }], ['kakao', {
597
+ level: 1
598
+ }]])]]);
599
+ MapZoomInfo.MAP_TO_BASE = new Map(tslib.__spreadArray([], Array.from(MapZoomInfo.BASE_TO_MAP.entries()).map(function (item) {
600
+ var base = item[0];
601
+ var mapZoom = item[1];
602
+ var result = [];
603
+ mapZoom.forEach(function (value, key) {
604
+ result.push([key + value.level, base]);
605
+ });
606
+ return result;
607
+ }).flatMap(function (a) {
608
+ return a;
609
+ }), true));
610
+ return MapZoomInfo;
611
+ }();
612
+
387
613
  function waiting(evaluation, timeoutSeconds) {
388
614
  return tslib.__awaiter(this, void 0, void 0, function () {
389
615
  var max;
@@ -796,6 +1022,9 @@
796
1022
  options = {
797
1023
  center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
798
1024
  zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
1025
+ draggable: this.mapProps.draggable === false ? false : true,
1026
+ scrollWheel: this.mapProps.draggable === false ? false : true,
1027
+ keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
799
1028
  logoControl: false,
800
1029
  mapDataControl: false,
801
1030
  mapTypeControl: false,
@@ -917,6 +1146,16 @@
917
1146
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom, true);
918
1147
  };
919
1148
 
1149
+ NaverMintMapController.prototype.getCenter = function () {
1150
+ return this.getCurrBounds().getCenter();
1151
+ };
1152
+
1153
+ NaverMintMapController.prototype.setCenter = function (position) {
1154
+ var _a;
1155
+
1156
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
1157
+ };
1158
+
920
1159
  return NaverMintMapController;
921
1160
  }(MintMapController);
922
1161
 
@@ -1309,7 +1548,8 @@
1309
1548
  minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
1310
1549
  zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
1311
1550
  disableDefaultUI: true,
1312
- gestureHandling: 'greedy',
1551
+ gestureHandling: this.mapProps.draggable === false ? 'none' : 'greedy',
1552
+ keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
1313
1553
  clickableIcons: false
1314
1554
  });
1315
1555
  this.map = map;
@@ -1381,9 +1621,522 @@
1381
1621
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
1382
1622
  };
1383
1623
 
1624
+ GoogleMintMapController.prototype.getCenter = function () {
1625
+ return this.getCurrBounds().getCenter();
1626
+ };
1627
+
1628
+ GoogleMintMapController.prototype.setCenter = function (position) {
1629
+ var _a;
1630
+
1631
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
1632
+ };
1633
+
1384
1634
  return GoogleMintMapController;
1385
1635
  }(MintMapController);
1386
1636
 
1637
+ var KakaoMintMapController = function (_super) {
1638
+ tslib.__extends(KakaoMintMapController, _super);
1639
+
1640
+ function KakaoMintMapController(props) {
1641
+ var _this = _super.call(this, props) || this;
1642
+
1643
+ _this.type = 'kakao';
1644
+ _this.map = null;
1645
+ _this.scriptUrl = 'https://dapi.kakao.com/v2/maps/sdk.js';
1646
+ _this.scriptModules = ['services', 'clusterer'];
1647
+ _this.polylineEvents = ['mouseover', 'mouseout'];
1648
+ _this.polygonEvents = ['mouseover', 'mouseout'];
1649
+ _this.markerEvents = ['click', 'mouseover', 'mouseout'];
1650
+ _this.dragStartPoint = [0, 0];
1651
+ _this.dragged = false;
1652
+ console.log("".concat(_this.type, " controller loadded"));
1653
+ return _this;
1654
+ }
1655
+
1656
+ KakaoMintMapController.prototype.initMarkerPool = function () {
1657
+ var _this = this;
1658
+
1659
+ if (!this.mapProps.markerCache) return;
1660
+ this.markerPool = new tools.ObjectPool().setFactory(function () {
1661
+ return new kakao.maps.CustomOverlay({
1662
+ position: _this.positionToLatLng(new Position(0, 0)),
1663
+ map: _this.map || undefined
1664
+ });
1665
+ }).setClear(function (item) {
1666
+ item.setMap(null);
1667
+ }).createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000).setCheckLiveTimeInterval(1000);
1668
+ };
1669
+
1670
+ KakaoMintMapController.prototype.createPolyline = function (polyline) {
1671
+ var _this = this;
1672
+
1673
+ var _a = polyline.options,
1674
+ position = _a.position,
1675
+ _b = _a.lineColor,
1676
+ lineColor = _b === void 0 ? 'blue' : _b,
1677
+ _c = _a.lineSize,
1678
+ lineSize = _c === void 0 ? 1 : _c,
1679
+ _d = _a.lineOpacity,
1680
+ lineOpacity = _d === void 0 ? 1 : _d;
1681
+ _a.visible;
1682
+ _a.editable;
1683
+ var event = _a.event;
1684
+
1685
+ if (this.map && Array.isArray(position)) {
1686
+ var path = position.map(function (elem) {
1687
+ return _this.positionToLatLng(Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem);
1688
+ });
1689
+ var pol_1 = new kakao.maps.Polyline({
1690
+ map: this.map,
1691
+ path: path,
1692
+ strokeColor: lineColor,
1693
+ strokeWeight: lineSize,
1694
+ strokeOpacity: lineOpacity
1695
+ });
1696
+ polyline.native = pol_1;
1697
+ event && event.forEach(function (handler, key) {
1698
+ if (_this.polylineEvents.includes(key)) {
1699
+ kakao.maps.event.addListener(pol_1, key, handler);
1700
+ }
1701
+ });
1702
+ }
1703
+ };
1704
+
1705
+ KakaoMintMapController.prototype.updatePolyline = function (polyline, options) {
1706
+ var _this = this;
1707
+
1708
+ if (polyline && polyline.native && polyline.native instanceof kakao.maps.Polyline) {
1709
+ var path = void 0;
1710
+
1711
+ if (Array.isArray(options.position)) {
1712
+ path = options.position.map(function (elem) {
1713
+ return _this.positionToLatLng(Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem);
1714
+ });
1715
+ }
1716
+
1717
+ polyline.native.setOptions({
1718
+ path: path || polyline.native.getPath(),
1719
+ strokeColor: options.lineColor,
1720
+ strokeWeight: options.lineSize,
1721
+ strokeOpacity: options.lineOpacity
1722
+ });
1723
+ }
1724
+ };
1725
+
1726
+ KakaoMintMapController.prototype.createPolygon = function (polygon) {
1727
+ var _this = this;
1728
+
1729
+ var _a = polygon.options,
1730
+ position = _a.position,
1731
+ innerPositions = _a.innerPositions,
1732
+ _b = _a.lineColor,
1733
+ lineColor = _b === void 0 ? 'green' : _b,
1734
+ _c = _a.lineSize,
1735
+ lineSize = _c === void 0 ? 1 : _c,
1736
+ _d = _a.lineOpacity,
1737
+ lineOpacity = _d === void 0 ? 1 : _d,
1738
+ _e = _a.fillColor,
1739
+ fillColor = _e === void 0 ? 'lightgreen' : _e,
1740
+ _f = _a.fillOpacity,
1741
+ fillOpacity = _f === void 0 ? 0.5 : _f;
1742
+ _a.visible;
1743
+ _a.editable;
1744
+ var event = _a.event;
1745
+
1746
+ if (this.map && Array.isArray(position)) {
1747
+ var outLine = position.map(function (elem) {
1748
+ return _this.positionToLatLng(Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem);
1749
+ });
1750
+ var path = [outLine];
1751
+ innerPositions && path.push(innerPositions.map(function (inner) {
1752
+ return _this.positionToLatLng(inner);
1753
+ }));
1754
+ var pol_2 = new kakao.maps.Polygon({
1755
+ map: this.map,
1756
+ path: path,
1757
+ strokeColor: lineColor,
1758
+ strokeWeight: lineSize,
1759
+ strokeOpacity: lineOpacity,
1760
+ fillColor: fillColor,
1761
+ fillOpacity: fillOpacity
1762
+ });
1763
+ polygon.native = pol_2;
1764
+ event && event.forEach(function (handler, key) {
1765
+ if (_this.polygonEvents.includes(key)) {
1766
+ kakao.maps.event.addListener(pol_2, key, handler);
1767
+ }
1768
+ });
1769
+ }
1770
+ };
1771
+
1772
+ KakaoMintMapController.prototype.updatePolygon = function (polygon, options) {
1773
+ var _this = this;
1774
+
1775
+ if (polygon && polygon.native && polygon.native instanceof kakao.maps.Polygon) {
1776
+ var paths = void 0;
1777
+
1778
+ if (Array.isArray(options.position)) {
1779
+ var outLine = options.position.map(function (elem) {
1780
+ return _this.positionToLatLng(Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem);
1781
+ });
1782
+ paths = [outLine];
1783
+ options.innerPositions && paths.push.apply(paths, options.innerPositions.map(function (inner) {
1784
+ return _this.positionToLatLng(inner);
1785
+ }));
1786
+ }
1787
+
1788
+ polygon.native.setOptions({
1789
+ path: paths || polygon.native.getPath(),
1790
+ strokeColor: options.lineColor,
1791
+ strokeWeight: options.lineSize,
1792
+ strokeOpacity: options.lineOpacity,
1793
+ fillColor: options.fillColor,
1794
+ fillOpacity: options.fillOpacity
1795
+ });
1796
+ }
1797
+ };
1798
+
1799
+ KakaoMintMapController.prototype.createMarker = function (marker) {
1800
+ var _this = this;
1801
+
1802
+ var _a;
1803
+
1804
+ if (this.map) {
1805
+ var options = {
1806
+ map: this.map,
1807
+ position: this.positionToLatLng(marker.options.position)
1808
+ };
1809
+ marker.element && (options.content = marker.element);
1810
+ var kakaoMarker_1;
1811
+
1812
+ if (this.mapProps.markerCache && this.markerPool) {
1813
+ kakaoMarker_1 = this.markerPool.getPoolItem();
1814
+ kakaoMarker_1.setVisible(true);
1815
+ options.content && kakaoMarker_1.setContent(options.content);
1816
+ marker.native = kakaoMarker_1;
1817
+ this.updateMarker(marker, marker.options);
1818
+ } else {
1819
+ kakaoMarker_1 = new kakao.maps.CustomOverlay(options);
1820
+ marker.options.visible !== undefined && kakaoMarker_1.setVisible(marker.options.visible);
1821
+ marker.native = kakaoMarker_1;
1822
+ }
1823
+
1824
+ ((_a = marker.options) === null || _a === void 0 ? void 0 : _a.event) && marker.options.event.forEach(function (handler, key) {
1825
+ if (_this.markerEvents.includes(key)) {
1826
+ kakao.maps.event.addListener(kakaoMarker_1, key, handler);
1827
+ }
1828
+ });
1829
+ }
1830
+ };
1831
+
1832
+ KakaoMintMapController.prototype.updateMarker = function (marker, options) {
1833
+ if (marker && marker.native && marker.native instanceof kakao.maps.CustomOverlay) {
1834
+ var map = marker.native.getMap();
1835
+
1836
+ if (map) {
1837
+ if (options.position && options.position instanceof Position) {
1838
+ marker.native.setPosition(this.positionToLatLng(options.position));
1839
+ }
1840
+
1841
+ if (options.visible !== undefined) {
1842
+ marker.native.setVisible(options.visible);
1843
+ }
1844
+ }
1845
+ }
1846
+ };
1847
+
1848
+ KakaoMintMapController.prototype.getMaxZIndex = function (increment, parent) {
1849
+ if (increment === void 0) {
1850
+ increment = 0;
1851
+ }
1852
+
1853
+ if (this.map) {
1854
+ var targetPane = parent;
1855
+ var max = 0;
1856
+
1857
+ for (var i = 0; i < targetPane.childElementCount; i++) {
1858
+ var elem = targetPane.children[i];
1859
+
1860
+ if (elem instanceof HTMLElement) {
1861
+ var index = Number(elem.style.zIndex);
1862
+
1863
+ if (!isNaN(index) && index > max) {
1864
+ max = index;
1865
+ }
1866
+ }
1867
+ }
1868
+
1869
+ this.markerMaxZIndex = max + increment;
1870
+ return this.markerMaxZIndex;
1871
+ } else {
1872
+ return this.markerMaxZIndex || 1;
1873
+ }
1874
+ };
1875
+
1876
+ KakaoMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
1877
+ if (this.map && marker.element && marker.element instanceof HTMLElement) {
1878
+ var parent_1 = marker.element.parentElement;
1879
+
1880
+ if (parent_1) {
1881
+ parent_1.style.zIndex = String(zIndex);
1882
+ }
1883
+ }
1884
+ };
1885
+
1886
+ KakaoMintMapController.prototype.markerToTheTop = function (marker) {
1887
+ if (this.map && marker.element && marker.element instanceof HTMLElement) {
1888
+ var parent_2 = marker.element.parentElement;
1889
+
1890
+ if (parent_2) {
1891
+ this.setMarkerZIndex(marker, this.getMaxZIndex(1, parent_2));
1892
+ }
1893
+ }
1894
+ };
1895
+
1896
+ KakaoMintMapController.prototype.clearDrawable = function (drawable) {
1897
+ var _this = this;
1898
+
1899
+ var _a, _b;
1900
+
1901
+ if (drawable && drawable.native && (drawable.native instanceof kakao.maps.CustomOverlay || drawable.native instanceof kakao.maps.Polyline || drawable.native instanceof kakao.maps.Polygon)) {
1902
+ if (drawable.native instanceof kakao.maps.CustomOverlay) {
1903
+ if (this.mapProps.markerCache && this.markerPool) {
1904
+ drawable.native.setVisible(false);
1905
+ (_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.releasePoolItem(drawable.native);
1906
+ } else {
1907
+ drawable.native.setMap(null);
1908
+ }
1909
+ } else {
1910
+ drawable.native.setMap(null);
1911
+ }
1912
+
1913
+ ((_b = drawable.options) === null || _b === void 0 ? void 0 : _b.event) && drawable.options.event.forEach(function (handler, key) {
1914
+ if (_this.markerEvents.includes(key)) {
1915
+ kakao.maps.event.removeListener(drawable.native, key, handler);
1916
+ }
1917
+ });
1918
+ return true;
1919
+ }
1920
+
1921
+ return false;
1922
+ };
1923
+
1924
+ KakaoMintMapController.prototype.isMapDragged = function () {
1925
+ return this.dragged;
1926
+ };
1927
+
1928
+ KakaoMintMapController.prototype.setMapDragged = function (value) {
1929
+ this.dragged = false;
1930
+ };
1931
+
1932
+ KakaoMintMapController.prototype.loadMapApi = function () {
1933
+ return tslib.__awaiter(this, void 0, void 0, function () {
1934
+ var _this = this;
1935
+
1936
+ return tslib.__generator(this, function (_a) {
1937
+ return [2, new Promise(function (resolve) {
1938
+ return tslib.__awaiter(_this, void 0, void 0, function () {
1939
+ var params, ok;
1940
+ return tslib.__generator(this, function (_a) {
1941
+ switch (_a.label) {
1942
+ case 0:
1943
+ params = {
1944
+ appkey: this.mapProps.mapKey,
1945
+ libraries: this.scriptModules.join(','),
1946
+ autoload: false
1947
+ };
1948
+ return [4, this.loadScript(this.buildUrl(this.scriptUrl, params), 'kakaoscript')];
1949
+
1950
+ case 1:
1951
+ _a.sent();
1952
+
1953
+ window.kakao.maps.load();
1954
+ return [4, waiting(function () {
1955
+ return window.kakao.maps.Map ? true : false;
1956
+ })];
1957
+
1958
+ case 2:
1959
+ ok = _a.sent();
1960
+
1961
+ if (!ok) {
1962
+ throw new Error('kakao script api load failed!!');
1963
+ }
1964
+
1965
+ this.mapApiLoaded = true;
1966
+ resolve(true);
1967
+ console.log("".concat(this.type, " map script loaded"));
1968
+ return [2];
1969
+ }
1970
+ });
1971
+ });
1972
+ })];
1973
+ });
1974
+ });
1975
+ };
1976
+
1977
+ KakaoMintMapController.prototype.initializingMap = function (divElement) {
1978
+ return tslib.__awaiter(this, void 0, void 0, function () {
1979
+ var _this = this;
1980
+
1981
+ return tslib.__generator(this, function (_a) {
1982
+ return [2, new Promise(function (resolve) {
1983
+ return tslib.__awaiter(_this, void 0, void 0, function () {
1984
+ var options, maxZoom, minZoom, map;
1985
+
1986
+ var _this = this;
1987
+
1988
+ var _a, _b, _c, _d;
1989
+
1990
+ return tslib.__generator(this, function (_e) {
1991
+ switch (_e.label) {
1992
+ case 0:
1993
+ if (this.mapInitialized && this.map) {
1994
+ if (this.map.getElement() === divElement) {
1995
+ resolve(this.map);
1996
+ return [2];
1997
+ } else {
1998
+ this.map.destroy();
1999
+ }
2000
+ }
2001
+
2002
+ if (!!this.mapApiLoaded) return [3, 2];
2003
+ return [4, this.loadMapApi()];
2004
+
2005
+ case 1:
2006
+ _e.sent();
2007
+
2008
+ _e.label = 2;
2009
+
2010
+ case 2:
2011
+ options = {
2012
+ center: this.positionToLatLng((_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center),
2013
+ level: this.getBaseToMapZoom((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel),
2014
+ draggable: this.mapProps.draggable === false ? false : true,
2015
+ scrollWheel: this.mapProps.draggable === false ? false : true,
2016
+ keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true
2017
+ };
2018
+ maxZoom = 1;
2019
+ minZoom = 14;
2020
+
2021
+ if ((_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.maxZoomLevel) {
2022
+ maxZoom = this.getSafeZoomValue(this.mapProps.base.maxZoomLevel);
2023
+ }
2024
+
2025
+ if ((_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.minZoomLevel) {
2026
+ minZoom = this.getSafeZoomValue(this.mapProps.base.minZoomLevel);
2027
+ }
2028
+
2029
+ if (minZoom < maxZoom) {
2030
+ minZoom = 14;
2031
+ }
2032
+
2033
+ map = new kakao.maps.Map(divElement, options);
2034
+ map.setMaxLevel(minZoom);
2035
+ map.setMinLevel(maxZoom);
2036
+ this.map = map;
2037
+ map.addListener('idle', function (e) {
2038
+ _this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
2039
+ });
2040
+ map.addListener('zoom_changed', function () {
2041
+ _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.getZoomLevel());
2042
+ });
2043
+ map.addListener('click', function (e) {
2044
+ if (!_this.mapProps.onClick) return;
2045
+ var pos = new Position(e.latLng.getLat(), e.latLng.getLng());
2046
+ pos.offset = new Offset(e.point.x, e.point.y);
2047
+
2048
+ _this.mapProps.onClick(pos);
2049
+ });
2050
+ map.addListener('mousemove', function (e) {
2051
+ if (!_this.mapProps.onMouseMove) return;
2052
+ var pos = new Position(e.latLng.getLat(), e.latLng.getLng());
2053
+ pos.offset = new Offset(e.point.x, e.point.y);
2054
+
2055
+ _this.mapProps.onMouseMove(pos);
2056
+ });
2057
+ this.mapInitialized = true;
2058
+ this.initMarkerPool();
2059
+ console.log("".concat(this.type, " map script initialized"), divElement);
2060
+ resolve(map);
2061
+ return [2];
2062
+ }
2063
+ });
2064
+ });
2065
+ })];
2066
+ });
2067
+ });
2068
+ };
2069
+
2070
+ KakaoMintMapController.prototype.getSafeZoomValue = function (value) {
2071
+ var mapValue = this.getBaseToMapZoom(value);
2072
+
2073
+ if (mapValue > 14) {
2074
+ return 14;
2075
+ } else if (mapValue < 1) {
2076
+ return 1;
2077
+ }
2078
+
2079
+ return mapValue;
2080
+ };
2081
+
2082
+ KakaoMintMapController.prototype.destroyMap = function () {
2083
+ var _a;
2084
+
2085
+ try {
2086
+ (_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
2087
+ } catch (e) {
2088
+ console.log('kakao map destroy error', e);
2089
+ }
2090
+
2091
+ console.log("".concat(this.type, " map destroyed"));
2092
+ };
2093
+
2094
+ KakaoMintMapController.prototype.getCurrBounds = function () {
2095
+ if (!this.map) {
2096
+ throw new Error('Map is not initialized!!');
2097
+ }
2098
+
2099
+ var bounds = this.map.getBounds();
2100
+ return Bounds.fromNESW(this.latLngToPosition(bounds.getNorthEast()), this.latLngToPosition(bounds.getSouthWest()));
2101
+ };
2102
+
2103
+ KakaoMintMapController.prototype.panningTo = function (targetCenter) {
2104
+ var _a;
2105
+
2106
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.panTo(this.positionToLatLng(targetCenter));
2107
+ };
2108
+
2109
+ KakaoMintMapController.prototype.getZoomLevel = function () {
2110
+ return this.map ? this.getMapToBaseZoom(this.map.getLevel()) : 13;
2111
+ };
2112
+
2113
+ KakaoMintMapController.prototype.setZoomLevel = function (zoom) {
2114
+ var _a;
2115
+
2116
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setLevel(this.getBaseToMapZoom(zoom));
2117
+ };
2118
+
2119
+ KakaoMintMapController.prototype.getCenter = function () {
2120
+ return this.getCurrBounds().getCenter();
2121
+ };
2122
+
2123
+ KakaoMintMapController.prototype.setCenter = function (position) {
2124
+ var _a;
2125
+
2126
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(this.positionToLatLng(position));
2127
+ };
2128
+
2129
+ KakaoMintMapController.prototype.positionToLatLng = function (pos) {
2130
+ return pos ? new kakao.maps.LatLng(pos.lat, pos.lng) : undefined;
2131
+ };
2132
+
2133
+ KakaoMintMapController.prototype.latLngToPosition = function (latLng) {
2134
+ return latLng ? new Position(latLng.getLat(), latLng.getLng()) : undefined;
2135
+ };
2136
+
2137
+ return KakaoMintMapController;
2138
+ }(MintMapController);
2139
+
1387
2140
  var Position = function () {
1388
2141
  function Position(lat, lng) {
1389
2142
  this.lat = 0;
@@ -1392,6 +2145,10 @@
1392
2145
  this.lng = lng;
1393
2146
  }
1394
2147
 
2148
+ Position.equals = function (pos1, pos2) {
2149
+ return pos1.lat === pos2.lat && pos1.lng === pos2.lng;
2150
+ };
2151
+
1395
2152
  return Position;
1396
2153
  }();
1397
2154
 
@@ -1556,19 +2313,25 @@
1556
2313
  lng: 127.0448698
1557
2314
  };
1558
2315
  function MintMap(_a) {
1559
- var mapType = _a.mapType,
2316
+ var mapLoadingComponent = _a.mapLoadingComponent,
2317
+ mapType = _a.mapType,
1560
2318
  children = _a.children,
1561
2319
  _b = _a.base,
1562
2320
  base = _b === void 0 ? {
1563
2321
  center: DEFAULT_CENTER,
1564
2322
  zoomLevel: 12
1565
2323
  } : _b,
1566
- props = tslib.__rest(_a, ["mapType", "children", "base"]);
2324
+ props = tslib.__rest(_a, ["mapLoadingComponent", "mapType", "children", "base"]);
1567
2325
 
1568
2326
  var _c = React.useState(),
1569
2327
  controller = _c[0],
1570
2328
  setController = _c[1];
1571
2329
 
2330
+ var loading = React.useMemo(function () {
2331
+ return mapLoadingComponent ? mapLoadingComponent() : React__default["default"].createElement(PointLoading, {
2332
+ text: "Loading"
2333
+ });
2334
+ }, [mapLoadingComponent]);
1572
2335
  React.useEffect(function () {
1573
2336
  if (mapType && mapType.length > 0) {
1574
2337
  setController(undefined);
@@ -1580,6 +2343,10 @@
1580
2343
  mapType: mapType
1581
2344
  }, props), {
1582
2345
  base: base
2346
+ })) : mapType === 'kakao' ? new KakaoMintMapController(tslib.__assign(tslib.__assign({
2347
+ mapType: mapType
2348
+ }, props), {
2349
+ base: base
1583
2350
  })) : null;
1584
2351
 
1585
2352
  if (newController_1) {
@@ -1599,9 +2366,7 @@
1599
2366
  mapType: mapType
1600
2367
  }, props, {
1601
2368
  base: base
1602
- }), children)) : React__default["default"].createElement(PointLoading, {
1603
- text: "Loading"
1604
- }));
2369
+ }), children)) : React__default["default"].createElement(React__default["default"].Fragment, null, loading));
1605
2370
  }
1606
2371
 
1607
2372
  function PointLoading(_a) {
@@ -1851,6 +2616,8 @@
1851
2616
  var offsetCalibration = function (mapType, divElement, options) {
1852
2617
  if (mapType === 'google') {
1853
2618
  divElement.style.transform = "translate(50%, 100%) translate(-".concat(options.anchor ? options.anchor.x : '0', "px, -").concat(options.anchor ? options.anchor.y : '0', "px)");
2619
+ } else if (mapType === 'kakao') {
2620
+ divElement.style.transform = "translate(50%, 50%) translate(-".concat(options.anchor ? options.anchor.x : '0', "px, -").concat(options.anchor ? options.anchor.y : '0', "px)");
1854
2621
  }
1855
2622
  };
1856
2623
 
@@ -1932,7 +2699,7 @@
1932
2699
  divElement.addEventListener('click', onClickHandler);
1933
2700
  divElement.addEventListener('mouseover', onMouseOverHandler);
1934
2701
  return function () {
1935
- if (divCloneRef.current && endAnimationClassName) {
2702
+ if (divCloneRef.current && endAnimationClassName && controller.getMapType() !== 'kakao') {
1936
2703
  divCloneRef.current.classList.add(endAnimationClassName);
1937
2704
 
1938
2705
  var aniListener_1 = function () {