@mint-ui/map 0.4.6-beta → 0.5.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -7,6 +7,7 @@ var MintMapController = require('../core/MintMapController.js');
7
7
  var waiting = require('../core/util/waiting.js');
8
8
  var tools = require('@mint-ui/tools');
9
9
  var MapTypes = require('../types/MapTypes.js');
10
+ var MapEventTypes = require('../types/MapEventTypes.js');
10
11
 
11
12
  var KakaoMintMapController =
12
13
  /** @class */
@@ -19,12 +20,20 @@ function (_super) {
19
20
  _this.type = 'kakao';
20
21
  _this.map = null;
21
22
  _this.scriptUrl = 'https://dapi.kakao.com/v2/maps/sdk.js';
22
- _this.scriptModules = ['services', 'clusterer'];
23
+ _this.scriptModules = ['services', 'clusterer']; // , 'geocoder' , 'panorama' , 'visualization']
24
+
25
+ _this.mapEvent = new MapEventTypes.MapEvent();
26
+ _this.mapUIEvent = new MapEventTypes.MapUIEvent();
23
27
  _this.polylineEvents = ['mouseover', 'mouseout'];
24
28
  _this.polygonEvents = ['mouseover', 'mouseout'];
25
29
  _this.markerEvents = ['click', 'mouseover', 'mouseout'];
26
30
  _this.dragStartPoint = [0, 0];
27
31
  _this.dragged = false;
32
+ _this.eventMap = new Map(); //kakao only 이벤트이름 재정의 zoom_start
33
+
34
+ _this.mapEvent.ZOOMSTART = 'zoom_start';
35
+ Object.freeze(_this.mapEvent);
36
+ Object.freeze(_this.mapUIEvent);
28
37
  return _this; // console.log(`${this.type} controller loadded`);
29
38
  }
30
39
 
@@ -598,6 +607,114 @@ function (_super) {
598
607
  return latLng ? new MapTypes.Position(latLng.getLat(), latLng.getLng()) : new MapTypes.Position(0, 0);
599
608
  };
600
609
 
610
+ KakaoMintMapController.prototype.addEventListener = function (eventName, callback) {
611
+ var _this = this;
612
+
613
+ var kakaoEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
614
+
615
+ if (!kakaoEventName) {
616
+ console.warn("MapEventName ".concat(eventName, " is not supported"));
617
+ return;
618
+ } // console.log(`${eventName} add`);
619
+
620
+
621
+ var map = this.eventMap.get(eventName);
622
+
623
+ if (!map) {
624
+ map = new Map();
625
+ this.eventMap.set(eventName, map);
626
+ }
627
+
628
+ var wrappingCallback = function (e) {
629
+ if (eventName in _this.mapEvent) {
630
+ var bounds = _this.getCurrBounds();
631
+
632
+ var param = {
633
+ name: eventName,
634
+ mapType: 'kakao',
635
+ vendorEventName: kakaoEventName,
636
+ param: {
637
+ bounds: bounds,
638
+ center: bounds.getCenter(),
639
+ zoomLevel: _this.getZoomLevel()
640
+ }
641
+ };
642
+ callback(param);
643
+ } else if (eventName in _this.mapUIEvent) {
644
+ var position = new MapTypes.Position(e.latLng.getLat(), e.latLng.getLng());
645
+ position.offset = new MapTypes.Offset(e.point.x, e.point.y);
646
+ var param = {
647
+ name: eventName,
648
+ mapType: 'kakao',
649
+ vendorEventName: kakaoEventName,
650
+ param: {
651
+ position: position,
652
+ offset: position.offset
653
+ }
654
+ };
655
+ callback(param);
656
+ }
657
+ };
658
+
659
+ kakao.maps.event.addListener(this.map, kakaoEventName, wrappingCallback);
660
+ map.set(callback, wrappingCallback);
661
+ };
662
+
663
+ KakaoMintMapController.prototype.removeEventListener = function (eventName, callback) {
664
+ var kakaoEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
665
+
666
+ if (!kakaoEventName) {
667
+ console.warn("MapEventName ".concat(eventName, " is not supported"));
668
+ return;
669
+ }
670
+
671
+ var map = this.eventMap.get(eventName);
672
+
673
+ if (map) {
674
+ var wrappingCallback = map.get(callback);
675
+
676
+ if (wrappingCallback) {
677
+ // console.log(`${naverEventListener.eventName} remove`);
678
+ kakao.maps.event.removeListener(this.map, kakaoEventName, wrappingCallback);
679
+ map.delete(callback);
680
+ }
681
+ }
682
+ };
683
+
684
+ KakaoMintMapController.prototype.removeAllEventListener = function (eventName) {
685
+ var _this = this;
686
+
687
+ if (eventName) {
688
+ this.clearEventListener(eventName);
689
+ } else {
690
+ this.eventMap.forEach(function (_map, eventName) {
691
+ _this.clearEventListener(eventName);
692
+ });
693
+ this.eventMap.clear();
694
+ }
695
+ };
696
+
697
+ KakaoMintMapController.prototype.clearEventListener = function (eventName) {
698
+ var _this = this;
699
+
700
+ var kakaoEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
701
+
702
+ if (!kakaoEventName) {
703
+ console.warn("MapEventName ".concat(eventName, " is not supported"));
704
+ return;
705
+ }
706
+
707
+ var map = this.eventMap.get(eventName);
708
+
709
+ if (map) {
710
+ map.forEach(function (wrappingCallback) {
711
+ // console.log(`${naverEventListener.eventName} remove`);
712
+ kakao.maps.event.removeListener(_this.map, kakaoEventName, wrappingCallback);
713
+ });
714
+ this.eventMap.delete(eventName);
715
+ }
716
+ };
717
+
601
718
  return KakaoMintMapController;
