@mint-ui/map 0.4.5-beta → 0.5.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +109 -109
- package/LICENSE +21 -21
- package/README.md +73 -73
- package/dist/components/mint-map/MintMap.d.ts +10 -117
- package/dist/components/mint-map/MintMap.js +24 -421
- package/dist/components/mint-map/core/MintMapCanvasRenderer.d.ts +4 -4
- package/dist/components/mint-map/core/MintMapCanvasRenderer.js +3 -1
- package/dist/components/mint-map/core/MintMapController.d.ts +64 -44
- package/dist/components/mint-map/core/MintMapController.js +49 -15
- package/dist/components/mint-map/core/MintMapCore.d.ts +3 -3
- package/dist/components/mint-map/core/MintMapCore.js +22 -10
- package/dist/components/mint-map/core/advanced/MapBuildingProjection.d.ts +15 -15
- package/dist/components/mint-map/core/advanced/MapBuildingProjection.js +11 -7
- package/dist/components/mint-map/core/advanced/MapLoadingComponents.d.ts +17 -0
- package/dist/components/mint-map/core/advanced/MapLoadingComponents.js +257 -0
- package/dist/components/mint-map/core/advanced/index.d.ts +3 -1
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.d.ts +20 -0
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.js +137 -0
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.d.ts +23 -0
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.js +188 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.d.ts +8 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.js +54 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.d.ts +12 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.js +152 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.d.ts +10 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.js +60 -0
- package/dist/components/mint-map/core/advanced/shapes/base/index.d.ts +3 -0
- package/dist/components/mint-map/core/advanced/shapes/index.d.ts +3 -0
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.d.ts +6 -6
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.js +21 -9
- package/dist/components/mint-map/core/hooks/index.d.ts +1 -1
- package/dist/components/mint-map/core/index.d.ts +8 -8
- package/dist/components/mint-map/core/provider/MintMapProvider.d.ts +8 -8
- package/dist/components/mint-map/core/provider/index.d.ts +1 -1
- package/dist/components/mint-map/core/util/animation.d.ts +16 -16
- package/dist/components/mint-map/core/util/animation.js +14 -5
- package/dist/components/mint-map/core/util/calculate.d.ts +66 -34
- package/dist/components/mint-map/core/util/calculate.js +233 -27
- package/dist/components/mint-map/core/util/cluster.d.ts +18 -18
- package/dist/components/mint-map/core/util/cluster.js +14 -9
- package/dist/components/mint-map/core/util/index.d.ts +4 -4
- package/dist/components/mint-map/core/util/waiting.d.ts +1 -1
- package/dist/components/mint-map/core/util/waiting.js +6 -2
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.d.ts +27 -19
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.js +9 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.d.ts +11 -4
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.js +107 -35
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +18 -11
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.js +8 -0
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +32 -23
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +76 -28
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +12 -5
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +21 -6
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +12 -5
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +21 -7
- package/dist/components/mint-map/core/wrapper/index.d.ts +6 -6
- package/dist/components/mint-map/google/GoogleMintMapController.d.ts +51 -39
- package/dist/components/mint-map/google/GoogleMintMapController.js +224 -44
- package/dist/components/mint-map/index.d.ts +5 -4
- package/dist/components/mint-map/kakao/KakaoMintMapController.d.ts +56 -44
- package/dist/components/mint-map/kakao/KakaoMintMapController.js +265 -66
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +53 -42
- package/dist/components/mint-map/naver/NaverMintMapController.js +237 -50
- package/dist/components/mint-map/types/CommonTypes.d.ts +11 -0
- package/dist/components/mint-map/types/MapDrawables.d.ts +110 -0
- package/dist/components/mint-map/types/MapDrawables.js +92 -0
- package/dist/components/mint-map/types/MapEventTypes.d.ts +41 -0
- package/dist/components/mint-map/types/MapEventTypes.js +57 -0
- package/dist/components/mint-map/types/MapTypes.d.ts +60 -0
- package/dist/components/mint-map/types/MapTypes.js +155 -0
- package/dist/components/mint-map/types/MintMapEvents.d.ts +25 -0
- package/dist/components/mint-map/types/MintMapProps.d.ts +92 -0
- package/dist/components/mint-map/types/index.d.ts +6 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.es.js +2638 -975
- package/dist/index.js +25 -9
- package/dist/index.umd.js +2644 -974
- package/package.json +77 -77
- package/test.ts +0 -7
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
/// <reference types="navermaps" />
|
|
2
|
-
import { MintMapController } from "../core/MintMapController";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
/// <reference types="navermaps" />
|
|
2
|
+
import { MintMapController } from "../core/MintMapController";
|
|
3
|
+
import { ObjectPool } from '@mint-ui/tools';
|
|
4
|
+
import { MapType, MapVendorType } from "../types/CommonTypes";
|
|
5
|
+
import { Drawable, Marker, MarkerOptions, Polygon, PolygonOptions, Polyline, PolylineOptions } from "../types/MapDrawables";
|
|
6
|
+
import { Bounds, Position } from "../types/MapTypes";
|
|
7
|
+
import { MintMapProps } from "../types/MintMapProps";
|
|
8
|
+
import { EventCallback, EventParamType, MapEvent, MapEventName, MapUIEvent } from "../types/MapEventTypes";
|
|
9
|
+
export declare class NaverMintMapController extends MintMapController {
|
|
10
|
+
type: MapType;
|
|
11
|
+
map: naver.maps.Map | null;
|
|
12
|
+
scriptUrl: string;
|
|
13
|
+
scriptModules: string[];
|
|
14
|
+
protected mapEvent: MapEvent;
|
|
15
|
+
protected mapUIEvent: MapUIEvent;
|
|
16
|
+
markerPool?: ObjectPool<naver.maps.Marker>;
|
|
17
|
+
constructor(props: MintMapProps);
|
|
18
|
+
private initMarkerPool;
|
|
19
|
+
polylineEvents: string[];
|
|
20
|
+
createPolyline(polyline: Polyline): void;
|
|
21
|
+
updatePolyline(polyline: Polyline, options: PolylineOptions): void;
|
|
22
|
+
polygonEvents: string[];
|
|
23
|
+
createPolygon(polygon: Polygon): void;
|
|
24
|
+
updatePolygon(polygon: Polygon, options: PolygonOptions): void;
|
|
25
|
+
markerEvents: string[];
|
|
26
|
+
createMarker(marker: Marker): void;
|
|
27
|
+
updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
28
|
+
private markerMaxZIndex;
|
|
29
|
+
private getMaxZIndex;
|
|
30
|
+
setMarkerZIndex(marker: Marker, zIndex: number): void;
|
|
31
|
+
markerToTheTop(marker: Marker): void;
|
|
32
|
+
clearDrawable(drawable: Drawable): boolean;
|
|
33
|
+
private dragStartPoint;
|
|
34
|
+
private dragged;
|
|
35
|
+
isMapDragged(): boolean;
|
|
36
|
+
setMapDragged(value: boolean): void;
|
|
37
|
+
private checkLoaded;
|
|
38
|
+
loadMapApi(): Promise<boolean>;
|
|
39
|
+
initializingMap(divElement: HTMLDivElement): Promise<MapVendorType>;
|
|
40
|
+
private getSafeZoomValue;
|
|
41
|
+
destroyMap(): void;
|
|
42
|
+
getCurrBounds(): Bounds;
|
|
43
|
+
panningTo(targetCenter: Position): void;
|
|
44
|
+
getZoomLevel(): number;
|
|
45
|
+
setZoomLevel(zoom: number): void;
|
|
46
|
+
getCenter(): Position;
|
|
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;
|
|
53
|
+
}
|
|
@@ -5,10 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var MintMapController = require('../core/MintMapController.js');
|
|
7
7
|
var waiting = require('../core/util/waiting.js');
|
|
8
|
-
var MintMap = require('../MintMap.js');
|
|
9
8
|
var tools = require('@mint-ui/tools');
|
|
9
|
+
var MapTypes = require('../types/MapTypes.js');
|
|
10
|
+
var MapEventTypes = require('../types/MapEventTypes.js');
|
|
10
11
|
|
|
11
|
-
var NaverMintMapController =
|
|
12
|
+
var NaverMintMapController =
|
|
13
|
+
/** @class */
|
|
14
|
+
function (_super) {
|
|
12
15
|
tslib.__extends(NaverMintMapController, _super);
|
|
13
16
|
|
|
14
17
|
function NaverMintMapController(props) {
|
|
@@ -17,27 +20,42 @@ var NaverMintMapController = function (_super) {
|
|
|
17
20
|
_this.type = 'naver';
|
|
18
21
|
_this.map = null;
|
|
19
22
|
_this.scriptUrl = 'https://openapi.map.naver.com/openapi/v3/maps.js';
|
|
20
|
-
_this.scriptModules = ['drawing'];
|
|
23
|
+
_this.scriptModules = ['drawing']; // , 'geocoder' , 'panorama' , 'visualization']
|
|
24
|
+
|
|
25
|
+
_this.mapEvent = new MapEventTypes.MapEvent();
|
|
26
|
+
_this.mapUIEvent = new MapEventTypes.MapUIEvent();
|
|
21
27
|
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
22
28
|
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
23
29
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
24
30
|
_this.dragStartPoint = [0, 0];
|
|
25
31
|
_this.dragged = false;
|
|
26
|
-
|
|
32
|
+
_this.eventMap = new Map();
|
|
33
|
+
Object.freeze(_this.mapEvent);
|
|
34
|
+
Object.freeze(_this.mapUIEvent);
|
|
35
|
+
return _this; // console.log(`${this.type} controller loadded`);
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
NaverMintMapController.prototype.initMarkerPool = function () {
|
|
30
39
|
var _this = this;
|
|
31
40
|
|
|
32
|
-
if (!this.mapProps.markerCache) return;
|
|
33
|
-
|
|
41
|
+
if (!this.mapProps.markerCache) return; //marker pool setting
|
|
42
|
+
|
|
43
|
+
this.markerPool = new tools.ObjectPool() //logging on
|
|
44
|
+
//.setLog(true)
|
|
45
|
+
//factory 셋팅
|
|
46
|
+
.setFactory(function () {
|
|
47
|
+
//console.log('pool item created');
|
|
34
48
|
return new naver.maps.Marker({
|
|
35
|
-
position: new
|
|
49
|
+
position: new MapTypes.Position(0, 0),
|
|
36
50
|
map: _this.map || undefined
|
|
37
51
|
});
|
|
38
|
-
})
|
|
52
|
+
}) //clear function 셋팅
|
|
53
|
+
.setClear(function (item) {
|
|
54
|
+
//console.log('pool item cleared');
|
|
39
55
|
item.setMap(null);
|
|
40
|
-
})
|
|
56
|
+
}) //초기 pool 사이즈
|
|
57
|
+
.createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000) //TTL 체크 간격 (기본 5초)
|
|
58
|
+
.setCheckLiveTimeInterval(1000);
|
|
41
59
|
};
|
|
42
60
|
|
|
43
61
|
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -55,11 +73,11 @@ var NaverMintMapController = function (_super) {
|
|
|
55
73
|
visible = _e === void 0 ? true : _e,
|
|
56
74
|
_f = _a.editable,
|
|
57
75
|
editable = _f === void 0 ? false : _f,
|
|
58
|
-
event = _a.event;
|
|
76
|
+
event = _a.event; //console.log('controller createPolyline start', polyline);
|
|
59
77
|
|
|
60
78
|
if (this.map && Array.isArray(position)) {
|
|
61
79
|
var path = position.map(function (elem) {
|
|
62
|
-
return Array.isArray(elem) ? new
|
|
80
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
63
81
|
});
|
|
64
82
|
var pol_1 = new naver.maps.Polyline({
|
|
65
83
|
map: this.map,
|
|
@@ -69,8 +87,13 @@ var NaverMintMapController = function (_super) {
|
|
|
69
87
|
strokeOpacity: lineOpacity,
|
|
70
88
|
clickable: true,
|
|
71
89
|
visible: visible
|
|
72
|
-
});
|
|
73
|
-
|
|
90
|
+
}); //@ts-ignore
|
|
91
|
+
|
|
92
|
+
editable && pol_1.setEditable(editable); // if(editable){
|
|
93
|
+
// //@ts-ignore
|
|
94
|
+
// this.drawingManager.addDrawing(pol, naver.maps.drawing.DrawingMode.POLYLINE)
|
|
95
|
+
// }
|
|
96
|
+
|
|
74
97
|
polyline.native = pol_1;
|
|
75
98
|
event && event.forEach(function (handler, key) {
|
|
76
99
|
if (_this.polylineEvents.includes(key)) {
|
|
@@ -81,12 +104,14 @@ var NaverMintMapController = function (_super) {
|
|
|
81
104
|
};
|
|
82
105
|
|
|
83
106
|
NaverMintMapController.prototype.updatePolyline = function (polyline, options) {
|
|
107
|
+
//console.log('controller updatePolyline', options);
|
|
84
108
|
if (polyline && polyline.native && polyline.native instanceof naver.maps.Polyline) {
|
|
109
|
+
//console.log('controller updatePolyline start');
|
|
85
110
|
var path = void 0;
|
|
86
111
|
|
|
87
112
|
if (Array.isArray(options.position)) {
|
|
88
113
|
path = options.position.map(function (elem) {
|
|
89
|
-
return Array.isArray(elem) ? new
|
|
114
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
90
115
|
});
|
|
91
116
|
}
|
|
92
117
|
|
|
@@ -96,7 +121,8 @@ var NaverMintMapController = function (_super) {
|
|
|
96
121
|
strokeColor: options.lineColor,
|
|
97
122
|
strokeWeight: options.lineSize,
|
|
98
123
|
strokeOpacity: options.lineOpacity
|
|
99
|
-
});
|
|
124
|
+
}); //@ts-ignore
|
|
125
|
+
|
|
100
126
|
options.editable !== undefined && polyline.native.setEditable(options.editable);
|
|
101
127
|
}
|
|
102
128
|
};
|
|
@@ -120,11 +146,11 @@ var NaverMintMapController = function (_super) {
|
|
|
120
146
|
_g = _a.visible,
|
|
121
147
|
visible = _g === void 0 ? true : _g;
|
|
122
148
|
_a.editable;
|
|
123
|
-
var event = _a.event;
|
|
149
|
+
var event = _a.event; //console.log('polygon', polygon);
|
|
124
150
|
|
|
125
151
|
if (this.map && Array.isArray(position)) {
|
|
126
152
|
var outLine = position.map(function (elem) {
|
|
127
|
-
return Array.isArray(elem) ? new
|
|
153
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
128
154
|
});
|
|
129
155
|
var paths = [outLine];
|
|
130
156
|
innerPositions && paths.push.apply(paths, innerPositions);
|
|
@@ -138,7 +164,9 @@ var NaverMintMapController = function (_super) {
|
|
|
138
164
|
fillOpacity: fillOpacity,
|
|
139
165
|
clickable: true,
|
|
140
166
|
visible: visible
|
|
141
|
-
});
|
|
167
|
+
}); //@ts-ignore
|
|
168
|
+
//pol.setEditable(editable)
|
|
169
|
+
|
|
142
170
|
polygon.native = pol_2;
|
|
143
171
|
event && event.forEach(function (handler, key) {
|
|
144
172
|
if (_this.polygonEvents.includes(key)) {
|
|
@@ -149,12 +177,14 @@ var NaverMintMapController = function (_super) {
|
|
|
149
177
|
};
|
|
150
178
|
|
|
151
179
|
NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
180
|
+
//console.log('controller updatePolygon', options);
|
|
152
181
|
if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
|
|
182
|
+
//console.log('controller updatePolygon start');
|
|
153
183
|
var paths = void 0;
|
|
154
184
|
|
|
155
185
|
if (Array.isArray(options.position)) {
|
|
156
186
|
var outLine = options.position.map(function (elem) {
|
|
157
|
-
return Array.isArray(elem) ? new
|
|
187
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
158
188
|
});
|
|
159
189
|
paths = [outLine];
|
|
160
190
|
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
@@ -168,7 +198,8 @@ var NaverMintMapController = function (_super) {
|
|
|
168
198
|
strokeOpacity: options.lineOpacity,
|
|
169
199
|
fillColor: options.fillColor,
|
|
170
200
|
fillOpacity: options.fillOpacity
|
|
171
|
-
});
|
|
201
|
+
}); //@ts-ignore
|
|
202
|
+
|
|
172
203
|
options.editable !== undefined && polygon.native.setEditable(options.editable);
|
|
173
204
|
}
|
|
174
205
|
};
|
|
@@ -183,7 +214,8 @@ var NaverMintMapController = function (_super) {
|
|
|
183
214
|
map: this.map,
|
|
184
215
|
position: marker.options.position,
|
|
185
216
|
visible: marker.options.visible === undefined || marker.options.visible
|
|
186
|
-
};
|
|
217
|
+
}; //console.log('controller createMarker', marker.options);
|
|
218
|
+
|
|
187
219
|
marker.element && (options.icon = {
|
|
188
220
|
content: marker.element,
|
|
189
221
|
anchor: marker.options.anchor
|
|
@@ -210,11 +242,19 @@ var NaverMintMapController = function (_super) {
|
|
|
210
242
|
};
|
|
211
243
|
|
|
212
244
|
NaverMintMapController.prototype.updateMarker = function (marker, options) {
|
|
245
|
+
//console.log('controller updateMarker', options);
|
|
213
246
|
if (marker && marker.native && marker.native instanceof naver.maps.Marker) {
|
|
214
247
|
var map = marker.native.getMap();
|
|
215
248
|
|
|
216
249
|
if (map) {
|
|
217
|
-
|
|
250
|
+
/** 중요!!!!
|
|
251
|
+
* naver 마커의 setOption(MarkerOptions) 은 내부적으로 setMap 을 무조건 강제 처리한다!!!
|
|
252
|
+
* setMap 을 처리하면 맵의 이벤트리스너 등등이 모두 초기화 되고 다시 맵을 add 하면서 마커관련된 모든 초기화가 다시 일어난다.
|
|
253
|
+
* (심지어 map 이 기존과 같은 객체인데도 초기화 처리함)
|
|
254
|
+
* 그래서 민트맵에서는 update 를 지원하는 항목별로 명시적으로 각각 처리한다.
|
|
255
|
+
*/
|
|
256
|
+
//Position
|
|
257
|
+
if (options.position && options.position instanceof MapTypes.Position) {
|
|
218
258
|
marker.native.setPosition(options.position);
|
|
219
259
|
}
|
|
220
260
|
|
|
@@ -226,7 +266,21 @@ var NaverMintMapController = function (_super) {
|
|
|
226
266
|
marker.native.setIcon(tslib.__assign(tslib.__assign({}, marker.native.getIcon()), {
|
|
227
267
|
anchor: options.anchor
|
|
228
268
|
}));
|
|
229
|
-
}
|
|
269
|
+
} // const newOption = {
|
|
270
|
+
// map:map,
|
|
271
|
+
// position:options.position instanceof Position?options.position:marker.native.getPosition(),
|
|
272
|
+
// visible:options.visible === undefined || options.visible,
|
|
273
|
+
// } as naver.maps.MarkerOptions
|
|
274
|
+
// if(options.anchor){
|
|
275
|
+
// newOption.icon = {...marker.native.getIcon(), anchor:options.anchor}
|
|
276
|
+
// }
|
|
277
|
+
// marker.native.setOptions({
|
|
278
|
+
// map:map,
|
|
279
|
+
// position:options.position instanceof Position?options.position:marker.native.getPosition(),
|
|
280
|
+
// visible:options.visible === undefined || options.visible,
|
|
281
|
+
// icon:{...marker.native.getIcon(), anchor:options.anchor}
|
|
282
|
+
// })
|
|
283
|
+
|
|
230
284
|
}
|
|
231
285
|
}
|
|
232
286
|
};
|
|
@@ -306,7 +360,7 @@ var NaverMintMapController = function (_super) {
|
|
|
306
360
|
NaverMintMapController.prototype.checkLoaded = function () {
|
|
307
361
|
var _a, _b;
|
|
308
362
|
|
|
309
|
-
return (_b = (_a = window.naver) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.Map;
|
|
363
|
+
return ((_b = (_a = window.naver) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.Map) ? true : false;
|
|
310
364
|
};
|
|
311
365
|
|
|
312
366
|
NaverMintMapController.prototype.loadMapApi = function () {
|
|
@@ -314,17 +368,21 @@ var NaverMintMapController = function (_super) {
|
|
|
314
368
|
var _this = this;
|
|
315
369
|
|
|
316
370
|
return tslib.__generator(this, function (_a) {
|
|
317
|
-
return [2
|
|
371
|
+
return [2
|
|
372
|
+
/*return*/
|
|
373
|
+
, new Promise(function (resolve, error) {
|
|
318
374
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
319
375
|
var callbackName, loaded, params, callbackExecFlag, ok;
|
|
320
376
|
return tslib.__generator(this, function (_a) {
|
|
321
377
|
switch (_a.label) {
|
|
322
378
|
case 0:
|
|
323
379
|
callbackName = this.getRandomFunctionName('load_naver');
|
|
324
|
-
loaded = false;
|
|
380
|
+
loaded = false; //@ts-ignore
|
|
325
381
|
|
|
326
382
|
window[callbackName] = function () {
|
|
327
|
-
|
|
383
|
+
// console.log('naver api loaded');
|
|
384
|
+
loaded = true; //@ts-ignore
|
|
385
|
+
|
|
328
386
|
delete window[callbackName];
|
|
329
387
|
};
|
|
330
388
|
|
|
@@ -333,17 +391,22 @@ var NaverMintMapController = function (_super) {
|
|
|
333
391
|
submodules: this.scriptModules.join(','),
|
|
334
392
|
callback: callbackName
|
|
335
393
|
};
|
|
336
|
-
return [4
|
|
394
|
+
return [4
|
|
395
|
+
/*yield*/
|
|
396
|
+
, this.loadScript(this.buildUrl(this.scriptUrl, params), 'naver_map_script', this.checkLoaded)];
|
|
337
397
|
|
|
338
398
|
case 1:
|
|
339
399
|
callbackExecFlag = _a.sent();
|
|
340
400
|
|
|
341
401
|
if (!callbackExecFlag) {
|
|
342
|
-
loaded = true;
|
|
402
|
+
loaded = true; //@ts-ignore
|
|
403
|
+
|
|
343
404
|
delete window[callbackName];
|
|
344
405
|
}
|
|
345
406
|
|
|
346
|
-
return [4
|
|
407
|
+
return [4
|
|
408
|
+
/*yield*/
|
|
409
|
+
, waiting.waiting(function () {
|
|
347
410
|
return loaded;
|
|
348
411
|
})];
|
|
349
412
|
|
|
@@ -356,7 +419,9 @@ var NaverMintMapController = function (_super) {
|
|
|
356
419
|
|
|
357
420
|
this.mapApiLoaded = true;
|
|
358
421
|
resolve(true);
|
|
359
|
-
return [2
|
|
422
|
+
return [2
|
|
423
|
+
/*return*/
|
|
424
|
+
];
|
|
360
425
|
}
|
|
361
426
|
});
|
|
362
427
|
});
|
|
@@ -370,8 +435,11 @@ var NaverMintMapController = function (_super) {
|
|
|
370
435
|
var _this = this;
|
|
371
436
|
|
|
372
437
|
return tslib.__generator(this, function (_a) {
|
|
438
|
+
//div element
|
|
373
439
|
this.mapDivElement = divElement;
|
|
374
|
-
return [2
|
|
440
|
+
return [2
|
|
441
|
+
/*return*/
|
|
442
|
+
, new Promise(function (resolve) {
|
|
375
443
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
376
444
|
var options, maxZoom, minZoom, map;
|
|
377
445
|
|
|
@@ -382,17 +450,26 @@ var NaverMintMapController = function (_super) {
|
|
|
382
450
|
return tslib.__generator(this, function (_e) {
|
|
383
451
|
switch (_e.label) {
|
|
384
452
|
case 0:
|
|
453
|
+
//이미 생성했으면
|
|
454
|
+
//1. divElement 가 그대로인 경우 기존 map 객체 리턴
|
|
455
|
+
//2. divElement 가 바뀐경우 기존 map 객체 destroy 하고 새로 생성
|
|
385
456
|
if (this.mapInitialized && this.map) {
|
|
386
457
|
if (this.map.getElement() === divElement) {
|
|
387
458
|
resolve(this.map);
|
|
388
|
-
return [2
|
|
459
|
+
return [2
|
|
460
|
+
/*return*/
|
|
461
|
+
];
|
|
389
462
|
} else {
|
|
390
463
|
this.map.destroy();
|
|
391
464
|
}
|
|
392
465
|
}
|
|
393
466
|
|
|
394
|
-
if (!!this.mapApiLoaded) return [3
|
|
395
|
-
|
|
467
|
+
if (!!this.mapApiLoaded) return [3
|
|
468
|
+
/*break*/
|
|
469
|
+
, 2];
|
|
470
|
+
return [4
|
|
471
|
+
/*yield*/
|
|
472
|
+
, this.loadMapApi()];
|
|
396
473
|
|
|
397
474
|
case 1:
|
|
398
475
|
_e.sent();
|
|
@@ -429,43 +506,59 @@ var NaverMintMapController = function (_super) {
|
|
|
429
506
|
options.minZoom = minZoom;
|
|
430
507
|
options.maxZoom = maxZoom;
|
|
431
508
|
map = new naver.maps.Map(divElement, options);
|
|
432
|
-
this.map = map;
|
|
509
|
+
this.map = map; //@ts-ignore
|
|
510
|
+
|
|
433
511
|
map.addListener('dragstart', function (e) {
|
|
512
|
+
//console.log('map dragstart', e);
|
|
434
513
|
_this.dragStartPoint[0] = e.domEvent.clientX;
|
|
435
514
|
_this.dragStartPoint[1] = e.domEvent.clientY;
|
|
436
|
-
});
|
|
515
|
+
}); //@ts-ignore
|
|
516
|
+
|
|
437
517
|
map.addListener('dragend', function (e) {
|
|
518
|
+
//console.log('map dragend', e);
|
|
438
519
|
if (_this.dragStartPoint[0] === e.domEvent.clientX && _this.dragStartPoint[1] === e.domEvent.clientY) {
|
|
439
520
|
_this.dragged = false;
|
|
440
521
|
} else {
|
|
441
522
|
_this.dragged = true;
|
|
442
|
-
}
|
|
443
|
-
|
|
523
|
+
} //console.log('map dragend', this.dragged)
|
|
524
|
+
|
|
525
|
+
}); //@ts-ignore
|
|
526
|
+
|
|
444
527
|
map.addListener('idle', function (e) {
|
|
528
|
+
//onBoundsChanged event
|
|
445
529
|
_this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
446
530
|
});
|
|
447
531
|
map.addListener('zoom_changed', function () {
|
|
532
|
+
//onZoomChanged event
|
|
533
|
+
//console.log('zoom_changed');
|
|
448
534
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
449
|
-
});
|
|
535
|
+
}); //@ts-ignore
|
|
536
|
+
|
|
450
537
|
map.addListener('click', function (e) {
|
|
538
|
+
// console.log('map click', e);
|
|
451
539
|
if (!_this.mapProps.onClick) return;
|
|
452
|
-
var pos = new
|
|
453
|
-
pos.offset = new
|
|
540
|
+
var pos = new MapTypes.Position(e.coord.y, e.coord.x);
|
|
541
|
+
pos.offset = new MapTypes.Offset(e.offset.x, e.offset.y);
|
|
454
542
|
|
|
455
543
|
_this.mapProps.onClick(pos);
|
|
456
|
-
});
|
|
544
|
+
}); //@ts-ignore
|
|
545
|
+
|
|
457
546
|
map.addListener('mousemove', function (e) {
|
|
458
547
|
if (!_this.mapProps.onMouseMove) return;
|
|
459
|
-
var pos = new
|
|
460
|
-
pos.offset = new
|
|
548
|
+
var pos = new MapTypes.Position(e.coord.y, e.coord.x);
|
|
549
|
+
pos.offset = new MapTypes.Offset(e.offset.x, e.offset.y); // console.log('mousemove', pos)
|
|
461
550
|
|
|
462
551
|
_this.mapProps.onMouseMove(pos);
|
|
463
552
|
});
|
|
464
553
|
this.mapInitialized = true;
|
|
465
|
-
this.initMarkerPool();
|
|
466
|
-
|
|
554
|
+
this.initMarkerPool(); // console.log(`${this.type} map script initialized`, divElement);
|
|
555
|
+
|
|
556
|
+
resolve(map); //네이버는 로드 후에 idle 이 발생 안해서 직접 일으켜준다
|
|
557
|
+
|
|
467
558
|
map.trigger('idle');
|
|
468
|
-
return [2
|
|
559
|
+
return [2
|
|
560
|
+
/*return*/
|
|
561
|
+
];
|
|
469
562
|
}
|
|
470
563
|
});
|
|
471
564
|
});
|
|
@@ -488,11 +581,13 @@ var NaverMintMapController = function (_super) {
|
|
|
488
581
|
var _a;
|
|
489
582
|
|
|
490
583
|
try {
|
|
584
|
+
this.removeAllEventListener();
|
|
491
585
|
this.map && this.map.destroy();
|
|
492
586
|
(_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
493
587
|
} catch (e) {
|
|
494
588
|
console.log('naver map destroy error', e);
|
|
495
|
-
}
|
|
589
|
+
} // console.log(`${this.type} map destroyed`);
|
|
590
|
+
|
|
496
591
|
};
|
|
497
592
|
|
|
498
593
|
NaverMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -501,7 +596,7 @@ var NaverMintMapController = function (_super) {
|
|
|
501
596
|
}
|
|
502
597
|
|
|
503
598
|
var bounds = this.map.getBounds();
|
|
504
|
-
return
|
|
599
|
+
return MapTypes.Bounds.fromNWSE(new MapTypes.Position(bounds.getMax().y, bounds.getMin().x), new MapTypes.Position(bounds.getMin().y, bounds.getMax().x));
|
|
505
600
|
};
|
|
506
601
|
|
|
507
602
|
NaverMintMapController.prototype.panningTo = function (targetCenter) {
|
|
@@ -534,6 +629,98 @@ var NaverMintMapController = function (_super) {
|
|
|
534
629
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
535
630
|
};
|
|
536
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
|
+
|
|
537
724
|
return NaverMintMapController;
|
|
538
725
|
}(MintMapController.MintMapController);
|
|
539
726
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="navermaps" />
|
|
2
|
+
/// <reference types="google.maps" />
|
|
3
|
+
/// <reference types="kakaomaps" />
|
|
4
|
+
/**
|
|
5
|
+
* 지원되는 맵 종류
|
|
6
|
+
*/
|
|
7
|
+
export declare type MapType = 'naver' | 'google' | 'kakao';
|
|
8
|
+
/**
|
|
9
|
+
* 맵 객체의 native 타입
|
|
10
|
+
*/
|
|
11
|
+
export declare type MapVendorType = naver.maps.Map | google.maps.Map | kakao.maps.Map;
|