@mint-ui/map 0.3.4-beta → 0.3.6-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/mint-map/MintMap.d.ts +8 -1
- package/dist/components/mint-map/MintMap.js +13 -5
- package/dist/components/mint-map/core/MintMapController.d.ts +3 -0
- package/dist/components/mint-map/core/MintMapCore.d.ts +1 -1
- package/dist/components/mint-map/core/MintMapCore.js +20 -9
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +8 -0
- package/dist/components/mint-map/google/GoogleMintMapController.d.ts +3 -0
- package/dist/components/mint-map/google/GoogleMintMapController.js +24 -3
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +3 -0
- package/dist/components/mint-map/naver/NaverMintMapController.js +19 -2
- package/dist/index.es.js +84 -20
- package/dist/index.umd.js +83 -19
- package/package.json +1 -1
|
@@ -10,9 +10,14 @@ export interface MintMapProps extends MintMapEvents {
|
|
|
10
10
|
mapId?: string;
|
|
11
11
|
base?: BaseProps;
|
|
12
12
|
visible?: boolean;
|
|
13
|
+
center?: Position;
|
|
14
|
+
zoomLevel?: number;
|
|
15
|
+
draggable?: boolean;
|
|
16
|
+
keyboardShortcuts?: boolean;
|
|
13
17
|
markerCache?: boolean;
|
|
14
18
|
markerCachePoolSize?: number;
|
|
15
19
|
boundsChangeThrottlingTime?: number;
|
|
20
|
+
mapLoadingComponent?: () => JSX.Element;
|
|
16
21
|
}
|
|
17
22
|
export interface MintMapEvents {
|
|
18
23
|
onBoundsChanged?: (bounds: Bounds) => void;
|
|
@@ -26,6 +31,7 @@ export declare class Position {
|
|
|
26
31
|
lng: number;
|
|
27
32
|
offset?: Offset;
|
|
28
33
|
constructor(lat: number, lng: number);
|
|
34
|
+
static equals(pos1: Position, pos2: Position): boolean;
|
|
29
35
|
}
|
|
30
36
|
export declare class Bounds {
|
|
31
37
|
nw: Position;
|
|
@@ -66,6 +72,7 @@ export declare abstract class Drawable {
|
|
|
66
72
|
}
|
|
67
73
|
export interface MarkerOptions extends DrawableOptions {
|
|
68
74
|
anchor?: Offset;
|
|
75
|
+
zIndex?: number;
|
|
69
76
|
}
|
|
70
77
|
export declare class Marker extends Drawable {
|
|
71
78
|
options: MarkerOptions;
|
|
@@ -92,4 +99,4 @@ export declare class Polygon extends Drawable {
|
|
|
92
99
|
constructor(options: PolygonOptions);
|
|
93
100
|
getCenter(): Position;
|
|
94
101
|
}
|
|
95
|
-
export declare function MintMap({ mapType, children, base, ...props }: PropsWithChildren<MintMapProps>): JSX.Element;
|
|
102
|
+
export declare function MintMap({ mapLoadingComponent, mapType, children, base, ...props }: PropsWithChildren<MintMapProps>): JSX.Element;
|
|
@@ -25,6 +25,10 @@ var Position = function () {
|
|
|
25
25
|
this.lng = lng;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
Position.equals = function (pos1, pos2) {
|
|
29
|
+
return pos1.lat === pos2.lat && pos1.lng === pos2.lng;
|
|
30
|
+
};
|
|
31
|
+
|
|
28
32
|
return Position;
|
|
29
33
|
}();
|
|
30
34
|
|
|
@@ -189,19 +193,25 @@ var DEFAULT_CENTER = {
|
|
|
189
193
|
lng: 127.0448698
|
|
190
194
|
};
|
|
191
195
|
function MintMap(_a) {
|
|
192
|
-
var
|
|
196
|
+
var mapLoadingComponent = _a.mapLoadingComponent,
|
|
197
|
+
mapType = _a.mapType,
|
|
193
198
|
children = _a.children,
|
|
194
199
|
_b = _a.base,
|
|
195
200
|
base = _b === void 0 ? {
|
|
196
201
|
center: DEFAULT_CENTER,
|
|
197
202
|
zoomLevel: 12
|
|
198
203
|
} : _b,
|
|
199
|
-
props = tslib.__rest(_a, ["mapType", "children", "base"]);
|
|
204
|
+
props = tslib.__rest(_a, ["mapLoadingComponent", "mapType", "children", "base"]);
|
|
200
205
|
|
|
201
206
|
var _c = React.useState(),
|
|
202
207
|
controller = _c[0],
|
|
203
208
|
setController = _c[1];
|
|
204
209
|
|
|
210
|
+
var loading = React.useMemo(function () {
|
|
211
|
+
return mapLoadingComponent ? mapLoadingComponent() : React__default["default"].createElement(PointLoading, {
|
|
212
|
+
text: "Loading"
|
|
213
|
+
});
|
|
214
|
+
}, [mapLoadingComponent]);
|
|
205
215
|
React.useEffect(function () {
|
|
206
216
|
if (mapType && mapType.length > 0) {
|
|
207
217
|
setController(undefined);
|
|
@@ -232,9 +242,7 @@ function MintMap(_a) {
|
|
|
232
242
|
mapType: mapType
|
|
233
243
|
}, props, {
|
|
234
244
|
base: base
|
|
235
|
-
}), children)) : React__default["default"].createElement(
|
|
236
|
-
text: "Loading"
|
|
237
|
-
}));
|
|
245
|
+
}), children)) : React__default["default"].createElement(React__default["default"].Fragment, null, loading));
|
|
238
246
|
}
|
|
239
247
|
|
|
240
248
|
function PointLoading(_a) {
|
|
@@ -10,12 +10,15 @@ export declare abstract class MintMapController {
|
|
|
10
10
|
abstract panningTo(targetCenter: Position): void;
|
|
11
11
|
abstract getZoomLevel(): number;
|
|
12
12
|
abstract setZoomLevel(zoom: number): void;
|
|
13
|
+
abstract getCenter(): Position;
|
|
14
|
+
abstract setCenter(position: Position): void;
|
|
13
15
|
abstract createMarker(marker: Marker): void;
|
|
14
16
|
abstract updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
15
17
|
abstract clearDrawable(drawable: Drawable): boolean;
|
|
16
18
|
abstract markerToTheTop(marker: Marker): void;
|
|
17
19
|
abstract isMapDragged(): boolean;
|
|
18
20
|
abstract setMapDragged(value: boolean): void;
|
|
21
|
+
abstract setMarkerZIndex(marker: Marker, zIndex: number): void;
|
|
19
22
|
abstract createPolyline(polyline: Polyline): void;
|
|
20
23
|
abstract updatePolyline(polyline: Polyline, options: PolylineOptions): void;
|
|
21
24
|
abstract createPolygon(polygon: Polygon): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
2
|
import { MintMapProps } from "../MintMap";
|
|
3
|
-
export declare function MintMapCore({ onLoad, visible,
|
|
3
|
+
export declare function MintMapCore({ onLoad, visible, zoomLevel, center, children }: PropsWithChildren<MintMapProps>): JSX.Element;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var classNames = require('classnames/bind');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var MintMap = require('../MintMap.js');
|
|
8
9
|
var MintMapProvider = require('./provider/MintMapProvider.js');
|
|
9
10
|
var MintMapCore_module = require('./MintMapCore.module.scss.js');
|
|
10
11
|
|
|
@@ -20,7 +21,8 @@ function MintMapCore(_a) {
|
|
|
20
21
|
var onLoad = _a.onLoad,
|
|
21
22
|
_b = _a.visible,
|
|
22
23
|
visible = _b === void 0 ? true : _b,
|
|
23
|
-
|
|
24
|
+
zoomLevel = _a.zoomLevel,
|
|
25
|
+
center = _a.center,
|
|
24
26
|
children = _a.children;
|
|
25
27
|
var controller = MintMapProvider.useMintMapController();
|
|
26
28
|
var elementRef = React.useRef(null);
|
|
@@ -59,21 +61,30 @@ function MintMapCore(_a) {
|
|
|
59
61
|
};
|
|
60
62
|
}, [controller, elementRef]);
|
|
61
63
|
React.useEffect(function () {
|
|
62
|
-
if (
|
|
64
|
+
if (zoomLevel && controller && mapInitialized) {
|
|
63
65
|
var prevZoomLevel = controller === null || controller === void 0 ? void 0 : controller.getZoomLevel();
|
|
64
66
|
|
|
65
|
-
if (prevZoomLevel !==
|
|
66
|
-
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(
|
|
67
|
+
if (prevZoomLevel !== zoomLevel) {
|
|
68
|
+
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(zoomLevel);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
}, [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
}, [zoomLevel]);
|
|
72
|
+
React.useEffect(function () {
|
|
73
|
+
if (center && controller && mapInitialized) {
|
|
74
|
+
var prevCenter = controller.getCenter();
|
|
75
|
+
|
|
76
|
+
if (!MintMap.Position.equals(prevCenter, center)) {
|
|
77
|
+
controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
78
|
+
}
|
|
74
79
|
}
|
|
80
|
+
}, [center]);
|
|
81
|
+
return React__default["default"].createElement("div", {
|
|
82
|
+
className: cn('mint-map-root')
|
|
75
83
|
}, mapInitialized && children, React__default["default"].createElement("div", {
|
|
76
84
|
className: cn('mint-map-container'),
|
|
85
|
+
style: {
|
|
86
|
+
visibility: visible ? 'inherit' : 'hidden'
|
|
87
|
+
},
|
|
77
88
|
ref: elementRef
|
|
78
89
|
}));
|
|
79
90
|
}
|
|
@@ -123,12 +123,20 @@ function MapMarkerWrapper(_a) {
|
|
|
123
123
|
if (markerRef.current) {
|
|
124
124
|
controller.updateMarker(markerRef.current, options);
|
|
125
125
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
126
|
+
|
|
127
|
+
if (markerRef.current.options.zIndex !== undefined) {
|
|
128
|
+
controller.setMarkerZIndex(markerRef.current, markerRef.current.options.zIndex);
|
|
129
|
+
}
|
|
126
130
|
} else {
|
|
127
131
|
markerRef.current = new MintMap.Marker(options);
|
|
128
132
|
markerRef.current.element = divElement;
|
|
129
133
|
controller.createMarker(markerRef.current);
|
|
130
134
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
131
135
|
|
|
136
|
+
if (markerRef.current.options.zIndex !== undefined) {
|
|
137
|
+
controller.setMarkerZIndex(markerRef.current, markerRef.current.options.zIndex);
|
|
138
|
+
}
|
|
139
|
+
|
|
132
140
|
if (movingAnimation) {
|
|
133
141
|
setMovingState(tslib.__assign(tslib.__assign({}, movingAnimation), {
|
|
134
142
|
marker: markerRef.current
|
|
@@ -19,6 +19,7 @@ export declare class GoogleMintMapController extends MintMapController {
|
|
|
19
19
|
updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
20
20
|
private markerMaxZIndex;
|
|
21
21
|
private getMaxZIndex;
|
|
22
|
+
setMarkerZIndex(marker: Marker, zIndex: number): void;
|
|
22
23
|
markerToTheTop(marker: Marker): void;
|
|
23
24
|
clearDrawable(drawable: Drawable): boolean;
|
|
24
25
|
private dragged;
|
|
@@ -32,4 +33,6 @@ export declare class GoogleMintMapController extends MintMapController {
|
|
|
32
33
|
panningTo(targetCenter: Position): void;
|
|
33
34
|
getZoomLevel(): number;
|
|
34
35
|
setZoomLevel(zoom: number): void;
|
|
36
|
+
getCenter(): Position;
|
|
37
|
+
setCenter(position: Position): void;
|
|
35
38
|
}
|
|
@@ -259,12 +259,22 @@ var GoogleMintMapController = function (_super) {
|
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
GoogleMintMapController.prototype.
|
|
262
|
+
GoogleMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
|
|
263
263
|
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
264
264
|
var parent_1 = marker.element.parentElement;
|
|
265
265
|
|
|
266
266
|
if (parent_1) {
|
|
267
|
-
parent_1.style.zIndex = String(
|
|
267
|
+
parent_1.style.zIndex = String(zIndex);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
GoogleMintMapController.prototype.markerToTheTop = function (marker) {
|
|
273
|
+
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
274
|
+
var parent_2 = marker.element.parentElement;
|
|
275
|
+
|
|
276
|
+
if (parent_2) {
|
|
277
|
+
this.setMarkerZIndex(marker, this.getMaxZIndex(1, parent_2));
|
|
268
278
|
}
|
|
269
279
|
}
|
|
270
280
|
};
|
|
@@ -386,7 +396,8 @@ var GoogleMintMapController = function (_super) {
|
|
|
386
396
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
387
397
|
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
388
398
|
disableDefaultUI: true,
|
|
389
|
-
gestureHandling: 'greedy',
|
|
399
|
+
gestureHandling: this.mapProps.draggable === false ? 'none' : 'greedy',
|
|
400
|
+
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
390
401
|
clickableIcons: false
|
|
391
402
|
});
|
|
392
403
|
this.map = map;
|
|
@@ -458,6 +469,16 @@ var GoogleMintMapController = function (_super) {
|
|
|
458
469
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
|
|
459
470
|
};
|
|
460
471
|
|
|
472
|
+
GoogleMintMapController.prototype.getCenter = function () {
|
|
473
|
+
return this.getCurrBounds().getCenter();
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
GoogleMintMapController.prototype.setCenter = function (position) {
|
|
477
|
+
var _a;
|
|
478
|
+
|
|
479
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
480
|
+
};
|
|
481
|
+
|
|
461
482
|
return GoogleMintMapController;
|
|
462
483
|
}(MintMapController.MintMapController);
|
|
463
484
|
|
|
@@ -21,6 +21,7 @@ export declare class NaverMintMapController extends MintMapController {
|
|
|
21
21
|
updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
22
22
|
private markerMaxZIndex;
|
|
23
23
|
private getMaxZIndex;
|
|
24
|
+
setMarkerZIndex(marker: Marker, zIndex: number): void;
|
|
24
25
|
markerToTheTop(marker: Marker): void;
|
|
25
26
|
clearDrawable(drawable: Drawable): boolean;
|
|
26
27
|
private dragStartPoint;
|
|
@@ -35,4 +36,6 @@ export declare class NaverMintMapController extends MintMapController {
|
|
|
35
36
|
panningTo(targetCenter: Position): void;
|
|
36
37
|
getZoomLevel(): number;
|
|
37
38
|
setZoomLevel(zoom: number): void;
|
|
39
|
+
getCenter(): Position;
|
|
40
|
+
setCenter(position: Position): void;
|
|
38
41
|
}
|
|
@@ -260,16 +260,20 @@ var NaverMintMapController = function (_super) {
|
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
262
|
|
|
263
|
-
NaverMintMapController.prototype.
|
|
263
|
+
NaverMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
|
|
264
264
|
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
265
265
|
var parent_1 = marker.element.parentElement;
|
|
266
266
|
|
|
267
267
|
if (parent_1) {
|
|
268
|
-
parent_1.style.zIndex = String(
|
|
268
|
+
parent_1.style.zIndex = String(zIndex);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
+
NaverMintMapController.prototype.markerToTheTop = function (marker) {
|
|
274
|
+
this.setMarkerZIndex(marker, this.getMaxZIndex(1));
|
|
275
|
+
};
|
|
276
|
+
|
|
273
277
|
NaverMintMapController.prototype.clearDrawable = function (drawable) {
|
|
274
278
|
var _a;
|
|
275
279
|
|
|
@@ -390,6 +394,9 @@ var NaverMintMapController = function (_super) {
|
|
|
390
394
|
options = {
|
|
391
395
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
392
396
|
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
397
|
+
draggable: this.mapProps.draggable === false ? false : true,
|
|
398
|
+
scrollWheel: this.mapProps.draggable === false ? false : true,
|
|
399
|
+
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
393
400
|
logoControl: false,
|
|
394
401
|
mapDataControl: false,
|
|
395
402
|
mapTypeControl: false,
|
|
@@ -511,6 +518,16 @@ var NaverMintMapController = function (_super) {
|
|
|
511
518
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom, true);
|
|
512
519
|
};
|
|
513
520
|
|
|
521
|
+
NaverMintMapController.prototype.getCenter = function () {
|
|
522
|
+
return this.getCurrBounds().getCenter();
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
NaverMintMapController.prototype.setCenter = function (position) {
|
|
526
|
+
var _a;
|
|
527
|
+
|
|
528
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
529
|
+
};
|
|
530
|
+
|
|
514
531
|
return NaverMintMapController;
|
|
515
532
|
}(MintMapController.MintMapController);
|
|
516
533
|
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter, __generator, __extends, __assign, __rest, __spreadArray } from 'tslib';
|
|
2
|
-
import React, { createContext, useContext, useRef, useState, useEffect } from 'react';
|
|
2
|
+
import React, { createContext, useContext, useRef, useState, useEffect, useMemo } from 'react';
|
|
3
3
|
import classNames from 'classnames/bind';
|
|
4
4
|
import styleInject from 'style-inject';
|
|
5
5
|
import { ObjectPool } from '@mint-ui/tools';
|
|
@@ -38,7 +38,8 @@ function MintMapCore(_a) {
|
|
|
38
38
|
var onLoad = _a.onLoad,
|
|
39
39
|
_b = _a.visible,
|
|
40
40
|
visible = _b === void 0 ? true : _b,
|
|
41
|
-
|
|
41
|
+
zoomLevel = _a.zoomLevel,
|
|
42
|
+
center = _a.center,
|
|
42
43
|
children = _a.children;
|
|
43
44
|
var controller = useMintMapController();
|
|
44
45
|
var elementRef = useRef(null);
|
|
@@ -77,21 +78,30 @@ function MintMapCore(_a) {
|
|
|
77
78
|
};
|
|
78
79
|
}, [controller, elementRef]);
|
|
79
80
|
useEffect(function () {
|
|
80
|
-
if (
|
|
81
|
+
if (zoomLevel && controller && mapInitialized) {
|
|
81
82
|
var prevZoomLevel = controller === null || controller === void 0 ? void 0 : controller.getZoomLevel();
|
|
82
83
|
|
|
83
|
-
if (prevZoomLevel !==
|
|
84
|
-
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(
|
|
84
|
+
if (prevZoomLevel !== zoomLevel) {
|
|
85
|
+
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(zoomLevel);
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
}, [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
}, [zoomLevel]);
|
|
89
|
+
useEffect(function () {
|
|
90
|
+
if (center && controller && mapInitialized) {
|
|
91
|
+
var prevCenter = controller.getCenter();
|
|
92
|
+
|
|
93
|
+
if (!Position.equals(prevCenter, center)) {
|
|
94
|
+
controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
95
|
+
}
|
|
92
96
|
}
|
|
97
|
+
}, [center]);
|
|
98
|
+
return React.createElement("div", {
|
|
99
|
+
className: cn$2('mint-map-root')
|
|
93
100
|
}, mapInitialized && children, React.createElement("div", {
|
|
94
101
|
className: cn$2('mint-map-container'),
|
|
102
|
+
style: {
|
|
103
|
+
visibility: visible ? 'inherit' : 'hidden'
|
|
104
|
+
},
|
|
95
105
|
ref: elementRef
|
|
96
106
|
}));
|
|
97
107
|
}
|
|
@@ -657,16 +667,20 @@ var NaverMintMapController = function (_super) {
|
|
|
657
667
|
}
|
|
658
668
|
};
|
|
659
669
|
|
|
660
|
-
NaverMintMapController.prototype.
|
|
670
|
+
NaverMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
|
|
661
671
|
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
662
672
|
var parent_1 = marker.element.parentElement;
|
|
663
673
|
|
|
664
674
|
if (parent_1) {
|
|
665
|
-
parent_1.style.zIndex = String(
|
|
675
|
+
parent_1.style.zIndex = String(zIndex);
|
|
666
676
|
}
|
|
667
677
|
}
|
|
668
678
|
};
|
|
669
679
|
|
|
680
|
+
NaverMintMapController.prototype.markerToTheTop = function (marker) {
|
|
681
|
+
this.setMarkerZIndex(marker, this.getMaxZIndex(1));
|
|
682
|
+
};
|
|
683
|
+
|
|
670
684
|
NaverMintMapController.prototype.clearDrawable = function (drawable) {
|
|
671
685
|
var _a;
|
|
672
686
|
|
|
@@ -787,6 +801,9 @@ var NaverMintMapController = function (_super) {
|
|
|
787
801
|
options = {
|
|
788
802
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
789
803
|
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
804
|
+
draggable: this.mapProps.draggable === false ? false : true,
|
|
805
|
+
scrollWheel: this.mapProps.draggable === false ? false : true,
|
|
806
|
+
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
790
807
|
logoControl: false,
|
|
791
808
|
mapDataControl: false,
|
|
792
809
|
mapTypeControl: false,
|
|
@@ -908,6 +925,16 @@ var NaverMintMapController = function (_super) {
|
|
|
908
925
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom, true);
|
|
909
926
|
};
|
|
910
927
|
|
|
928
|
+
NaverMintMapController.prototype.getCenter = function () {
|
|
929
|
+
return this.getCurrBounds().getCenter();
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
NaverMintMapController.prototype.setCenter = function (position) {
|
|
933
|
+
var _a;
|
|
934
|
+
|
|
935
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
936
|
+
};
|
|
937
|
+
|
|
911
938
|
return NaverMintMapController;
|
|
912
939
|
}(MintMapController);
|
|
913
940
|
|
|
@@ -1163,12 +1190,22 @@ var GoogleMintMapController = function (_super) {
|
|
|
1163
1190
|
}
|
|
1164
1191
|
};
|
|
1165
1192
|
|
|
1166
|
-
GoogleMintMapController.prototype.
|
|
1193
|
+
GoogleMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
|
|
1167
1194
|
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
1168
1195
|
var parent_1 = marker.element.parentElement;
|
|
1169
1196
|
|
|
1170
1197
|
if (parent_1) {
|
|
1171
|
-
parent_1.style.zIndex = String(
|
|
1198
|
+
parent_1.style.zIndex = String(zIndex);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
GoogleMintMapController.prototype.markerToTheTop = function (marker) {
|
|
1204
|
+
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
1205
|
+
var parent_2 = marker.element.parentElement;
|
|
1206
|
+
|
|
1207
|
+
if (parent_2) {
|
|
1208
|
+
this.setMarkerZIndex(marker, this.getMaxZIndex(1, parent_2));
|
|
1172
1209
|
}
|
|
1173
1210
|
}
|
|
1174
1211
|
};
|
|
@@ -1290,7 +1327,8 @@ var GoogleMintMapController = function (_super) {
|
|
|
1290
1327
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
1291
1328
|
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
1292
1329
|
disableDefaultUI: true,
|
|
1293
|
-
gestureHandling: 'greedy',
|
|
1330
|
+
gestureHandling: this.mapProps.draggable === false ? 'none' : 'greedy',
|
|
1331
|
+
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
1294
1332
|
clickableIcons: false
|
|
1295
1333
|
});
|
|
1296
1334
|
this.map = map;
|
|
@@ -1362,6 +1400,16 @@ var GoogleMintMapController = function (_super) {
|
|
|
1362
1400
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
|
|
1363
1401
|
};
|
|
1364
1402
|
|
|
1403
|
+
GoogleMintMapController.prototype.getCenter = function () {
|
|
1404
|
+
return this.getCurrBounds().getCenter();
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
GoogleMintMapController.prototype.setCenter = function (position) {
|
|
1408
|
+
var _a;
|
|
1409
|
+
|
|
1410
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1365
1413
|
return GoogleMintMapController;
|
|
1366
1414
|
}(MintMapController);
|
|
1367
1415
|
|
|
@@ -1373,6 +1421,10 @@ var Position = function () {
|
|
|
1373
1421
|
this.lng = lng;
|
|
1374
1422
|
}
|
|
1375
1423
|
|
|
1424
|
+
Position.equals = function (pos1, pos2) {
|
|
1425
|
+
return pos1.lat === pos2.lat && pos1.lng === pos2.lng;
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1376
1428
|
return Position;
|
|
1377
1429
|
}();
|
|
1378
1430
|
|
|
@@ -1537,19 +1589,25 @@ var DEFAULT_CENTER = {
|
|
|
1537
1589
|
lng: 127.0448698
|
|
1538
1590
|
};
|
|
1539
1591
|
function MintMap(_a) {
|
|
1540
|
-
var
|
|
1592
|
+
var mapLoadingComponent = _a.mapLoadingComponent,
|
|
1593
|
+
mapType = _a.mapType,
|
|
1541
1594
|
children = _a.children,
|
|
1542
1595
|
_b = _a.base,
|
|
1543
1596
|
base = _b === void 0 ? {
|
|
1544
1597
|
center: DEFAULT_CENTER,
|
|
1545
1598
|
zoomLevel: 12
|
|
1546
1599
|
} : _b,
|
|
1547
|
-
props = __rest(_a, ["mapType", "children", "base"]);
|
|
1600
|
+
props = __rest(_a, ["mapLoadingComponent", "mapType", "children", "base"]);
|
|
1548
1601
|
|
|
1549
1602
|
var _c = useState(),
|
|
1550
1603
|
controller = _c[0],
|
|
1551
1604
|
setController = _c[1];
|
|
1552
1605
|
|
|
1606
|
+
var loading = useMemo(function () {
|
|
1607
|
+
return mapLoadingComponent ? mapLoadingComponent() : React.createElement(PointLoading, {
|
|
1608
|
+
text: "Loading"
|
|
1609
|
+
});
|
|
1610
|
+
}, [mapLoadingComponent]);
|
|
1553
1611
|
useEffect(function () {
|
|
1554
1612
|
if (mapType && mapType.length > 0) {
|
|
1555
1613
|
setController(undefined);
|
|
@@ -1580,9 +1638,7 @@ function MintMap(_a) {
|
|
|
1580
1638
|
mapType: mapType
|
|
1581
1639
|
}, props, {
|
|
1582
1640
|
base: base
|
|
1583
|
-
}), children)) : React.createElement(
|
|
1584
|
-
text: "Loading"
|
|
1585
|
-
}));
|
|
1641
|
+
}), children)) : React.createElement(React.Fragment, null, loading));
|
|
1586
1642
|
}
|
|
1587
1643
|
|
|
1588
1644
|
function PointLoading(_a) {
|
|
@@ -1943,12 +1999,20 @@ function MapMarkerWrapper(_a) {
|
|
|
1943
1999
|
if (markerRef.current) {
|
|
1944
2000
|
controller.updateMarker(markerRef.current, options);
|
|
1945
2001
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
2002
|
+
|
|
2003
|
+
if (markerRef.current.options.zIndex !== undefined) {
|
|
2004
|
+
controller.setMarkerZIndex(markerRef.current, markerRef.current.options.zIndex);
|
|
2005
|
+
}
|
|
1946
2006
|
} else {
|
|
1947
2007
|
markerRef.current = new Marker(options);
|
|
1948
2008
|
markerRef.current.element = divElement;
|
|
1949
2009
|
controller.createMarker(markerRef.current);
|
|
1950
2010
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
1951
2011
|
|
|
2012
|
+
if (markerRef.current.options.zIndex !== undefined) {
|
|
2013
|
+
controller.setMarkerZIndex(markerRef.current, markerRef.current.options.zIndex);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
1952
2016
|
if (movingAnimation) {
|
|
1953
2017
|
setMovingState(__assign(__assign({}, movingAnimation), {
|
|
1954
2018
|
marker: markerRef.current
|
package/dist/index.umd.js
CHANGED
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
var onLoad = _a.onLoad,
|
|
44
44
|
_b = _a.visible,
|
|
45
45
|
visible = _b === void 0 ? true : _b,
|
|
46
|
-
|
|
46
|
+
zoomLevel = _a.zoomLevel,
|
|
47
|
+
center = _a.center,
|
|
47
48
|
children = _a.children;
|
|
48
49
|
var controller = useMintMapController();
|
|
49
50
|
var elementRef = React.useRef(null);
|
|
@@ -82,21 +83,30 @@
|
|
|
82
83
|
};
|
|
83
84
|
}, [controller, elementRef]);
|
|
84
85
|
React.useEffect(function () {
|
|
85
|
-
if (
|
|
86
|
+
if (zoomLevel && controller && mapInitialized) {
|
|
86
87
|
var prevZoomLevel = controller === null || controller === void 0 ? void 0 : controller.getZoomLevel();
|
|
87
88
|
|
|
88
|
-
if (prevZoomLevel !==
|
|
89
|
-
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(
|
|
89
|
+
if (prevZoomLevel !== zoomLevel) {
|
|
90
|
+
controller === null || controller === void 0 ? void 0 : controller.setZoomLevel(zoomLevel);
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
}, [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
}, [zoomLevel]);
|
|
94
|
+
React.useEffect(function () {
|
|
95
|
+
if (center && controller && mapInitialized) {
|
|
96
|
+
var prevCenter = controller.getCenter();
|
|
97
|
+
|
|
98
|
+
if (!Position.equals(prevCenter, center)) {
|
|
99
|
+
controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
100
|
+
}
|
|
97
101
|
}
|
|
102
|
+
}, [center]);
|
|
103
|
+
return React__default["default"].createElement("div", {
|
|
104
|
+
className: cn$2('mint-map-root')
|
|
98
105
|
}, mapInitialized && children, React__default["default"].createElement("div", {
|
|
99
106
|
className: cn$2('mint-map-container'),
|
|
107
|
+
style: {
|
|
108
|
+
visibility: visible ? 'inherit' : 'hidden'
|
|
109
|
+
},
|
|
100
110
|
ref: elementRef
|
|
101
111
|
}));
|
|
102
112
|
}
|
|
@@ -662,16 +672,20 @@
|
|
|
662
672
|
}
|
|
663
673
|
};
|
|
664
674
|
|
|
665
|
-
NaverMintMapController.prototype.
|
|
675
|
+
NaverMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
|
|
666
676
|
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
667
677
|
var parent_1 = marker.element.parentElement;
|
|
668
678
|
|
|
669
679
|
if (parent_1) {
|
|
670
|
-
parent_1.style.zIndex = String(
|
|
680
|
+
parent_1.style.zIndex = String(zIndex);
|
|
671
681
|
}
|
|
672
682
|
}
|
|
673
683
|
};
|
|
674
684
|
|
|
685
|
+
NaverMintMapController.prototype.markerToTheTop = function (marker) {
|
|
686
|
+
this.setMarkerZIndex(marker, this.getMaxZIndex(1));
|
|
687
|
+
};
|
|
688
|
+
|
|
675
689
|
NaverMintMapController.prototype.clearDrawable = function (drawable) {
|
|
676
690
|
var _a;
|
|
677
691
|
|
|
@@ -792,6 +806,9 @@
|
|
|
792
806
|
options = {
|
|
793
807
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
794
808
|
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
809
|
+
draggable: this.mapProps.draggable === false ? false : true,
|
|
810
|
+
scrollWheel: this.mapProps.draggable === false ? false : true,
|
|
811
|
+
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
795
812
|
logoControl: false,
|
|
796
813
|
mapDataControl: false,
|
|
797
814
|
mapTypeControl: false,
|
|
@@ -913,6 +930,16 @@
|
|
|
913
930
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom, true);
|
|
914
931
|
};
|
|
915
932
|
|
|
933
|
+
NaverMintMapController.prototype.getCenter = function () {
|
|
934
|
+
return this.getCurrBounds().getCenter();
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
NaverMintMapController.prototype.setCenter = function (position) {
|
|
938
|
+
var _a;
|
|
939
|
+
|
|
940
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
941
|
+
};
|
|
942
|
+
|
|
916
943
|
return NaverMintMapController;
|
|
917
944
|
}(MintMapController);
|
|
918
945
|
|
|
@@ -1168,12 +1195,22 @@
|
|
|
1168
1195
|
}
|
|
1169
1196
|
};
|
|
1170
1197
|
|
|
1171
|
-
GoogleMintMapController.prototype.
|
|
1198
|
+
GoogleMintMapController.prototype.setMarkerZIndex = function (marker, zIndex) {
|
|
1172
1199
|
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
1173
1200
|
var parent_1 = marker.element.parentElement;
|
|
1174
1201
|
|
|
1175
1202
|
if (parent_1) {
|
|
1176
|
-
parent_1.style.zIndex = String(
|
|
1203
|
+
parent_1.style.zIndex = String(zIndex);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
GoogleMintMapController.prototype.markerToTheTop = function (marker) {
|
|
1209
|
+
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
1210
|
+
var parent_2 = marker.element.parentElement;
|
|
1211
|
+
|
|
1212
|
+
if (parent_2) {
|
|
1213
|
+
this.setMarkerZIndex(marker, this.getMaxZIndex(1, parent_2));
|
|
1177
1214
|
}
|
|
1178
1215
|
}
|
|
1179
1216
|
};
|
|
@@ -1295,7 +1332,8 @@
|
|
|
1295
1332
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
1296
1333
|
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
1297
1334
|
disableDefaultUI: true,
|
|
1298
|
-
gestureHandling: 'greedy',
|
|
1335
|
+
gestureHandling: this.mapProps.draggable === false ? 'none' : 'greedy',
|
|
1336
|
+
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
1299
1337
|
clickableIcons: false
|
|
1300
1338
|
});
|
|
1301
1339
|
this.map = map;
|
|
@@ -1367,6 +1405,16 @@
|
|
|
1367
1405
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
|
|
1368
1406
|
};
|
|
1369
1407
|
|
|
1408
|
+
GoogleMintMapController.prototype.getCenter = function () {
|
|
1409
|
+
return this.getCurrBounds().getCenter();
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
GoogleMintMapController.prototype.setCenter = function (position) {
|
|
1413
|
+
var _a;
|
|
1414
|
+
|
|
1415
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1370
1418
|
return GoogleMintMapController;
|
|
1371
1419
|
}(MintMapController);
|
|
1372
1420
|
|
|
@@ -1378,6 +1426,10 @@
|
|
|
1378
1426
|
this.lng = lng;
|
|
1379
1427
|
}
|
|
1380
1428
|
|
|
1429
|
+
Position.equals = function (pos1, pos2) {
|
|
1430
|
+
return pos1.lat === pos2.lat && pos1.lng === pos2.lng;
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1381
1433
|
return Position;
|
|
1382
1434
|
}();
|
|
1383
1435
|
|
|
@@ -1542,19 +1594,25 @@
|
|
|
1542
1594
|
lng: 127.0448698
|
|
1543
1595
|
};
|
|
1544
1596
|
function MintMap(_a) {
|
|
1545
|
-
var
|
|
1597
|
+
var mapLoadingComponent = _a.mapLoadingComponent,
|
|
1598
|
+
mapType = _a.mapType,
|
|
1546
1599
|
children = _a.children,
|
|
1547
1600
|
_b = _a.base,
|
|
1548
1601
|
base = _b === void 0 ? {
|
|
1549
1602
|
center: DEFAULT_CENTER,
|
|
1550
1603
|
zoomLevel: 12
|
|
1551
1604
|
} : _b,
|
|
1552
|
-
props = tslib.__rest(_a, ["mapType", "children", "base"]);
|
|
1605
|
+
props = tslib.__rest(_a, ["mapLoadingComponent", "mapType", "children", "base"]);
|
|
1553
1606
|
|
|
1554
1607
|
var _c = React.useState(),
|
|
1555
1608
|
controller = _c[0],
|
|
1556
1609
|
setController = _c[1];
|
|
1557
1610
|
|
|
1611
|
+
var loading = React.useMemo(function () {
|
|
1612
|
+
return mapLoadingComponent ? mapLoadingComponent() : React__default["default"].createElement(PointLoading, {
|
|
1613
|
+
text: "Loading"
|
|
1614
|
+
});
|
|
1615
|
+
}, [mapLoadingComponent]);
|
|
1558
1616
|
React.useEffect(function () {
|
|
1559
1617
|
if (mapType && mapType.length > 0) {
|
|
1560
1618
|
setController(undefined);
|
|
@@ -1585,9 +1643,7 @@
|
|
|
1585
1643
|
mapType: mapType
|
|
1586
1644
|
}, props, {
|
|
1587
1645
|
base: base
|
|
1588
|
-
}), children)) : React__default["default"].createElement(
|
|
1589
|
-
text: "Loading"
|
|
1590
|
-
}));
|
|
1646
|
+
}), children)) : React__default["default"].createElement(React__default["default"].Fragment, null, loading));
|
|
1591
1647
|
}
|
|
1592
1648
|
|
|
1593
1649
|
function PointLoading(_a) {
|
|
@@ -1948,12 +2004,20 @@
|
|
|
1948
2004
|
if (markerRef.current) {
|
|
1949
2005
|
controller.updateMarker(markerRef.current, options);
|
|
1950
2006
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
2007
|
+
|
|
2008
|
+
if (markerRef.current.options.zIndex !== undefined) {
|
|
2009
|
+
controller.setMarkerZIndex(markerRef.current, markerRef.current.options.zIndex);
|
|
2010
|
+
}
|
|
1951
2011
|
} else {
|
|
1952
2012
|
markerRef.current = new Marker(options);
|
|
1953
2013
|
markerRef.current.element = divElement;
|
|
1954
2014
|
controller.createMarker(markerRef.current);
|
|
1955
2015
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
1956
2016
|
|
|
2017
|
+
if (markerRef.current.options.zIndex !== undefined) {
|
|
2018
|
+
controller.setMarkerZIndex(markerRef.current, markerRef.current.options.zIndex);
|
|
2019
|
+
}
|
|
2020
|
+
|
|
1957
2021
|
if (movingAnimation) {
|
|
1958
2022
|
setMovingState(tslib.__assign(tslib.__assign({}, movingAnimation), {
|
|
1959
2023
|
marker: markerRef.current
|