602
719
  }(MintMapController.MintMapController);
603
720
 
@@ -5,11 +5,14 @@ import { MapType, MapVendorType } from "../types/CommonTypes";
5
5
  import { Drawable, Marker, MarkerOptions, Polygon, PolygonOptions, Polyline, PolylineOptions } from "../types/MapDrawables";
6
6
  import { Bounds, Position } from "../types/MapTypes";
7
7
  import { MintMapProps } from "../types/MintMapProps";
8
+ import { EventCallback, EventParamType, MapEvent, MapEventName, MapUIEvent } from "../types/MapEventTypes";
8
9
  export declare class NaverMintMapController extends MintMapController {
9
10
  type: MapType;
10
11
  map: naver.maps.Map | null;
11
12
  scriptUrl: string;
12
13
  scriptModules: string[];
14
+ protected mapEvent: MapEvent;
15
+ protected mapUIEvent: MapUIEvent;
13
16
  markerPool?: ObjectPool<naver.maps.Marker>;
14
17
  constructor(props: MintMapProps);
15
18
  private initMarkerPool;
@@ -42,4 +45,9 @@ export declare class NaverMintMapController extends MintMapController {
42
45
  setZoomLevel(zoom: number): void;
43
46
  getCenter(): Position;
44
47
  setCenter(position: Position): void;
48
+ private eventMap;
49
+ addEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
50
+ removeEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
51
+ removeAllEventListener(eventName?: MapEventName | undefined): void;
52
+ private clearEventListener;
45
53
  }
@@ -7,6 +7,7 @@ var MintMapController = require('../core/MintMapController.js');
7
7
  var waiting = require('../core/util/waiting.js');
8
8
  var tools = require('@mint-ui/tools');
9
9
  var MapTypes = require('../types/MapTypes.js');
10
+ var MapEventTypes = require('../types/MapEventTypes.js');
10
11
 
11
12
  var NaverMintMapController =
12
13
  /** @class */
@@ -19,12 +20,18 @@ function (_super) {
19
20
  _this.type = 'naver';
20
21
  _this.map = null;
21
22
  _this.scriptUrl = 'https://openapi.map.naver.com/openapi/v3/maps.js';
22
- _this.scriptModules = ['drawing'];
23
+ _this.scriptModules = ['drawing']; // , 'geocoder' , 'panorama' , 'visualization']
24
+
25
+ _this.mapEvent = new MapEventTypes.MapEvent();
26
+ _this.mapUIEvent = new MapEventTypes.MapUIEvent();
23
27
  _this.polylineEvents = ['mouseover', 'mouseout'];
24
28
  _this.polygonEvents = ['mouseover', 'mouseout'];
25
29
  _this.markerEvents = ['click', 'mouseover', 'mouseout'];
26
30
  _this.dragStartPoint = [0, 0];
27
31
  _this.dragged = false;
32
+ _this.eventMap = new Map();
33
+ Object.freeze(_this.mapEvent);
34
+ Object.freeze(_this.mapUIEvent);
28
35
  return _this; // console.log(`${this.type} controller loadded`);
29
36
  }
30
37
 
@@ -574,6 +581,7 @@ function (_super) {
574
581
  var _a;
575
582
 
576
583
  try {
584
+ this.removeAllEventListener();
577
585
  this.map && this.map.destroy();
578
586
  (_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
579
587
  } catch (e) {
@@ -621,6 +629,98 @@ function (_super) {
621
629
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
622
630
  };
623
631
 
632
+ NaverMintMapController.prototype.addEventListener = function (eventName, callback) {
633
+ var _this = this;
634
+
635
+ var naverEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
636
+
637
+ if (!naverEventName) {
638
+ console.warn("MapEventName ".concat(eventName, " is not supported"));
639
+ return;
640
+ } // console.log(`${eventName} add`);
641
+
642
+
643
+ var map = this.eventMap.get(eventName);
644
+
645
+ if (!map) {
646
+ map = new Map();
647
+ this.eventMap.set(eventName, map);
648
+ }
649
+
650
+ var wrappingCallback = function (e) {
651
+ if (eventName in _this.mapEvent) {
652
+ var bounds = _this.getCurrBounds();
653
+
654
+ var param = {
655
+ name: eventName,
656
+ mapType: 'naver',
657
+ vendorEventName: naverEventName,
658
+ param: {
659
+ bounds: bounds,
660
+ center: bounds.getCenter(),
661
+ zoomLevel: _this.getZoomLevel()
662
+ }
663
+ };
664
+ callback(param);
665
+ } else if (eventName in _this.mapUIEvent) {
666
+ var position = new MapTypes.Position(e.coord.y, e.coord.x);
667
+ position.offset = new MapTypes.Offset(e.offset.x, e.offset.y);
668
+ var param = {
669
+ name: eventName,
670
+ mapType: 'naver',
671
+ vendorEventName: naverEventName,
672
+ param: {
673
+ position: position,
674
+ offset: position.offset
675
+ }
676
+ };
677
+ callback(param);
678
+ }
679
+ };
680
+
681
+ var naverEventListener = naver.maps.Event.addListener(this.map, naverEventName, wrappingCallback);
682
+ map.set(callback, naverEventListener);
683
+ };
684
+
685
+ NaverMintMapController.prototype.removeEventListener = function (eventName, callback) {
686
+ var map = this.eventMap.get(eventName);
687
+
688
+ if (map) {
689
+ var naverEventListener = map.get(callback);
690
+
691
+ if (naverEventListener) {
692
+ // console.log(`${naverEventListener.eventName} remove`);
693
+ naver.maps.Event.removeListener(naverEventListener);
694
+ map.delete(callback);
695
+ }
696
+ }
697
+ };
698
+
699
+ NaverMintMapController.prototype.removeAllEventListener = function (eventName) {
700
+ var _this = this;
701
+
702
+ if (eventName) {
703
+ this.clearEventListener(eventName);
704
+ } else {
705
+ this.eventMap.forEach(function (_map, eventName) {
706
+ _this.clearEventListener(eventName);
707
+ });
708
+ this.eventMap.clear();
709
+ }
710
+ };
711
+
712
+ NaverMintMapController.prototype.clearEventListener = function (eventName) {
713
+ var map = this.eventMap.get(eventName);
714
+
715
+ if (map) {
716
+ map.forEach(function (naverEventListener) {
717
+ // console.log(`${naverEventListener.eventName} remove`);
718
+ naver.maps.Event.removeListener(naverEventListener);
719
+ });
720
+ this.eventMap.delete(eventName);
721
+ }
722
+ };
723
+
624
724
  return NaverMintMapController;
625
725
  }(MintMapController.MintMapController);
626
726
 
@@ -0,0 +1,41 @@
1
+ import { MapType } from "./CommonTypes";
2
+ import { Bounds, Offset, Position } from "./MapTypes";
3
+ export declare class MapEvent {
4
+ BOUNDS_CHANGED: string;
5
+ CENTER_CHANGED: string;
6
+ IDLE: string;
7
+ ZOOM_CHANGED: string;
8
+ ZOOMSTART: string;
9
+ get(eventName: MapEventName): string | undefined;
10
+ }
11
+ export declare class MapUIEvent {
12
+ CLICK: string;
13
+ DBLCLICK: string;
14
+ MOUSEDOWN: string;
15
+ MOUSEUP: string;
16
+ MOUSEOUT: string;
17
+ MOUSEMOVE: string;
18
+ MOUSEOVER: string;
19
+ DRAG: string;
20
+ DRAGSTART: string;
21
+ DRAGEND: string;
22
+ get(eventName: MapEventName): string | undefined;
23
+ }
24
+ export declare type MapEventName = keyof MapEvent | keyof MapUIEvent;
25
+ export declare type MapEventParam = {
26
+ center: Position;
27
+ bounds: Bounds;
28
+ zoomLevel: number;
29
+ };
30
+ export declare type MapUIEventParam = {
31
+ offset: Offset;
32
+ position: Position;
33
+ };
34
+ export declare type EventParamType = MapEventParam & MapUIEventParam;
35
+ export interface EventParam<T> {
36
+ mapType: MapType;
37
+ name: MapEventName;
38
+ vendorEventName: string;
39
+ param: T;
40
+ }
41
+ export declare type EventCallback<T> = (e: EventParam<T>) => void;
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ // export type MapEvent = 'bounds_changed'|'center_changed'|'idle'|'zoom_changed'|'zoomstart'
6
+ // export type MapUIEvent = 'click'|'dblclick'|''
7
+ var MapEvent =
8
+ /** @class */
9
+ function () {
10
+ function MapEvent() {
11
+ this.BOUNDS_CHANGED = 'bounds_changed';
12
+ this.CENTER_CHANGED = 'center_changed';
13
+ this.IDLE = 'idle';
14
+ this.ZOOM_CHANGED = 'zoom_changed';
15
+ this.ZOOMSTART = 'zoomstart';
16
+ }
17
+
18
+ MapEvent.prototype.get = function (eventName) {
19
+ var value = this[eventName];
20
+
21
+ if (typeof value === 'string') {
22
+ return value;
23
+ }
24
+ };
25
+
26
+ return MapEvent;
27
+ }();
28
+
29
+ var MapUIEvent =
30
+ /** @class */
31
+ function () {
32
+ function MapUIEvent() {
33
+ this.CLICK = 'click';
34
+ this.DBLCLICK = 'dblclick';
35
+ this.MOUSEDOWN = 'mousedown';
36
+ this.MOUSEUP = 'mouseup';
37
+ this.MOUSEOUT = 'mouseout';
38
+ this.MOUSEMOVE = 'mousemove';
39
+ this.MOUSEOVER = 'mouseover';
40
+ this.DRAG = 'drag';
41
+ this.DRAGSTART = 'dragstart';
42
+ this.DRAGEND = 'dragend';
43
+ }
44
+
45
+ MapUIEvent.prototype.get = function (eventName) {
46
+ var value = this[eventName];
47
+
48
+ if (typeof value === 'string') {
49
+ return value;
50
+ }
51
+ };
52
+
53
+ return MapUIEvent;
54
+ }();
55
+
56
+ exports.MapEvent = MapEvent;
57
+ exports.MapUIEvent = MapUIEvent;
@@ -56,4 +56,5 @@ export declare class Offset {
56
56
  * DOM 상에서의 좌표를 표현 (픽셀을 나타내는 숫자)
57
57
  */
58
58
  constructor(x: number, y: number);
59
+ equals(other?: Offset): boolean | undefined;
59
60
  }
@@ -143,6 +143,10 @@ function () {
143
143
  this.y = y;
144
144
  }
145
145
 
146
+ Offset.prototype.equals = function (other) {
147
+ return other && this.x === other.x && this.y === other.y;
148
+ };
149
+
146
150
  return Offset;
147
151
  }();
148
152
 
@@ -3,3 +3,4 @@ export * from './MapDrawables';
3
3
  export * from './MapTypes';
4
4
  export * from './MintMapEvents';
5
5
  export * from './MintMapProps';
6
+ export * from './MapEventTypes';