@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,5 +1,12 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
import { PolylineOptions } from "../../
|
|
3
|
-
export interface MapPolylineWrapperProps extends PolylineOptions {
|
|
4
|
-
}
|
|
5
|
-
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { PolylineOptions } from "../../types/MapDrawables";
|
|
3
|
+
export interface MapPolylineWrapperProps extends PolylineOptions {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Mint Map 컴포넌트
|
|
7
|
+
*
|
|
8
|
+
* @param {MapControlWrapperProps} MapControlWrapperProps
|
|
9
|
+
*
|
|
10
|
+
* @returns {JSX.Element} JSX
|
|
11
|
+
*/
|
|
12
|
+
export declare function MapPolylineWrapper({ children, ...options }: PropsWithChildren<MapPolylineWrapperProps>): JSX.Element;
|
|
@@ -5,32 +5,46 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var MintMapProvider = require('../provider/MintMapProvider.js');
|
|
8
|
-
var
|
|
8
|
+
var MapDrawables = require('../../types/MapDrawables.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Mint Map 컴포넌트
|
|
16
|
+
*
|
|
17
|
+
* @param {MapControlWrapperProps} MapControlWrapperProps
|
|
18
|
+
*
|
|
19
|
+
* @returns {JSX.Element} JSX
|
|
20
|
+
*/
|
|
21
|
+
|
|
14
22
|
function MapPolylineWrapper(_a) {
|
|
15
23
|
var children = _a.children,
|
|
16
|
-
options = tslib.__rest(_a, ["children"]);
|
|
24
|
+
options = tslib.__rest(_a, ["children"]); //controller
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var controller = MintMapProvider.useMintMapController(); //lifecycle
|
|
17
28
|
|
|
18
|
-
var controller = MintMapProvider.useMintMapController();
|
|
19
29
|
React.useEffect(function () {
|
|
20
30
|
return function () {
|
|
21
31
|
if (polylineRef.current) {
|
|
22
|
-
controller.clearDrawable(polylineRef.current);
|
|
32
|
+
controller.clearDrawable(polylineRef.current); // console.log('polyline cleared')
|
|
23
33
|
}
|
|
24
34
|
};
|
|
25
|
-
}, []);
|
|
35
|
+
}, []); //create/update object
|
|
36
|
+
|
|
26
37
|
var polylineRef = React.useRef();
|
|
27
38
|
React.useEffect(function () {
|
|
39
|
+
//console.log('Polyline useEffect')
|
|
28
40
|
if (options) {
|
|
29
41
|
if (polylineRef.current) {
|
|
42
|
+
//console.log('update Polyline', options)
|
|
30
43
|
controller.updatePolyline(polylineRef.current, options);
|
|
31
44
|
} else {
|
|
32
|
-
var polyline = new
|
|
33
|
-
polylineRef.current = polyline;
|
|
45
|
+
var polyline = new MapDrawables.Polyline(options);
|
|
46
|
+
polylineRef.current = polyline; //console.log('create Polyline', options)
|
|
47
|
+
|
|
34
48
|
controller.createPolyline(polyline);
|
|
35
49
|
}
|
|
36
50
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './MapControlWrapper';
|
|
2
|
-
export * from './MapMarkerWrapper';
|
|
3
|
-
export * from './MapPolygonWrapper';
|
|
4
|
-
export * from './MapPolylineWrapper';
|
|
5
|
-
export * from './MapCanvasWrapper';
|
|
6
|
-
export * from './MapCanvasMarkerWrapper';
|
|
1
|
+
export * from './MapControlWrapper';
|
|
2
|
+
export * from './MapMarkerWrapper';
|
|
3
|
+
export * from './MapPolygonWrapper';
|
|
4
|
+
export * from './MapPolylineWrapper';
|
|
5
|
+
export * from './MapCanvasWrapper';
|
|
6
|
+
export * from './MapCanvasMarkerWrapper';
|
|
@@ -1,39 +1,51 @@
|
|
|
1
|
-
/// <reference types="google.maps" />
|
|
2
|
-
import { MintMapController } from "../core/MintMapController";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import { MintMapController } from "../core/MintMapController";
|
|
3
|
+
import { MapType, MapVendorType } from "../types/CommonTypes";
|
|
4
|
+
import { Drawable, Marker, MarkerOptions, Polygon, PolygonOptions, Polyline, PolylineOptions } from "../types/MapDrawables";
|
|
5
|
+
import { EventCallback, EventParamType, MapEvent, MapEventName, MapUIEvent } from "../types/MapEventTypes";
|
|
6
|
+
import { Bounds, Position } from "../types/MapTypes";
|
|
7
|
+
import { MintMapProps } from "../types/MintMapProps";
|
|
8
|
+
export declare class GoogleMintMapController extends MintMapController {
|
|
9
|
+
type: MapType;
|
|
10
|
+
map: google.maps.Map | null;
|
|
11
|
+
scriptUrl: string;
|
|
12
|
+
scriptModules: string[];
|
|
13
|
+
protected mapEvent: MapEvent;
|
|
14
|
+
protected mapUIEvent: MapUIEvent;
|
|
15
|
+
constructor(props: MintMapProps);
|
|
16
|
+
polylineEvents: string[];
|
|
17
|
+
createPolyline(polyline: Polyline): void;
|
|
18
|
+
updatePolyline(polyline: Polyline, options: PolylineOptions): void;
|
|
19
|
+
polygonEvents: string[];
|
|
20
|
+
createPolygon(polygon: Polygon): void;
|
|
21
|
+
updatePolygon(polygon: Polygon, options: PolygonOptions): void;
|
|
22
|
+
private getValidOptions;
|
|
23
|
+
markerEvents: string[];
|
|
24
|
+
createMarker(marker: Marker): void;
|
|
25
|
+
updateMarker(marker: Marker, options: MarkerOptions): void;
|
|
26
|
+
private markerMaxZIndex;
|
|
27
|
+
private getMaxZIndex;
|
|
28
|
+
setMarkerZIndex(marker: Marker, zIndex: number): void;
|
|
29
|
+
markerToTheTop(marker: Marker): void;
|
|
30
|
+
clearDrawable(drawable: Drawable): boolean;
|
|
31
|
+
private dragged;
|
|
32
|
+
isMapDragged(): boolean;
|
|
33
|
+
setMapDragged(value: boolean): void;
|
|
34
|
+
private checkLoaded;
|
|
35
|
+
loadMapApi(): Promise<boolean>;
|
|
36
|
+
lastMousePosition: Position | null;
|
|
37
|
+
initializingMap(divElement: HTMLDivElement): Promise<MapVendorType>;
|
|
38
|
+
destroyMap: () => void;
|
|
39
|
+
private fromGoogleBounds;
|
|
40
|
+
getCurrBounds(): Bounds;
|
|
41
|
+
panningTo(targetCenter: Position): void;
|
|
42
|
+
getZoomLevel(): number;
|
|
43
|
+
setZoomLevel(zoom: number): void;
|
|
44
|
+
getCenter(): Position;
|
|
45
|
+
setCenter(position: Position): void;
|
|
46
|
+
private eventMap;
|
|
47
|
+
addEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
|
|
48
|
+
removeEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
|
|
49
|
+
removeAllEventListener(eventName?: MapEventName | undefined): void;
|
|
50
|
+
private clearEventListener;
|
|
51
|
+
}
|
|
@@ -5,9 +5,12 @@ 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
|
|
8
|
+
var MapEventTypes = require('../types/MapEventTypes.js');
|
|
9
|
+
var MapTypes = require('../types/MapTypes.js');
|
|
9
10
|
|
|
10
|
-
var GoogleMintMapController =
|
|
11
|
+
var GoogleMintMapController =
|
|
12
|
+
/** @class */
|
|
13
|
+
function (_super) {
|
|
11
14
|
tslib.__extends(GoogleMintMapController, _super);
|
|
12
15
|
|
|
13
16
|
function GoogleMintMapController(props) {
|
|
@@ -16,21 +19,34 @@ var GoogleMintMapController = function (_super) {
|
|
|
16
19
|
_this.type = 'google';
|
|
17
20
|
_this.map = null;
|
|
18
21
|
_this.scriptUrl = 'https://maps.googleapis.com/maps/api/js';
|
|
19
|
-
_this.scriptModules = ['marker'];
|
|
22
|
+
_this.scriptModules = ['marker']; //'drawing' , 'geometry' , 'journeySharing' , 'localContext' , 'places' , 'visualization']
|
|
23
|
+
|
|
24
|
+
_this.mapEvent = new MapEventTypes.MapEvent();
|
|
25
|
+
_this.mapUIEvent = new MapEventTypes.MapUIEvent();
|
|
20
26
|
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
21
27
|
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
22
28
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
23
29
|
_this.dragged = false;
|
|
30
|
+
_this.lastMousePosition = null;
|
|
24
31
|
|
|
25
32
|
_this.destroyMap = function () {
|
|
26
33
|
try {
|
|
34
|
+
_this.removeAllEventListener();
|
|
35
|
+
|
|
27
36
|
_this.map && google.maps.event.clearInstanceListeners(_this.map);
|
|
28
37
|
} catch (e) {
|
|
29
38
|
console.log('google map destroy error', e);
|
|
30
|
-
}
|
|
39
|
+
} // console.log(`${this.type} map destroyed`);
|
|
40
|
+
|
|
31
41
|
};
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
_this.eventMap = new Map(); //google 은 zoomstart 가 없으므로 zoom_changed 로 대체 (하지만 zooming 되는 내내 여러번 호출됨)
|
|
44
|
+
//나중에 naver 와 마찬가지로 zoomstart 1번 zoom_changed 1번 호출되도록 바꾸는것 고려중
|
|
45
|
+
|
|
46
|
+
_this.mapEvent.ZOOMSTART = 'zoom_changed';
|
|
47
|
+
Object.freeze(_this.mapEvent);
|
|
48
|
+
Object.freeze(_this.mapUIEvent);
|
|
49
|
+
return _this; // console.log(`${this.type} controller loadded`);
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
GoogleMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -48,12 +64,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
48
64
|
visible = _e === void 0 ? true : _e,
|
|
49
65
|
_f = _a.editable,
|
|
50
66
|
editable = _f === void 0 ? false : _f,
|
|
51
|
-
event = _a.event;
|
|
67
|
+
event = _a.event; //console.log('polyline', polyline);
|
|
52
68
|
|
|
53
69
|
if (this.map && Array.isArray(position)) {
|
|
54
70
|
var path = position.map(function (elem) {
|
|
55
|
-
return Array.isArray(elem) ? new
|
|
56
|
-
});
|
|
71
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
72
|
+
}); //console.log('polyline path',path);
|
|
73
|
+
|
|
57
74
|
var pol_1 = new google.maps.Polyline({
|
|
58
75
|
map: this.map,
|
|
59
76
|
path: path,
|
|
@@ -63,7 +80,8 @@ var GoogleMintMapController = function (_super) {
|
|
|
63
80
|
clickable: true,
|
|
64
81
|
visible: visible,
|
|
65
82
|
editable: editable
|
|
66
|
-
});
|
|
83
|
+
}); //console.log('google polyline created', polyline);
|
|
84
|
+
|
|
67
85
|
polyline.native = pol_1;
|
|
68
86
|
event && event.forEach(function (handler, key) {
|
|
69
87
|
if (_this.polylineEvents.includes(key)) {
|
|
@@ -74,12 +92,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
74
92
|
};
|
|
75
93
|
|
|
76
94
|
GoogleMintMapController.prototype.updatePolyline = function (polyline, options) {
|
|
95
|
+
//console.log('controller updatePolyline', options);
|
|
77
96
|
if (polyline && polyline.native && polyline.native instanceof google.maps.Polyline) {
|
|
78
|
-
var polylineOption = this.getValidOptions(options);
|
|
97
|
+
var polylineOption = this.getValidOptions(options); //console.log('controller updatePolyline start', polylineOption);
|
|
79
98
|
|
|
80
99
|
if (this.map && Array.isArray(options.position)) {
|
|
81
100
|
var path = options.position.map(function (elem) {
|
|
82
|
-
return Array.isArray(elem) ? new
|
|
101
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
83
102
|
});
|
|
84
103
|
polylineOption.path = path;
|
|
85
104
|
}
|
|
@@ -108,11 +127,11 @@ var GoogleMintMapController = function (_super) {
|
|
|
108
127
|
visible = _g === void 0 ? true : _g,
|
|
109
128
|
_h = _a.editable,
|
|
110
129
|
editable = _h === void 0 ? false : _h,
|
|
111
|
-
event = _a.event;
|
|
130
|
+
event = _a.event; //console.log('polygon', polygon);
|
|
112
131
|
|
|
113
132
|
if (this.map && Array.isArray(position)) {
|
|
114
133
|
var outLine = position.map(function (elem) {
|
|
115
|
-
return Array.isArray(elem) ? new
|
|
134
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
116
135
|
});
|
|
117
136
|
var paths = [outLine];
|
|
118
137
|
innerPositions && paths.push.apply(paths, innerPositions);
|
|
@@ -127,7 +146,8 @@ var GoogleMintMapController = function (_super) {
|
|
|
127
146
|
clickable: true,
|
|
128
147
|
visible: visible,
|
|
129
148
|
editable: editable
|
|
130
|
-
});
|
|
149
|
+
}); //console.log('google polygon created', polygon);
|
|
150
|
+
|
|
131
151
|
polygon.native = pol_2;
|
|
132
152
|
event && event.forEach(function (handler, key) {
|
|
133
153
|
if (_this.polygonEvents.includes(key)) {
|
|
@@ -138,12 +158,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
138
158
|
};
|
|
139
159
|
|
|
140
160
|
GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
161
|
+
//console.log('controller updatePolygon', options);
|
|
141
162
|
if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
|
|
142
|
-
var polygonOption = this.getValidOptions(options);
|
|
163
|
+
var polygonOption = this.getValidOptions(options); //console.log('controller updatePolygon start', polygonOption);
|
|
143
164
|
|
|
144
165
|
if (this.map && Array.isArray(options.position)) {
|
|
145
166
|
var outLine = options.position.map(function (elem) {
|
|
146
|
-
return Array.isArray(elem) ? new
|
|
167
|
+
return Array.isArray(elem) ? new MapTypes.Position(elem[1], elem[0]) : elem;
|
|
147
168
|
});
|
|
148
169
|
var paths = [outLine];
|
|
149
170
|
options.innerPositions && paths.push.apply(paths, options.innerPositions);
|
|
@@ -155,12 +176,14 @@ var GoogleMintMapController = function (_super) {
|
|
|
155
176
|
};
|
|
156
177
|
|
|
157
178
|
GoogleMintMapController.prototype.getValidOptions = function (options) {
|
|
179
|
+
//console.log('getValidOptions DrawableOptions',options)
|
|
158
180
|
var target = {};
|
|
159
181
|
|
|
160
182
|
for (var _i = 0, _a = Object.getOwnPropertyNames(options); _i < _a.length; _i++) {
|
|
161
|
-
var name_1 = _a[_i];
|
|
183
|
+
var name_1 = _a[_i]; //@ts-ignore
|
|
162
184
|
|
|
163
185
|
if (options[name_1] !== undefined) {
|
|
186
|
+
//@ts-ignore
|
|
164
187
|
target[name_1] = options[name_1];
|
|
165
188
|
}
|
|
166
189
|
}
|
|
@@ -176,7 +199,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
176
199
|
if (this.map) {
|
|
177
200
|
var googleMarker_1;
|
|
178
201
|
|
|
179
|
-
if (marker.element) {
|
|
202
|
+
if (marker.element && marker.element instanceof Element) {
|
|
180
203
|
var options = {
|
|
181
204
|
map: this.map,
|
|
182
205
|
position: marker.options.position
|
|
@@ -207,6 +230,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
207
230
|
};
|
|
208
231
|
|
|
209
232
|
GoogleMintMapController.prototype.updateMarker = function (marker, options) {
|
|
233
|
+
//console.log('controller updateMarker', options);
|
|
210
234
|
var _a, _b;
|
|
211
235
|
|
|
212
236
|
if (marker && marker.native) {
|
|
@@ -216,8 +240,9 @@ var GoogleMintMapController = function (_super) {
|
|
|
216
240
|
if (map) {
|
|
217
241
|
marker.native.setOptions({
|
|
218
242
|
map: map,
|
|
219
|
-
position: options.position instanceof
|
|
220
|
-
visible: options.visible === undefined || options.visible
|
|
243
|
+
position: options.position instanceof MapTypes.Position ? options.position : marker.native.getPosition(),
|
|
244
|
+
visible: options.visible === undefined || options.visible // icon:{...marker.native.getIcon(), anchor:options.anchor}
|
|
245
|
+
|
|
221
246
|
});
|
|
222
247
|
}
|
|
223
248
|
} else if (marker.native instanceof google.maps.marker.AdvancedMarkerView) {
|
|
@@ -225,7 +250,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
225
250
|
marker.native.element.style.visibility = options.visible ? 'visible' : 'hidden';
|
|
226
251
|
}
|
|
227
252
|
|
|
228
|
-
if (options.position instanceof
|
|
253
|
+
if (options.position instanceof MapTypes.Position && (((_a = marker.native.position) === null || _a === void 0 ? void 0 : _a.lat) != options.position.lat || ((_b = marker.native.position) === null || _b === void 0 ? void 0 : _b.lng) != options.position.lng)) {
|
|
229
254
|
marker.native.position = options.position;
|
|
230
255
|
}
|
|
231
256
|
}
|
|
@@ -313,7 +338,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
313
338
|
GoogleMintMapController.prototype.checkLoaded = function () {
|
|
314
339
|
var _a, _b, _c;
|
|
315
340
|
|
|
316
|
-
return (_c = (_b = (_a = window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.marker) === null || _c === void 0 ? void 0 : _c.AdvancedMarkerView;
|
|
341
|
+
return ((_c = (_b = (_a = window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.marker) === null || _c === void 0 ? void 0 : _c.AdvancedMarkerView) ? true : false;
|
|
317
342
|
};
|
|
318
343
|
|
|
319
344
|
GoogleMintMapController.prototype.loadMapApi = function () {
|
|
@@ -321,17 +346,21 @@ var GoogleMintMapController = function (_super) {
|
|
|
321
346
|
var _this = this;
|
|
322
347
|
|
|
323
348
|
return tslib.__generator(this, function (_a) {
|
|
324
|
-
return [2
|
|
349
|
+
return [2
|
|
350
|
+
/*return*/
|
|
351
|
+
, new Promise(function (resolve) {
|
|
325
352
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
326
353
|
var callbackName, loaded, params, callbackExecFlag, ok;
|
|
327
354
|
return tslib.__generator(this, function (_a) {
|
|
328
355
|
switch (_a.label) {
|
|
329
356
|
case 0:
|
|
330
357
|
callbackName = this.getRandomFunctionName('load_google');
|
|
331
|
-
loaded = false;
|
|
358
|
+
loaded = false; //@ts-ignore
|
|
332
359
|
|
|
333
360
|
window[callbackName] = function () {
|
|
334
|
-
|
|
361
|
+
// console.log('google api loaded');
|
|
362
|
+
loaded = true; //@ts-ignore
|
|
363
|
+
|
|
335
364
|
delete window[callbackName];
|
|
336
365
|
};
|
|
337
366
|
|
|
@@ -341,17 +370,23 @@ var GoogleMintMapController = function (_super) {
|
|
|
341
370
|
v: 'beta',
|
|
342
371
|
callback: callbackName
|
|
343
372
|
};
|
|
344
|
-
return [4
|
|
373
|
+
return [4
|
|
374
|
+
/*yield*/
|
|
375
|
+
, this.loadScript(this.buildUrl(this.scriptUrl, params), 'google_map_script', this.checkLoaded)];
|
|
345
376
|
|
|
346
377
|
case 1:
|
|
347
378
|
callbackExecFlag = _a.sent();
|
|
348
379
|
|
|
349
380
|
if (!callbackExecFlag) {
|
|
350
|
-
loaded
|
|
381
|
+
// console.log('google api loaded 222222');
|
|
382
|
+
loaded = true; //@ts-ignore
|
|
383
|
+
|
|
351
384
|
delete window[callbackName];
|
|
352
385
|
}
|
|
353
386
|
|
|
354
|
-
return [4
|
|
387
|
+
return [4
|
|
388
|
+
/*yield*/
|
|
389
|
+
, waiting.waiting(function () {
|
|
355
390
|
return loaded;
|
|
356
391
|
})];
|
|
357
392
|
|
|
@@ -364,7 +399,9 @@ var GoogleMintMapController = function (_super) {
|
|
|
364
399
|
|
|
365
400
|
this.mapApiLoaded = true;
|
|
366
401
|
resolve(true);
|
|
367
|
-
return [2
|
|
402
|
+
return [2
|
|
403
|
+
/*return*/
|
|
404
|
+
];
|
|
368
405
|
}
|
|
369
406
|
});
|
|
370
407
|
});
|
|
@@ -378,8 +415,11 @@ var GoogleMintMapController = function (_super) {
|
|
|
378
415
|
var _this = this;
|
|
379
416
|
|
|
380
417
|
return tslib.__generator(this, function (_a) {
|
|
418
|
+
//div element
|
|
381
419
|
this.mapDivElement = divElement;
|
|
382
|
-
return [2
|
|
420
|
+
return [2
|
|
421
|
+
/*return*/
|
|
422
|
+
, new Promise(function (resolve) {
|
|
383
423
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
384
424
|
var map;
|
|
385
425
|
|
|
@@ -390,15 +430,24 @@ var GoogleMintMapController = function (_super) {
|
|
|
390
430
|
return tslib.__generator(this, function (_e) {
|
|
391
431
|
switch (_e.label) {
|
|
392
432
|
case 0:
|
|
433
|
+
//이미 생성했으면
|
|
434
|
+
//1. divElement 가 그대로인 경우 기존 map 객체 리턴
|
|
435
|
+
//2. divElement 가 바뀐경우 기존 map 객체 destroy 하고 새로 생성
|
|
393
436
|
if (this.mapInitialized && this.map) {
|
|
394
437
|
if (this.map.getDiv() === divElement) {
|
|
395
438
|
resolve(this.map);
|
|
396
|
-
return [2
|
|
439
|
+
return [2
|
|
440
|
+
/*return*/
|
|
441
|
+
];
|
|
397
442
|
}
|
|
398
443
|
}
|
|
399
444
|
|
|
400
|
-
if (!!this.mapApiLoaded) return [3
|
|
401
|
-
|
|
445
|
+
if (!!this.mapApiLoaded) return [3
|
|
446
|
+
/*break*/
|
|
447
|
+
, 2];
|
|
448
|
+
return [4
|
|
449
|
+
/*yield*/
|
|
450
|
+
, this.loadMapApi()];
|
|
402
451
|
|
|
403
452
|
case 1:
|
|
404
453
|
_e.sent();
|
|
@@ -417,30 +466,53 @@ var GoogleMintMapController = function (_super) {
|
|
|
417
466
|
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
418
467
|
clickableIcons: false
|
|
419
468
|
});
|
|
420
|
-
this.map = map;
|
|
469
|
+
this.map = map; //@ts-ignore
|
|
470
|
+
|
|
421
471
|
map.addListener('idle', function () {
|
|
472
|
+
//onBoundsChanged event
|
|
422
473
|
_this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
423
474
|
});
|
|
424
475
|
map.addListener('zoom_changed', function () {
|
|
425
|
-
|
|
426
|
-
|
|
476
|
+
//onZoomChanged event
|
|
477
|
+
// console.log('zoom_changed');
|
|
478
|
+
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom() || 10);
|
|
479
|
+
}); //@ts-ignore
|
|
480
|
+
|
|
427
481
|
map.addListener('click', function (e) {
|
|
482
|
+
// console.log('map click', e)
|
|
428
483
|
if (!_this.mapProps.onClick) return;
|
|
429
|
-
var pos = new
|
|
430
|
-
pos.offset = new
|
|
484
|
+
var pos = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
|
|
485
|
+
pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
|
|
431
486
|
|
|
432
487
|
_this.mapProps.onClick(pos);
|
|
488
|
+
}); //@ts-ignore
|
|
489
|
+
|
|
490
|
+
map.addListener('mousedown', function (e) {
|
|
491
|
+
// console.log('map click', e)
|
|
492
|
+
var pos = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
|
|
493
|
+
pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
|
|
494
|
+
_this.lastMousePosition = pos;
|
|
495
|
+
}); //@ts-ignore
|
|
496
|
+
|
|
497
|
+
map.addListener('mouseup', function (e) {
|
|
498
|
+
// console.log('map click', e)
|
|
499
|
+
var pos = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
|
|
500
|
+
pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
|
|
501
|
+
_this.lastMousePosition = pos;
|
|
433
502
|
});
|
|
434
503
|
map.addListener('mousemove', function (e) {
|
|
435
504
|
if (!_this.mapProps.onMouseMove) return;
|
|
436
|
-
var pos = new
|
|
437
|
-
pos.offset = new
|
|
505
|
+
var pos = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
|
|
506
|
+
pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y); // console.log('mousemove', pos)
|
|
438
507
|
|
|
439
508
|
_this.mapProps.onMouseMove(pos);
|
|
440
509
|
});
|
|
441
|
-
this.mapInitialized = true;
|
|
510
|
+
this.mapInitialized = true; // console.log(`${this.type} map script initialized`, divElement);
|
|
511
|
+
|
|
442
512
|
resolve(map);
|
|
443
|
-
return [2
|
|
513
|
+
return [2
|
|
514
|
+
/*return*/
|
|
515
|
+
];
|
|
444
516
|
}
|
|
445
517
|
});
|
|
446
518
|
});
|
|
@@ -450,7 +522,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
450
522
|
};
|
|
451
523
|
|
|
452
524
|
GoogleMintMapController.prototype.fromGoogleBounds = function (bounds) {
|
|
453
|
-
return
|
|
525
|
+
return MapTypes.Bounds.fromNESW(new MapTypes.Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()), new MapTypes.Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
|
|
454
526
|
};
|
|
455
527
|
|
|
456
528
|
GoogleMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -463,7 +535,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
463
535
|
if (bounds) {
|
|
464
536
|
return this.fromGoogleBounds(bounds);
|
|
465
537
|
} else {
|
|
466
|
-
throw new Error('bounds is not found!!!');
|
|
538
|
+
throw new Error('bounds is not found!!!'); //return new Bounds(new Position(0,0), new Position(0,0))
|
|
467
539
|
}
|
|
468
540
|
};
|
|
469
541
|
|
|
@@ -495,6 +567,114 @@ var GoogleMintMapController = function (_super) {
|
|
|
495
567
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
496
568
|
};
|
|
497
569
|
|
|
570
|
+
GoogleMintMapController.prototype.addEventListener = function (eventName, callback) {
|
|
571
|
+
var _this = this;
|
|
572
|
+
|
|
573
|
+
if (!this.map) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
var googleEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
|
|
578
|
+
|
|
579
|
+
if (!googleEventName) {
|
|
580
|
+
console.warn("MapEventName ".concat(eventName, " is not supported"));
|
|
581
|
+
return;
|
|
582
|
+
} // console.log(`${eventName} add`);
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
var map = this.eventMap.get(eventName);
|
|
586
|
+
|
|
587
|
+
if (!map) {
|
|
588
|
+
map = new Map();
|
|
589
|
+
this.eventMap.set(eventName, map);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
var wrappingCallback = function (e) {
|
|
593
|
+
if (eventName in _this.mapEvent) {
|
|
594
|
+
var bounds = _this.getCurrBounds();
|
|
595
|
+
|
|
596
|
+
var param = {
|
|
597
|
+
name: eventName,
|
|
598
|
+
mapType: 'google',
|
|
599
|
+
vendorEventName: googleEventName,
|
|
600
|
+
param: {
|
|
601
|
+
bounds: bounds,
|
|
602
|
+
center: bounds.getCenter(),
|
|
603
|
+
zoomLevel: _this.getZoomLevel()
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
callback(param);
|
|
607
|
+
} else if (eventName in _this.mapUIEvent) {
|
|
608
|
+
if (eventName.startsWith('DRAG')) console.log(eventName, e);
|
|
609
|
+
var position = null;
|
|
610
|
+
|
|
611
|
+
if (e) {
|
|
612
|
+
position = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
|
|
613
|
+
position.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
|
|
614
|
+
} else {
|
|
615
|
+
position = _this.lastMousePosition;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
var param = {
|
|
619
|
+
name: eventName,
|
|
620
|
+
mapType: 'google',
|
|
621
|
+
vendorEventName: googleEventName,
|
|
622
|
+
param: {
|
|
623
|
+
position: position,
|
|
624
|
+
offset: position === null || position === void 0 ? void 0 : position.offset
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
callback(param);
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
var googleEventListener = this.map.addListener(googleEventName, wrappingCallback);
|
|
632
|
+
map.set(callback, googleEventListener);
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
GoogleMintMapController.prototype.removeEventListener = function (eventName, callback) {
|
|
636
|
+
var map = this.eventMap.get(eventName);
|
|
637
|
+
|
|
638
|
+
if (map) {
|
|
639
|
+
var listenerMap = this.eventMap.get(eventName);
|
|
640
|
+
|
|
641
|
+
if (listenerMap) {
|
|
642
|
+
var googleEventListener = listenerMap.get(callback);
|
|
643
|
+
|
|
644
|
+
if (googleEventListener) {
|
|
645
|
+
// console.log(`${eventName} remove`);
|
|
646
|
+
google.maps.event.removeListener(googleEventListener);
|
|
647
|
+
listenerMap.delete(callback);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
GoogleMintMapController.prototype.removeAllEventListener = function (eventName) {
|
|
654
|
+
var _this = this;
|
|
655
|
+
|
|
656
|
+
if (eventName) {
|
|
657
|
+
this.clearEventListener(eventName);
|
|
658
|
+
} else {
|
|
659
|
+
this.eventMap.forEach(function (_map, eventName) {
|
|
660
|
+
_this.clearEventListener(eventName);
|
|
661
|
+
});
|
|
662
|
+
this.eventMap.clear();
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
GoogleMintMapController.prototype.clearEventListener = function (eventName) {
|
|
667
|
+
var map = this.eventMap.get(eventName);
|
|
668
|
+
|
|
669
|
+
if (map) {
|
|
670
|
+
map.forEach(function (googleEventListener) {
|
|
671
|
+
// console.log(`${eventName} remove`);
|
|
672
|
+
google.maps.event.removeListener(googleEventListener);
|
|
673
|
+
});
|
|
674
|
+
this.eventMap.delete(eventName);
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
498
678
|
return GoogleMintMapController;
|
|
499
679
|
}(MintMapController.MintMapController);
|
|
500
680
|
|