@mint-ui/map 0.1.1-beta → 0.1.2-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/MintMap.d.ts +2 -2
  2. package/dist/components/mint-map/MintMap.js +69 -49
  3. package/dist/components/mint-map/core/MintMapController.d.ts +1 -1
  4. package/dist/components/mint-map/core/MintMapController.js +3 -1
  5. package/dist/components/mint-map/core/MintMapCore.d.ts +1 -1
  6. package/dist/components/mint-map/core/MintMapCore.js +3 -1
  7. package/dist/components/mint-map/core/advanced/MapBuildingProjection.js +4 -4
  8. package/dist/components/mint-map/core/advanced/index.d.ts +1 -0
  9. package/dist/components/mint-map/core/hooks/index.d.ts +1 -0
  10. package/dist/components/mint-map/core/index.d.ts +7 -7
  11. package/dist/components/mint-map/core/provider/MintMapProvider.d.ts +2 -2
  12. package/dist/components/mint-map/core/provider/MintMapProvider.js +1 -1
  13. package/dist/components/mint-map/core/provider/index.d.ts +1 -0
  14. package/dist/components/mint-map/core/util/index.d.ts +3 -0
  15. package/dist/components/mint-map/core/util/waiting.d.ts +1 -1
  16. package/dist/components/mint-map/core/util/waiting.js +33 -0
  17. package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +1 -1
  18. package/dist/components/mint-map/core/wrapper/MapControlWrapper.js +3 -1
  19. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +1 -1
  20. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +3 -1
  21. package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +1 -1
  22. package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +3 -1
  23. package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +1 -1
  24. package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +3 -1
  25. package/dist/components/mint-map/core/wrapper/index.d.ts +4 -0
  26. package/dist/components/mint-map/google/GoogleMintMapController.d.ts +2 -2
  27. package/dist/components/mint-map/google/GoogleMintMapController.js +431 -0
  28. package/dist/components/mint-map/index.d.ts +3 -1
  29. package/dist/components/mint-map/naver/NaverMintMapController.d.ts +2 -2
  30. package/dist/components/mint-map/naver/NaverMintMapController.js +427 -0
  31. package/dist/index.es.js +1095 -197
  32. package/dist/index.js +32 -9
  33. package/dist/index.umd.js +1109 -195
  34. package/package.json +1 -1
