@mint-ui/map 0.1.7-beta → 0.1.9-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 +53 -53
- package/dist/components/mint-map/MintMap.d.ts +92 -88
- package/dist/components/mint-map/MintMap.js +42 -11
- package/dist/components/mint-map/core/MintMapController.d.ts +33 -32
- package/dist/components/mint-map/core/MintMapCore.d.ts +3 -3
- package/dist/components/mint-map/core/MintMapCore.js +10 -0
- package/dist/components/mint-map/core/advanced/MapBuildingProjection.d.ts +15 -15
- package/dist/components/mint-map/core/advanced/index.d.ts +1 -1
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.d.ts +6 -6
- package/dist/components/mint-map/core/hooks/index.d.ts +1 -1
- package/dist/components/mint-map/core/index.d.ts +7 -7
- 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/calculate.d.ts +34 -29
- package/dist/components/mint-map/core/util/calculate.js +68 -8
- package/dist/components/mint-map/core/util/index.d.ts +3 -3
- package/dist/components/mint-map/core/util/waiting.d.ts +1 -1
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +11 -11
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +23 -23
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +2 -4
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +5 -5
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +5 -5
- package/dist/components/mint-map/core/wrapper/index.d.ts +4 -4
- package/dist/components/mint-map/google/GoogleMintMapController.d.ts +35 -34
- package/dist/components/mint-map/google/GoogleMintMapController.js +19 -8
- package/dist/components/mint-map/index.d.ts +4 -4
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +38 -36
- package/dist/components/mint-map/naver/NaverMintMapController.js +45 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +186 -42
- package/dist/index.umd.js +186 -42
- package/package.json +76 -76
- package/test.ts +6 -6
|
@@ -339,10 +339,10 @@ var GoogleMintMapController = function (_super) {
|
|
|
339
339
|
|
|
340
340
|
var _this = this;
|
|
341
341
|
|
|
342
|
-
var _a, _b;
|
|
342
|
+
var _a, _b, _c, _d;
|
|
343
343
|
|
|
344
|
-
return tslib.__generator(this, function (
|
|
345
|
-
switch (
|
|
344
|
+
return tslib.__generator(this, function (_e) {
|
|
345
|
+
switch (_e.label) {
|
|
346
346
|
case 0:
|
|
347
347
|
if (this.mapInitialized && this.map) {
|
|
348
348
|
if (this.map.getDiv() === divElement) {
|
|
@@ -355,22 +355,27 @@ var GoogleMintMapController = function (_super) {
|
|
|
355
355
|
return [4, this.loadMapApi()];
|
|
356
356
|
|
|
357
357
|
case 1:
|
|
358
|
-
|
|
358
|
+
_e.sent();
|
|
359
359
|
|
|
360
|
-
|
|
360
|
+
_e.label = 2;
|
|
361
361
|
|
|
362
362
|
case 2:
|
|
363
363
|
map = new google.maps.Map(divElement, {
|
|
364
364
|
mapId: this.mapProps.mapId,
|
|
365
365
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
366
|
-
maxZoom:
|
|
367
|
-
minZoom:
|
|
368
|
-
zoom: (
|
|
366
|
+
maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
|
|
367
|
+
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
368
|
+
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
369
|
+
disableDefaultUI: true,
|
|
370
|
+
gestureHandling: 'greedy'
|
|
369
371
|
});
|
|
370
372
|
map.addListener('dragend', function () {
|
|
371
373
|
console.log('map dragend');
|
|
372
374
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
373
375
|
});
|
|
376
|
+
map.addListener('idle', function () {
|
|
377
|
+
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
378
|
+
});
|
|
374
379
|
map.addListener('zoom_changed', function () {
|
|
375
380
|
console.log('zoom_changed');
|
|
376
381
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
@@ -425,6 +430,12 @@ var GoogleMintMapController = function (_super) {
|
|
|
425
430
|
return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
|
|
426
431
|
};
|
|
427
432
|
|
|
433
|
+
GoogleMintMapController.prototype.setZoomLevel = function (zoom) {
|
|
434
|
+
var _a;
|
|
435
|
+
|
|
436
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
|
|
437
|
+
};
|
|
438
|
+
|
|
428
439
|
return GoogleMintMapController;
|
|
429
440
|
}(MintMapController.MintMapController);
|
|
430
441
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './MintMap';
|
|
2
|
-
export * from './core';
|
|
3
|
-
export * from './naver/NaverMintMapController';
|
|
4
|
-
export * from './google/GoogleMintMapController';
|
|
1
|
+
export * from './MintMap';
|
|
2
|
+
export * from './core';
|
|
3
|
+
export * from './naver/NaverMintMapController';
|
|
4
|
+
export * from './google/GoogleMintMapController';
|
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
/// <reference types="navermaps" />
|
|
2
|
-
import { MintMapController } from "../core/MintMapController";
|
|
3
|
-
import { Bounds, Drawable, MapType, MapVendorType, Marker, MarkerOptions, MintMapProps, Polygon, PolygonOptions, Polyline, PolylineOptions, Position } from "../MintMap";
|
|
4
|
-
import { ObjectPool } from '@mint-ui/tools';
|
|
5
|
-
export declare class NaverMintMapController extends MintMapController {
|
|
6
|
-
type: MapType;
|
|
7
|
-
map: naver.maps.Map | null;
|
|
8
|
-
scriptUrl: string;
|
|
9
|
-
scriptModules: string[];
|
|
10
|
-
markerPool?: ObjectPool<naver.maps.Marker>;
|
|
11
|
-
constructor(props: MintMapProps);
|
|
12
|
-
private initMarkerPool;
|
|
13
|
-
polylineEvents: string[];
|
|
14
|
-
createPolyline(polyline: Polyline): void;
|
|
15
|
-
updatePolyline(polyline: Polyline, options: PolylineOptions): void;
|
|
16
|
-
polygonEvents: string[];
|
|
17
|
-
createPolygon(polygon: Polygon): void;
|
|
18
|
-
updatePolygon(polygon: Polygon, options: PolygonOptions): void;
|
|
19
|
-
markerEvents: string[];
|
|
20
|
-
createMarker(marker: Marker): void;
|
|
21
|
-
updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
22
|
-
private markerMaxZIndex;
|
|
23
|
-
private getMaxZIndex;
|
|
24
|
-
markerToTheTop(marker: Marker): void;
|
|
25
|
-
clearDrawable(drawable: Drawable): boolean;
|
|
26
|
-
private dragStartPoint;
|
|
27
|
-
private dragged;
|
|
28
|
-
isMapDragged(): boolean;
|
|
29
|
-
setMapDragged(value: boolean): void;
|
|
30
|
-
loadMapApi(): Promise<boolean>;
|
|
31
|
-
initializingMap(divElement: HTMLDivElement): Promise<MapVendorType>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
/// <reference types="navermaps" />
|
|
2
|
+
import { MintMapController } from "../core/MintMapController";
|
|
3
|
+
import { Bounds, Drawable, MapType, MapVendorType, Marker, MarkerOptions, MintMapProps, Polygon, PolygonOptions, Polyline, PolylineOptions, Position } from "../MintMap";
|
|
4
|
+
import { ObjectPool } from '@mint-ui/tools';
|
|
5
|
+
export declare class NaverMintMapController extends MintMapController {
|
|
6
|
+
type: MapType;
|
|
7
|
+
map: naver.maps.Map | null;
|
|
8
|
+
scriptUrl: string;
|
|
9
|
+
scriptModules: string[];
|
|
10
|
+
markerPool?: ObjectPool<naver.maps.Marker>;
|
|
11
|
+
constructor(props: MintMapProps);
|
|
12
|
+
private initMarkerPool;
|
|
13
|
+
polylineEvents: string[];
|
|
14
|
+
createPolyline(polyline: Polyline): void;
|
|
15
|
+
updatePolyline(polyline: Polyline, options: PolylineOptions): void;
|
|
16
|
+
polygonEvents: string[];
|
|
17
|
+
createPolygon(polygon: Polygon): void;
|
|
18
|
+
updatePolygon(polygon: Polygon, options: PolygonOptions): void;
|
|
19
|
+
markerEvents: string[];
|
|
20
|
+
createMarker(marker: Marker): void;
|
|
21
|
+
updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
22
|
+
private markerMaxZIndex;
|
|
23
|
+
private getMaxZIndex;
|
|
24
|
+
markerToTheTop(marker: Marker): void;
|
|
25
|
+
clearDrawable(drawable: Drawable): boolean;
|
|
26
|
+
private dragStartPoint;
|
|
27
|
+
private dragged;
|
|
28
|
+
isMapDragged(): boolean;
|
|
29
|
+
setMapDragged(value: boolean): void;
|
|
30
|
+
loadMapApi(): Promise<boolean>;
|
|
31
|
+
initializingMap(divElement: HTMLDivElement): Promise<MapVendorType>;
|
|
32
|
+
private getSafeZoomValue;
|
|
33
|
+
destroyMap(): void;
|
|
34
|
+
getCurrBounds(): Bounds;
|
|
35
|
+
panningTo(targetCenter: Position): void;
|
|
36
|
+
getZoomLevel(): number;
|
|
37
|
+
setZoomLevel(zoom: number): void;
|
|
38
|
+
}
|
|
@@ -38,7 +38,7 @@ var NaverMintMapController = function (_super) {
|
|
|
38
38
|
});
|
|
39
39
|
}).setClear(function (item) {
|
|
40
40
|
item.setMap(null);
|
|
41
|
-
}).createPool(1000).setCheckLiveTimeInterval(1000);
|
|
41
|
+
}).createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000).setCheckLiveTimeInterval(1000);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -351,14 +351,14 @@ var NaverMintMapController = function (_super) {
|
|
|
351
351
|
return tslib.__generator(this, function (_a) {
|
|
352
352
|
return [2, new Promise(function (resolve) {
|
|
353
353
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
354
|
-
var map;
|
|
354
|
+
var options, maxZoom, minZoom, map;
|
|
355
355
|
|
|
356
356
|
var _this = this;
|
|
357
357
|
|
|
358
|
-
var _a, _b;
|
|
358
|
+
var _a, _b, _c, _d;
|
|
359
359
|
|
|
360
|
-
return tslib.__generator(this, function (
|
|
361
|
-
switch (
|
|
360
|
+
return tslib.__generator(this, function (_e) {
|
|
361
|
+
switch (_e.label) {
|
|
362
362
|
case 0:
|
|
363
363
|
if (this.mapInitialized && this.map) {
|
|
364
364
|
if (this.map.getElement() === divElement) {
|
|
@@ -373,19 +373,37 @@ var NaverMintMapController = function (_super) {
|
|
|
373
373
|
return [4, this.loadMapApi()];
|
|
374
374
|
|
|
375
375
|
case 1:
|
|
376
|
-
|
|
376
|
+
_e.sent();
|
|
377
377
|
|
|
378
|
-
|
|
378
|
+
_e.label = 2;
|
|
379
379
|
|
|
380
380
|
case 2:
|
|
381
|
-
|
|
381
|
+
options = {
|
|
382
382
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
383
383
|
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
384
384
|
logoControl: false,
|
|
385
385
|
mapDataControl: false,
|
|
386
386
|
mapTypeControl: false,
|
|
387
387
|
scaleControl: false
|
|
388
|
-
}
|
|
388
|
+
};
|
|
389
|
+
maxZoom = 21;
|
|
390
|
+
minZoom = 6;
|
|
391
|
+
|
|
392
|
+
if ((_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.maxZoomLevel) {
|
|
393
|
+
maxZoom = this.getSafeZoomValue(this.mapProps.base.maxZoomLevel);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if ((_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.minZoomLevel) {
|
|
397
|
+
minZoom = this.getSafeZoomValue(this.mapProps.base.minZoomLevel);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (minZoom > maxZoom) {
|
|
401
|
+
minZoom = 6;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
options.minZoom = minZoom;
|
|
405
|
+
options.maxZoom = maxZoom;
|
|
406
|
+
map = new naver.maps.Map(divElement, options);
|
|
389
407
|
map.addListener('dragstart', function (e) {
|
|
390
408
|
_this.dragStartPoint[0] = e.domEvent.clientX;
|
|
391
409
|
_this.dragStartPoint[1] = e.domEvent.clientY;
|
|
@@ -396,12 +414,12 @@ var NaverMintMapController = function (_super) {
|
|
|
396
414
|
} else {
|
|
397
415
|
_this.dragged = true;
|
|
398
416
|
}
|
|
399
|
-
|
|
417
|
+
});
|
|
418
|
+
map.addListener('idle', function () {
|
|
400
419
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
401
420
|
});
|
|
402
421
|
map.addListener('zoom_changed', function () {
|
|
403
422
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
404
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
405
423
|
});
|
|
406
424
|
map.addListener('click', function (e) {
|
|
407
425
|
console.log('map click', e);
|
|
@@ -423,6 +441,16 @@ var NaverMintMapController = function (_super) {
|
|
|
423
441
|
});
|
|
424
442
|
};
|
|
425
443
|
|
|
444
|
+
NaverMintMapController.prototype.getSafeZoomValue = function (value) {
|
|
445
|
+
if (value > 21) {
|
|
446
|
+
return 21;
|
|
447
|
+
} else if (value < 6) {
|
|
448
|
+
return 6;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return value;
|
|
452
|
+
};
|
|
453
|
+
|
|
426
454
|
NaverMintMapController.prototype.destroyMap = function () {
|
|
427
455
|
var _a;
|
|
428
456
|
|
|
@@ -459,6 +487,12 @@ var NaverMintMapController = function (_super) {
|
|
|
459
487
|
return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
|
|
460
488
|
};
|
|
461
489
|
|
|
490
|
+
NaverMintMapController.prototype.setZoomLevel = function (zoom) {
|
|
491
|
+
var _a;
|
|
492
|
+
|
|
493
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom, true);
|
|
494
|
+
};
|
|
495
|
+
|
|
462
496
|
return NaverMintMapController;
|
|
463
497
|
}(MintMapController.MintMapController);
|
|
464
498
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './components/mint-map';
|
|
1
|
+
export * from './components/mint-map';
|
package/dist/index.es.js
CHANGED
|
@@ -38,6 +38,7 @@ function MintMapCore(_a) {
|
|
|
38
38
|
var onLoad = _a.onLoad,
|
|
39
39
|
_b = _a.visible,
|
|
40
40
|
visible = _b === void 0 ? true : _b,
|
|
41
|
+
base = _a.base,
|
|
41
42
|
children = _a.children;
|
|
42
43
|
var controller = useMintMapController();
|
|
43
44
|
var elementRef = useRef(null);
|
|
@@ -75,6 +76,15 @@ function MintMapCore(_a) {
|
|
|
75
76
|
controller && controller.destroyMap();
|
|
76
77
|
};
|
|
77
78
|
}, [controller, elementRef]);
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
if ((base === null || base === void 0 ? void 0 : base.zoomLevel) && controller && mapInitialized) {
|
|
81
|
+
var prevZoomLevel = controller === null || controller === void 0 ? void 0 : controller.getZoomLevel();
|
|
82
|
+
|
|
83
|
+
if (prevZoomLevel !== base.zoomLevel) {
|
|
84
|
+
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(base.zoomLevel);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, [base]);
|
|
78
88
|
return React.createElement("div", {
|
|
79
89
|
className: cn$2('mint-map-root'),
|
|
80
90
|
style: {
|
|
@@ -148,22 +158,82 @@ var PolygonCalculator = function () {
|
|
|
148
158
|
return false;
|
|
149
159
|
};
|
|
150
160
|
|
|
161
|
+
PolygonCalculator.getIncludedPositions = function (polygon, position) {
|
|
162
|
+
var targets = Array.isArray(position) ? position : [position];
|
|
163
|
+
var result = [];
|
|
164
|
+
var maxX = Math.max.apply(Math, polygon.map(function (pos) {
|
|
165
|
+
return pos.lng;
|
|
166
|
+
})) + 1;
|
|
167
|
+
var lines = this.convertPolygonToLinePoints(polygon);
|
|
168
|
+
|
|
169
|
+
for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
|
|
170
|
+
var target = targets_1[_i];
|
|
171
|
+
var tempLine = this.convertPositionToPoints(target, new Position(target.lat, maxX));
|
|
172
|
+
var crossPoints = this.getCrossPointAll(lines, tempLine);
|
|
173
|
+
|
|
174
|
+
if (crossPoints.length > 0 && crossPoints.length % 2 != 0) {
|
|
175
|
+
result.push(target);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
PolygonCalculator.convertPolygonToLinePoints = function (polygon) {
|
|
183
|
+
var lines = [];
|
|
184
|
+
|
|
185
|
+
for (var i = 0; i < polygon.length; i++) {
|
|
186
|
+
lines.push(this.convertPositionToPoints(polygon[i], polygon[i + 1 === polygon.length ? 0 : i + 1]));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return lines;
|
|
190
|
+
};
|
|
191
|
+
|
|
151
192
|
PolygonCalculator.convertPositionToPoints = function (pos1, pos2) {
|
|
152
193
|
return new LinePoints(pos1.lng, pos1.lat, pos2.lng, pos2.lat);
|
|
153
194
|
};
|
|
154
195
|
|
|
155
|
-
PolygonCalculator.
|
|
196
|
+
PolygonCalculator.getCrossPoint = function (sr, tr) {
|
|
197
|
+
var p1 = (sr.x1 - sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 - tr.x2);
|
|
198
|
+
|
|
199
|
+
if (p1 != 0) {
|
|
200
|
+
var x = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.x1 - tr.x2) - (sr.x1 - sr.x2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
201
|
+
var y = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
202
|
+
|
|
203
|
+
if (this.toFixedPosition((x - sr.x1) * (x - sr.x2)) <= 0 && this.toFixedPosition((y - sr.y1) * (y - sr.y2)) <= 0 && this.toFixedPosition((x - tr.x1) * (x - tr.x2)) <= 0 && this.toFixedPosition((y - tr.y1) * (y - tr.y2)) <= 0) {
|
|
204
|
+
return {
|
|
205
|
+
x: x,
|
|
206
|
+
y: y
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
PolygonCalculator.toFixedPosition = function (n) {
|
|
213
|
+
return Number(n.toFixed(15));
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
PolygonCalculator.getCrossPointAll = function (sr, tr) {
|
|
217
|
+
var result = [];
|
|
218
|
+
|
|
156
219
|
for (var _i = 0, sr_1 = sr; _i < sr_1.length; _i++) {
|
|
157
220
|
var tmp = sr_1[_i];
|
|
158
|
-
var
|
|
221
|
+
var p = this.getCrossPoint(tmp, tr);
|
|
159
222
|
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
223
|
+
if (p) {
|
|
224
|
+
result.push(p);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
163
227
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
228
|
+
return result;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
PolygonCalculator.findCrossPoint = function (sr, tr) {
|
|
232
|
+
for (var _i = 0, sr_2 = sr; _i < sr_2.length; _i++) {
|
|
233
|
+
var tmp = sr_2[_i];
|
|
234
|
+
|
|
235
|
+
if (this.getCrossPoint(tmp, tr)) {
|
|
236
|
+
return true;
|
|
167
237
|
}
|
|
168
238
|
}
|
|
169
239
|
|
|
@@ -352,7 +422,7 @@ var NaverMintMapController = function (_super) {
|
|
|
352
422
|
});
|
|
353
423
|
}).setClear(function (item) {
|
|
354
424
|
item.setMap(null);
|
|
355
|
-
}).createPool(1000).setCheckLiveTimeInterval(1000);
|
|
425
|
+
}).createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000).setCheckLiveTimeInterval(1000);
|
|
356
426
|
};
|
|
357
427
|
|
|
358
428
|
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -665,14 +735,14 @@ var NaverMintMapController = function (_super) {
|
|
|
665
735
|
return __generator(this, function (_a) {
|
|
666
736
|
return [2, new Promise(function (resolve) {
|
|
667
737
|
return __awaiter(_this, void 0, void 0, function () {
|
|
668
|
-
var map;
|
|
738
|
+
var options, maxZoom, minZoom, map;
|
|
669
739
|
|
|
670
740
|
var _this = this;
|
|
671
741
|
|
|
672
|
-
var _a, _b;
|
|
742
|
+
var _a, _b, _c, _d;
|
|
673
743
|
|
|
674
|
-
return __generator(this, function (
|
|
675
|
-
switch (
|
|
744
|
+
return __generator(this, function (_e) {
|
|
745
|
+
switch (_e.label) {
|
|
676
746
|
case 0:
|
|
677
747
|
if (this.mapInitialized && this.map) {
|
|
678
748
|
if (this.map.getElement() === divElement) {
|
|
@@ -687,19 +757,37 @@ var NaverMintMapController = function (_super) {
|
|
|
687
757
|
return [4, this.loadMapApi()];
|
|
688
758
|
|
|
689
759
|
case 1:
|
|
690
|
-
|
|
760
|
+
_e.sent();
|
|
691
761
|
|
|
692
|
-
|
|
762
|
+
_e.label = 2;
|
|
693
763
|
|
|
694
764
|
case 2:
|
|
695
|
-
|
|
765
|
+
options = {
|
|
696
766
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
697
767
|
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
698
768
|
logoControl: false,
|
|
699
769
|
mapDataControl: false,
|
|
700
770
|
mapTypeControl: false,
|
|
701
771
|
scaleControl: false
|
|
702
|
-
}
|
|
772
|
+
};
|
|
773
|
+
maxZoom = 21;
|
|
774
|
+
minZoom = 6;
|
|
775
|
+
|
|
776
|
+
if ((_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.maxZoomLevel) {
|
|
777
|
+
maxZoom = this.getSafeZoomValue(this.mapProps.base.maxZoomLevel);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if ((_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.minZoomLevel) {
|
|
781
|
+
minZoom = this.getSafeZoomValue(this.mapProps.base.minZoomLevel);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (minZoom > maxZoom) {
|
|
785
|
+
minZoom = 6;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
options.minZoom = minZoom;
|
|
789
|
+
options.maxZoom = maxZoom;
|
|
790
|
+
map = new naver.maps.Map(divElement, options);
|
|
703
791
|
map.addListener('dragstart', function (e) {
|
|
704
792
|
_this.dragStartPoint[0] = e.domEvent.clientX;
|
|
705
793
|
_this.dragStartPoint[1] = e.domEvent.clientY;
|
|
@@ -710,12 +798,12 @@ var NaverMintMapController = function (_super) {
|
|
|
710
798
|
} else {
|
|
711
799
|
_this.dragged = true;
|
|
712
800
|
}
|
|
713
|
-
|
|
801
|
+
});
|
|
802
|
+
map.addListener('idle', function () {
|
|
714
803
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
715
804
|
});
|
|
716
805
|
map.addListener('zoom_changed', function () {
|
|
717
806
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
718
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
719
807
|
});
|
|
720
808
|
map.addListener('click', function (e) {
|
|
721
809
|
console.log('map click', e);
|
|
@@ -737,6 +825,16 @@ var NaverMintMapController = function (_super) {
|
|
|
737
825
|
});
|
|
738
826
|
};
|
|
739
827
|
|
|
828
|
+
NaverMintMapController.prototype.getSafeZoomValue = function (value) {
|
|
829
|
+
if (value > 21) {
|
|
830
|
+
return 21;
|
|
831
|
+
} else if (value < 6) {
|
|
832
|
+
return 6;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
return value;
|
|
836
|
+
};
|
|
837
|
+
|
|
740
838
|
NaverMintMapController.prototype.destroyMap = function () {
|
|
741
839
|
var _a;
|
|
742
840
|
|
|
@@ -773,6 +871,12 @@ var NaverMintMapController = function (_super) {
|
|
|
773
871
|
return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
|
|
774
872
|
};
|
|
775
873
|
|
|
874
|
+
NaverMintMapController.prototype.setZoomLevel = function (zoom) {
|
|
875
|
+
var _a;
|
|
876
|
+
|
|
877
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom, true);
|
|
878
|
+
};
|
|
879
|
+
|
|
776
880
|
return NaverMintMapController;
|
|
777
881
|
}(MintMapController);
|
|
778
882
|
|
|
@@ -1108,10 +1212,10 @@ var GoogleMintMapController = function (_super) {
|
|
|
1108
1212
|
|
|
1109
1213
|
var _this = this;
|
|
1110
1214
|
|
|
1111
|
-
var _a, _b;
|
|
1215
|
+
var _a, _b, _c, _d;
|
|
1112
1216
|
|
|
1113
|
-
return __generator(this, function (
|
|
1114
|
-
switch (
|
|
1217
|
+
return __generator(this, function (_e) {
|
|
1218
|
+
switch (_e.label) {
|
|
1115
1219
|
case 0:
|
|
1116
1220
|
if (this.mapInitialized && this.map) {
|
|
1117
1221
|
if (this.map.getDiv() === divElement) {
|
|
@@ -1124,22 +1228,27 @@ var GoogleMintMapController = function (_super) {
|
|
|
1124
1228
|
return [4, this.loadMapApi()];
|
|
1125
1229
|
|
|
1126
1230
|
case 1:
|
|
1127
|
-
|
|
1231
|
+
_e.sent();
|
|
1128
1232
|
|
|
1129
|
-
|
|
1233
|
+
_e.label = 2;
|
|
1130
1234
|
|
|
1131
1235
|
case 2:
|
|
1132
1236
|
map = new google.maps.Map(divElement, {
|
|
1133
1237
|
mapId: this.mapProps.mapId,
|
|
1134
1238
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
1135
|
-
maxZoom:
|
|
1136
|
-
minZoom:
|
|
1137
|
-
zoom: (
|
|
1239
|
+
maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
|
|
1240
|
+
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
1241
|
+
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
1242
|
+
disableDefaultUI: true,
|
|
1243
|
+
gestureHandling: 'greedy'
|
|
1138
1244
|
});
|
|
1139
1245
|
map.addListener('dragend', function () {
|
|
1140
1246
|
console.log('map dragend');
|
|
1141
1247
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1142
1248
|
});
|
|
1249
|
+
map.addListener('idle', function () {
|
|
1250
|
+
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1251
|
+
});
|
|
1143
1252
|
map.addListener('zoom_changed', function () {
|
|
1144
1253
|
console.log('zoom_changed');
|
|
1145
1254
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
@@ -1194,6 +1303,12 @@ var GoogleMintMapController = function (_super) {
|
|
|
1194
1303
|
return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
|
|
1195
1304
|
};
|
|
1196
1305
|
|
|
1306
|
+
GoogleMintMapController.prototype.setZoomLevel = function (zoom) {
|
|
1307
|
+
var _a;
|
|
1308
|
+
|
|
1309
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1197
1312
|
return GoogleMintMapController;
|
|
1198
1313
|
}(MintMapController);
|
|
1199
1314
|
|
|
@@ -1248,10 +1363,26 @@ var Bounds = function () {
|
|
|
1248
1363
|
return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
1249
1364
|
};
|
|
1250
1365
|
|
|
1251
|
-
Bounds.prototype.
|
|
1366
|
+
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
1367
|
+
var result = [];
|
|
1368
|
+
|
|
1252
1369
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
1253
1370
|
var pos = positions_1[_i];
|
|
1254
1371
|
|
|
1372
|
+
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1373
|
+
result.push(pos);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
return result;
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
Bounds.prototype.includes = function (positions) {
|
|
1381
|
+
positions = Array.isArray(positions) ? positions : [positions];
|
|
1382
|
+
|
|
1383
|
+
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
1384
|
+
var pos = positions_2[_i];
|
|
1385
|
+
|
|
1255
1386
|
if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
|
|
1256
1387
|
return false;
|
|
1257
1388
|
}
|
|
@@ -1261,8 +1392,8 @@ var Bounds = function () {
|
|
|
1261
1392
|
};
|
|
1262
1393
|
|
|
1263
1394
|
Bounds.prototype.includesOnlyOnePoint = function (positions) {
|
|
1264
|
-
for (var _i = 0,
|
|
1265
|
-
var pos =
|
|
1395
|
+
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
1396
|
+
var pos = positions_3[_i];
|
|
1266
1397
|
|
|
1267
1398
|
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1268
1399
|
return true;
|
|
@@ -1344,23 +1475,36 @@ var Polygon = function (_super) {
|
|
|
1344
1475
|
return Polygon;
|
|
1345
1476
|
}(Drawable);
|
|
1346
1477
|
var cn$1 = classNames.bind(styles$2);
|
|
1478
|
+
var DEFAULT_CENTER = {
|
|
1479
|
+
lat: 37.5036845,
|
|
1480
|
+
lng: 127.0448698
|
|
1481
|
+
};
|
|
1347
1482
|
function MintMap(_a) {
|
|
1348
1483
|
var mapType = _a.mapType,
|
|
1349
1484
|
children = _a.children,
|
|
1350
|
-
|
|
1485
|
+
_b = _a.base,
|
|
1486
|
+
base = _b === void 0 ? {
|
|
1487
|
+
center: DEFAULT_CENTER,
|
|
1488
|
+
zoomLevel: 12
|
|
1489
|
+
} : _b,
|
|
1490
|
+
props = __rest(_a, ["mapType", "children", "base"]);
|
|
1351
1491
|
|
|
1352
|
-
var
|
|
1353
|
-
controller =
|
|
1354
|
-
setController =
|
|
1492
|
+
var _c = useState(),
|
|
1493
|
+
controller = _c[0],
|
|
1494
|
+
setController = _c[1];
|
|
1355
1495
|
|
|
1356
1496
|
useEffect(function () {
|
|
1357
1497
|
if (mapType && mapType.length > 0) {
|
|
1358
1498
|
setController(undefined);
|
|
1359
|
-
var newController_1 = mapType === 'naver' ? new NaverMintMapController(__assign({
|
|
1499
|
+
var newController_1 = mapType === 'naver' ? new NaverMintMapController(__assign(__assign({
|
|
1360
1500
|
mapType: mapType
|
|
1361
|
-
}, props)
|
|
1501
|
+
}, props), {
|
|
1502
|
+
base: base
|
|
1503
|
+
})) : mapType === 'google' ? new GoogleMintMapController(__assign(__assign({
|
|
1362
1504
|
mapType: mapType
|
|
1363
|
-
}, props)
|
|
1505
|
+
}, props), {
|
|
1506
|
+
base: base
|
|
1507
|
+
})) : null;
|
|
1364
1508
|
|
|
1365
1509
|
if (newController_1) {
|
|
1366
1510
|
newController_1.loadMapApi().then(function () {
|
|
@@ -1377,7 +1521,9 @@ function MintMap(_a) {
|
|
|
1377
1521
|
controller: controller
|
|
1378
1522
|
}, React.createElement(MintMapCore, __assign({
|
|
1379
1523
|
mapType: mapType
|
|
1380
|
-
}, props
|
|
1524
|
+
}, props, {
|
|
1525
|
+
base: base
|
|
1526
|
+
}), children)) : React.createElement(PointLoading, {
|
|
1381
1527
|
text: "Loading"
|
|
1382
1528
|
}));
|
|
1383
1529
|
}
|
|
@@ -1717,7 +1863,7 @@ function MapMarkerWrapper(_a) {
|
|
|
1717
1863
|
divCloneRef.current && divCloneRef.current.removeEventListener('animationend', aniListener_1);
|
|
1718
1864
|
|
|
1719
1865
|
if (markerRef.current) {
|
|
1720
|
-
|
|
1866
|
+
controller.clearDrawable(markerRef.current);
|
|
1721
1867
|
}
|
|
1722
1868
|
|
|
1723
1869
|
divCloneRef.current = undefined;
|
|
@@ -1730,7 +1876,7 @@ function MapMarkerWrapper(_a) {
|
|
|
1730
1876
|
divElement.removeEventListener('mouseover', onMouseOverHandler);
|
|
1731
1877
|
|
|
1732
1878
|
if (markerRef.current) {
|
|
1733
|
-
|
|
1879
|
+
controller.clearDrawable(markerRef.current);
|
|
1734
1880
|
}
|
|
1735
1881
|
}
|
|
1736
1882
|
};
|
|
@@ -1738,11 +1884,9 @@ function MapMarkerWrapper(_a) {
|
|
|
1738
1884
|
useEffect(function () {
|
|
1739
1885
|
if (options) {
|
|
1740
1886
|
if (markerRef.current) {
|
|
1741
|
-
console.log('update Marker');
|
|
1742
1887
|
controller.updateMarker(markerRef.current, options);
|
|
1743
1888
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
1744
1889
|
} else {
|
|
1745
|
-
console.log('create Marker');
|
|
1746
1890
|
markerRef.current = new Marker(options);
|
|
1747
1891
|
markerRef.current.element = divElement;
|
|
1748
1892
|
controller.createMarker(markerRef.current);
|