@@ -0,0 +1,427 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var MintMapController = require('../core/MintMapController.js');
7
+ var waiting = require('../core/util/waiting.js');
8
+ var MintMap = require('../MintMap.js');
9
+
10
+ var NaverMintMapController = function (_super) {
11
+ tslib.__extends(NaverMintMapController, _super);
12
+
13
+ function NaverMintMapController(props) {
14
+ var _this = _super.call(this, props) || this;
15
+
16
+ _this.type = 'naver';
17
+ _this.map = null;
18
+ _this.scriptUrl = 'https://openapi.map.naver.com/openapi/v3/maps.js';
19
+ _this.scriptModules = ['drawing'];
20
+ _this.polylineEvents = ['mouseover', 'mouseout'];
21
+ _this.polygonEvents = ['mouseover', 'mouseout'];
22
+ _this.markerEvents = ['click', 'mouseover', 'mouseout'];
23
+ _this.dragStartPoint = [0, 0];
24
+ _this.dragged = false;
25
+ console.log("".concat(_this.type, " controller loadded"));
26
+ return _this;
27
+ }
28
+
29
+ NaverMintMapController.prototype.createPolyline = function (polyline) {
30
+ var _this = this;
31
+
32
+ var _a = polyline.options,
33
+ position = _a.position,
34
+ _b = _a.lineColor,
35
+ lineColor = _b === void 0 ? 'blue' : _b,
36
+ _c = _a.lineSize,
37
+ lineSize = _c === void 0 ? 1 : _c,
38
+ _d = _a.lineOpacity,
39
+ lineOpacity = _d === void 0 ? 1 : _d,
40
+ _e = _a.visible,
41
+ visible = _e === void 0 ? true : _e,
42
+ _f = _a.editable,
43
+ editable = _f === void 0 ? false : _f,
44
+ event = _a.event;
45
+
46
+ if (this.map && Array.isArray(position)) {
47
+ var path = position.map(function (elem) {
48
+ return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
49
+ });
50
+ var pol_1 = new naver.maps.Polyline({
51
+ map: this.map,
52
+ path: path,
53
+ strokeColor: lineColor,
54
+ strokeWeight: lineSize,
55
+ strokeOpacity: lineOpacity,
56
+ clickable: true,
57
+ visible: visible
58
+ });
59
+ editable && pol_1.setEditable(editable);
60
+ polyline.native = pol_1;
61
+ event && event.forEach(function (handler, key) {
62
+ if (_this.polylineEvents.includes(key)) {
63
+ naver.maps.Event.addListener(pol_1, key, handler);
64
+ }
65
+ });
66
+ }
67
+ };
68
+
69
+ NaverMintMapController.prototype.updatePolyline = function (polyline, options) {
70
+ if (polyline && polyline.native && polyline.native instanceof naver.maps.Polyline) {
71
+ var path = void 0;
72
+
73
+ if (Array.isArray(options.position)) {
74
+ path = options.position.map(function (elem) {
75
+ return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
76
+ });
77
+ }
78
+
79
+ polyline.native.setOptions({
80
+ path: path || polyline.native.getPath(),
81
+ visible: options.visible === undefined || options.visible,
82
+ strokeColor: options.lineColor,
83
+ strokeWeight: options.lineSize,
84
+ strokeOpacity: options.lineOpacity
85
+ });
86
+ options.editable !== undefined && polyline.native.setEditable(options.editable);
87
+ }
88
+ };
89
+
90
+ NaverMintMapController.prototype.createPolygon = function (polygon) {
91
+ var _this = this;
92
+
93
+ var _a = polygon.options,
94
+ position = _a.position,
95
+ innerPositions = _a.innerPositions,
96
+ _b = _a.lineColor,
97
+ lineColor = _b === void 0 ? 'green' : _b,
98
+ _c = _a.lineSize,
99
+ lineSize = _c === void 0 ? 1 : _c,
100
+ _d = _a.lineOpacity,
101
+ lineOpacity = _d === void 0 ? 1 : _d,
102
+ _e = _a.fillColor,
103
+ fillColor = _e === void 0 ? 'lightgreen' : _e,
104
+ _f = _a.fillOpacity,
105
+ fillOpacity = _f === void 0 ? 0.5 : _f,
106
+ _g = _a.visible,
107
+ visible = _g === void 0 ? true : _g;
108
+ _a.editable;
109
+ var event = _a.event;
110
+
111
+ if (this.map && Array.isArray(position)) {
112
+ var outLine = position.map(function (elem) {
113
+ return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
114
+ });
115
+ var paths = innerPositions ? tslib.__spreadArray([outLine], innerPositions, true) : [outLine];
116
+ var pol_2 = new naver.maps.Polygon({
117
+ map: this.map,
118
+ paths: paths,
119
+ strokeColor: lineColor,
120
+ strokeWeight: lineSize,
121
+ strokeOpacity: lineOpacity,
122
+ fillColor: fillColor,
123
+ fillOpacity: fillOpacity,
124
+ clickable: true,
125
+ visible: visible
126
+ });
127
+ polygon.native = pol_2;
128
+ event && event.forEach(function (handler, key) {
129
+ if (_this.polygonEvents.includes(key)) {
130
+ naver.maps.Event.addListener(pol_2, key, handler);
131
+ }
132
+ });
133
+ }
134
+ };
135
+
136
+ NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
137
+ if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
138
+ polygon.native.setOptions({
139
+ paths: polygon.native.getPaths(),
140
+ visible: options.visible === undefined || options.visible,
141
+ strokeColor: options.lineColor,
142
+ strokeWeight: options.lineSize,
143
+ strokeOpacity: options.lineOpacity,
144
+ fillColor: options.fillColor,
145
+ fillOpacity: options.fillOpacity
146
+ });
147
+ options.editable !== undefined && polygon.native.setEditable(options.editable);
148
+ }
149
+ };
150
+
151
+ NaverMintMapController.prototype.createMarker = function (marker) {
152
+ var _this = this;
153
+
154
+ var _a;
155
+
156
+ if (this.map) {
157
+ var options = {
158
+ map: this.map,
159
+ position: marker.options.position,
160
+ visible: marker.options.visible === undefined || marker.options.visible
161
+ };
162
+ marker.element && (options.icon = {
163
+ content: marker.element,
164
+ anchor: marker.options.anchor
165
+ });
166
+ var naverMarker_1 = new naver.maps.Marker(options);
167
+ marker.native = naverMarker_1;
168
+ ((_a = marker.options) === null || _a === void 0 ? void 0 : _a.event) && marker.options.event.forEach(function (handler, key) {
169
+ if (_this.markerEvents.includes(key)) {
170
+ naver.maps.Event.addListener(naverMarker_1, key, handler);
171
+ }
172
+ });
173
+ }
174
+ };
175
+
176
+ NaverMintMapController.prototype.updateMarker = function (marker, options) {
177
+ if (marker && marker.native && marker.native instanceof naver.maps.Marker) {
178
+ var map = marker.native.getMap();
179
+
180
+ if (map) {
181
+ var newOption = {
182
+ map: map,
183
+ position: options.position instanceof MintMap.Position ? options.position : marker.native.getPosition(),
184
+ visible: options.visible === undefined || options.visible
185
+ };
186
+
187
+ if (options.anchor) {
188
+ newOption.icon = tslib.__assign(tslib.__assign({}, marker.native.getIcon()), {
189
+ anchor: options.anchor
190
+ });
191
+ }
192
+
193
+ marker.native.setOptions({
194
+ map: map,
195
+ position: options.position instanceof MintMap.Position ? options.position : marker.native.getPosition(),
196
+ visible: options.visible === undefined || options.visible,
197
+ icon: tslib.__assign(tslib.__assign({}, marker.native.getIcon()), {
198
+ anchor: options.anchor
199
+ })
200
+ });
201
+ }
202
+ }
203
+ };
204
+
205
+ NaverMintMapController.prototype.getMaxZIndex = function (increment) {
206
+ if (increment === void 0) {
207
+ increment = 0;
208
+ }
209
+
210
+ if (this.map) {
211
+ var targetPane = this.map.getPanes().overlayImage;
212
+ var max = 0;
213
+
214
+ for (var i = 0; i < targetPane.childElementCount; i++) {
215
+ var elem = targetPane.children[i];
216
+
217
+ if (elem instanceof HTMLElement) {
218
+ var index = Number(elem.style.zIndex);
219
+
220
+ if (!isNaN(index) && index > max) {
221
+ max = index;
222
+ }
223
+ }
224
+ }
225
+
226
+ this.markerMaxZIndex = max + increment;
227
+ return this.markerMaxZIndex;
228
+ } else {
229
+ return this.markerMaxZIndex || 1;
230
+ }
231
+ };
232
+
233
+ NaverMintMapController.prototype.markerToTheTop = function (marker) {
234
+ if (this.map && marker.element && marker.element instanceof HTMLElement) {
235
+ var parent_1 = marker.element.parentElement;
236
+
237
+ if (parent_1) {
238
+ parent_1.style.zIndex = String(this.getMaxZIndex(1));
239
+ }
240
+ }
241
+ };
242
+
243
+ NaverMintMapController.prototype.clearDrawable = function (drawable) {
244
+ if (drawable && drawable.native && drawable.native instanceof naver.maps.OverlayView) {
245
+ drawable.native.setMap(null);
246
+ return true;
247
+ }
248
+
249
+ return false;
250
+ };
251
+
252
+ NaverMintMapController.prototype.isMapDragged = function () {
253
+ return this.dragged;
254
+ };
255
+
256
+ NaverMintMapController.prototype.setMapDragged = function (value) {
257
+ this.dragged = false;
258
+ };
259
+
260
+ NaverMintMapController.prototype.loadMapApi = function () {
261
+ return tslib.__awaiter(this, void 0, void 0, function () {
262
+ var _this = this;
263
+
264
+ return tslib.__generator(this, function (_a) {
265
+ return [2, new Promise(function (resolve) {
266
+ return tslib.__awaiter(_this, void 0, void 0, function () {
267
+ var callbackName, loaded, params, ok;
268
+ return tslib.__generator(this, function (_a) {
269
+ switch (_a.label) {
270
+ case 0:
271
+ callbackName = "load".concat(new Date().getTime());
272
+ loaded = false;
273
+
274
+ window[callbackName] = function () {
275
+ console.log('naver api loaded');
276
+ loaded = true;
277
+ delete window[callbackName];
278
+ };
279
+
280
+ params = {
281
+ ncpClientId: this.mapProps.mapKey,
282
+ submodules: this.scriptModules.join(','),
283
+ callback: callbackName
284
+ };
285
+ return [4, this.loadScript(this.buildUrl(this.scriptUrl, params), 'naverscript')];
286
+
287
+ case 1:
288
+ _a.sent();
289
+
290
+ return [4, waiting.waiting(function () {
291
+ return loaded;
292
+ })];
293
+
294
+ case 2:
295
+ ok = _a.sent();
296
+
297
+ if (!ok) {
298
+ throw new Error('naver script api load failed!!');
299
+ }
300
+
301
+ this.mapApiLoaded = true;
302
+ resolve(true);
303
+ console.log("".concat(this.type, " map script loaded"));
304
+ return [2];
305
+ }
306
+ });
307
+ });
308
+ })];
309
+ });
310
+ });
311
+ };
312
+
313
+ NaverMintMapController.prototype.initializingMap = function (divElement) {
314
+ return tslib.__awaiter(this, void 0, void 0, function () {
315
+ var _this = this;
316
+
317
+ return tslib.__generator(this, function (_a) {
318
+ return [2, new Promise(function (resolve) {
319
+ return tslib.__awaiter(_this, void 0, void 0, function () {
320
+ var map;
321
+
322
+ var _this = this;
323
+
324
+ var _a, _b;
325
+
326
+ return tslib.__generator(this, function (_c) {
327
+ switch (_c.label) {
328
+ case 0:
329
+ if (this.mapInitialized && this.map) {
330
+ if (this.map.getElement() === divElement) {
331
+ resolve(this.map);
332
+ return [2];
333
+ } else {
334
+ this.map.destroy();
335
+ }
336
+ }
337
+
338
+ if (!!this.mapApiLoaded) return [3, 2];
339
+ return [4, this.loadMapApi()];
340
+
341
+ case 1:
342
+ _c.sent();
343
+
344
+ _c.label = 2;
345
+
346
+ case 2:
347
+ map = new naver.maps.Map(divElement, {
348
+ center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
349
+ zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
350
+ logoControl: false,
351
+ mapDataControl: false,
352
+ mapTypeControl: false,
353
+ scaleControl: false
354
+ });
355
+ map.addListener('dragstart', function (e) {
356
+ _this.dragStartPoint[0] = e.domEvent.clientX;
357
+ _this.dragStartPoint[1] = e.domEvent.clientY;
358
+ });
359
+ map.addListener('dragend', function (e) {
360
+ if (_this.dragStartPoint[0] === e.domEvent.clientX && _this.dragStartPoint[1] === e.domEvent.clientY) {
361
+ _this.dragged = false;
362
+ } else {
363
+ _this.dragged = true;
364
+ }
365
+
366
+ _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
367
+ });
368
+ map.addListener('zoom_changed', function () {
369
+ _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
370
+ _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
371
+ });
372
+ map.addListener('click', function (e) {
373
+ console.log('map click', e);
374
+ var pos = new MintMap.Position(e.coord.y, e.coord.x);
375
+ pos.offset = new MintMap.Offset(e.offset.x, e.offset.y);
376
+ _this.mapProps.onClick && _this.mapProps.onClick(pos);
377
+ });
378
+ this.map = map;
379
+ this.mapInitialized = true;
380
+ console.log("".concat(this.type, " map script initialized"), divElement);
381
+ resolve(map);
382
+ return [2];
383
+ }
384
+ });
385
+ });
386
+ })];
387
+ });
388
+ });
389
+ };
390
+
391
+ NaverMintMapController.prototype.destroyMap = function () {
392
+ console.log("".concat(this.type, " map destroyed"));
393
+
394
+ try {
395
+ this.map && this.map.destroy();
396
+ } catch (e) {
397
+ console.log('naver map destroy error', e);
398
+ }
399
+ };
400
+
401
+ NaverMintMapController.prototype.getCurrBounds = function () {
402
+ if (!this.map) {
403
+ throw new Error('Map is not initialized!!');
404
+ }
405
+
406
+ var bounds = this.map.getBounds();
407
+ return new MintMap.Bounds(new MintMap.Position(bounds.getMin().y, bounds.getMin().x), new MintMap.Position(bounds.getMax().y, bounds.getMax().x));
408
+ };
409
+
410
+ NaverMintMapController.prototype.panningTo = function (targetCenter) {
411
+ var _a;
412
+
413
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.panTo(targetCenter, {
414
+ duration: 1000
415
+ });
416
+ };
417
+
418
+ NaverMintMapController.prototype.getZoomLevel = function () {
419
+ var _a;
420
+
421
+ return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
422
+ };
423
+
424
+ return NaverMintMapController;
425
+ }(MintMapController.MintMapController);
426
+
427
+ exports.NaverMintMapController = NaverMintMapController;