@mint-ui/map 0.4.0-beta → 0.4.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/components/mint-map/MintMap.d.ts +1 -0
- package/dist/components/mint-map/core/MintMapCanvasRenderer.d.ts +4 -0
- package/dist/components/mint-map/core/MintMapCanvasRenderer.js +13 -0
- package/dist/components/mint-map/core/MintMapController.d.ts +4 -1
- package/dist/components/mint-map/core/MintMapController.js +33 -1
- package/dist/components/mint-map/core/MintMapCore.d.ts +1 -1
- package/dist/components/mint-map/core/MintMapCore.js +6 -4
- package/dist/components/mint-map/core/index.d.ts +1 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.d.ts +19 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.js +15 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.d.ts +4 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.js +271 -0
- package/dist/components/mint-map/core/wrapper/index.d.ts +2 -0
- package/dist/components/mint-map/google/GoogleMintMapController.js +1 -6
- package/dist/components/mint-map/kakao/KakaoMintMapController.js +1 -5
- package/dist/components/mint-map/naver/NaverMintMapController.js +3 -8
- package/dist/index.es.js +313 -26
- package/dist/index.js +6 -0
- package/dist/index.umd.js +314 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
- React map library
|
|
4
4
|
- Control various map with one interface
|
|
5
|
-
- Google, Naver map supported now
|
|
5
|
+
- Google, Naver, Kakao map supported now
|
|
6
6
|
- Typescript supported
|
|
7
|
+
- Canvas marker supported (experimental)
|
|
7
8
|
|
|
8
9
|
## Installation
|
|
9
10
|
|
|
@@ -40,6 +41,25 @@ function MyMapComponent(){
|
|
|
40
41
|
<div style={{width:'10px', height:'10px', background:'red', borderRadius:'10px'}}></div>
|
|
41
42
|
|
|
42
43
|
</MapMarkerWrapper>
|
|
44
|
+
|
|
45
|
+
{/* Overlay canvas */}
|
|
46
|
+
<MapCanvasWrapper>
|
|
47
|
+
|
|
48
|
+
{/* Canvas marker */}
|
|
49
|
+
<MapCanvasMarkerWrapper position={new Position(-25.344, 131.031)}
|
|
50
|
+
renderer={(renderer:MintMapCanvasRenderer, offset:Offset, _payload?:TestPayload)=>{
|
|
51
|
+
const {context} = renderer
|
|
52
|
+
context.fillStyle = `hsl(${(Math.random() * 360).toFixed(0)} 100% 60%)`
|
|
53
|
+
context.fillRect(Math.floor(offset.x), Math.floor(offset.y), 8, 8)
|
|
54
|
+
}}
|
|
55
|
+
boxWidth={8} boxHeight={8}
|
|
56
|
+
payload={testItem}
|
|
57
|
+
onClick={(e)=>{
|
|
58
|
+
alert('marker 1 clicked!!!'+e.x+','+e.y)
|
|
59
|
+
}}
|
|
60
|
+
></MapCanvasMarkerWrapper>
|
|
61
|
+
|
|
62
|
+
</MapCanvasWrapper>
|
|
43
63
|
|
|
44
64
|
</MintMap>
|
|
45
65
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var MintMapCanvasRenderer = function () {
|
|
6
|
+
function MintMapCanvasRenderer(context) {
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return MintMapCanvasRenderer;
|
|
11
|
+
}();
|
|
12
|
+
|
|
13
|
+
exports.MintMapCanvasRenderer = MintMapCanvasRenderer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bounds, Drawable, MapType, MapVendorType, Marker, MarkerOptions, MintMapProps, Polygon, PolygonOptions, Polyline, PolylineOptions, Position } from "../MintMap";
|
|
1
|
+
import { Bounds, Drawable, MapType, MapVendorType, Marker, MarkerOptions, MintMapProps, Offset, Polygon, PolygonOptions, Polyline, PolylineOptions, Position } from "../MintMap";
|
|
2
2
|
export declare abstract class MintMapController {
|
|
3
3
|
abstract type: MapType;
|
|
4
4
|
abstract map: MapVendorType | null;
|
|
@@ -26,9 +26,12 @@ export declare abstract class MintMapController {
|
|
|
26
26
|
mapProps: MintMapProps;
|
|
27
27
|
mapApiLoaded: boolean;
|
|
28
28
|
mapInitialized: boolean;
|
|
29
|
+
mapDivElement: HTMLDivElement;
|
|
29
30
|
constructor(props: MintMapProps);
|
|
30
31
|
getMap(): MapVendorType | null;
|
|
31
32
|
getMapType(): MapType;
|
|
33
|
+
positionToOffset(position: Position): Offset;
|
|
34
|
+
offsetToPosition(offset: Offset): Position;
|
|
32
35
|
loadScript(url: string, id?: string): Promise<void>;
|
|
33
36
|
buildUrl(baseUrl: string, param: {
|
|
34
37
|
[key: string]: string | string[];
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
+
var MintMap = require('../MintMap.js');
|
|
6
7
|
|
|
7
8
|
var MintMapController = function () {
|
|
8
9
|
function MintMapController(props) {
|
|
@@ -20,12 +21,43 @@ var MintMapController = function () {
|
|
|
20
21
|
return this.type;
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
MintMapController.prototype.positionToOffset = function (position) {
|
|
25
|
+
var div = this.mapDivElement;
|
|
26
|
+
var w = div === null || div === void 0 ? void 0 : div.offsetWidth;
|
|
27
|
+
var h = div === null || div === void 0 ? void 0 : div.offsetHeight;
|
|
28
|
+
var bounds = this.getCurrBounds();
|
|
29
|
+
var maxLng = bounds.ne.lng;
|
|
30
|
+
var minLng = bounds.sw.lng;
|
|
31
|
+
var lng = Math.abs(maxLng - minLng);
|
|
32
|
+
var x = w * (position.lng - minLng) / lng;
|
|
33
|
+
var maxLat = bounds.ne.lat;
|
|
34
|
+
var minLat = bounds.sw.lat;
|
|
35
|
+
var lat = Math.abs(maxLat - minLat);
|
|
36
|
+
var y = h * (maxLat - position.lat) / lat;
|
|
37
|
+
return new MintMap.Offset(x, y);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
MintMapController.prototype.offsetToPosition = function (offset) {
|
|
41
|
+
var div = this.mapDivElement;
|
|
42
|
+
var w = div === null || div === void 0 ? void 0 : div.offsetWidth;
|
|
43
|
+
var h = div === null || div === void 0 ? void 0 : div.offsetHeight;
|
|
44
|
+
var bounds = this.getCurrBounds();
|
|
45
|
+
var maxLng = bounds.ne.lng;
|
|
46
|
+
var minLng = bounds.sw.lng;
|
|
47
|
+
var lng = Math.abs(maxLng - minLng);
|
|
48
|
+
var lngVal = offset.x * lng / w + minLng;
|
|
49
|
+
var maxLat = bounds.ne.lat;
|
|
50
|
+
var minLat = bounds.sw.lat;
|
|
51
|
+
var lat = Math.abs(maxLat - minLat);
|
|
52
|
+
var latVal = (offset.y * lat / h - maxLat) * -1;
|
|
53
|
+
return new MintMap.Position(latVal, lngVal);
|
|
54
|
+
};
|
|
55
|
+
|
|
23
56
|
MintMapController.prototype.loadScript = function (url, id) {
|
|
24
57
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
25
58
|
return tslib.__generator(this, function (_a) {
|
|
26
59
|
return [2, new Promise(function (resolve) {
|
|
27
60
|
if (id && document.getElementById(id)) {
|
|
28
|
-
console.log("already loaded script => ".concat(id));
|
|
29
61
|
resolve();
|
|
30
62
|
return;
|
|
31
63
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
2
|
import { MintMapProps } from "../MintMap";
|
|
3
|
-
export declare function MintMapCore({ onLoad, visible, zoomLevel, center, children }: PropsWithChildren<MintMapProps>): JSX.Element;
|
|
3
|
+
export declare function MintMapCore({ onLoad, visible, zoomLevel, center, centerMoveWithPanning, children }: PropsWithChildren<MintMapProps>): JSX.Element;
|
|
@@ -23,13 +23,15 @@ function MintMapCore(_a) {
|
|
|
23
23
|
visible = _b === void 0 ? true : _b,
|
|
24
24
|
zoomLevel = _a.zoomLevel,
|
|
25
25
|
center = _a.center,
|
|
26
|
+
_c = _a.centerMoveWithPanning,
|
|
27
|
+
centerMoveWithPanning = _c === void 0 ? false : _c,
|
|
26
28
|
children = _a.children;
|
|
27
29
|
var controller = MintMapProvider.useMintMapController();
|
|
28
30
|
var elementRef = React.useRef(null);
|
|
29
31
|
|
|
30
|
-
var
|
|
31
|
-
mapInitialized =
|
|
32
|
-
setMapInitialized =
|
|
32
|
+
var _d = React.useState(false),
|
|
33
|
+
mapInitialized = _d[0],
|
|
34
|
+
setMapInitialized = _d[1];
|
|
33
35
|
|
|
34
36
|
React.useEffect(function () {
|
|
35
37
|
(function () {
|
|
@@ -74,7 +76,7 @@ function MintMapCore(_a) {
|
|
|
74
76
|
var prevCenter = controller.getCenter();
|
|
75
77
|
|
|
76
78
|
if (!MintMap.Position.equals(prevCenter, center)) {
|
|
77
|
-
controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
79
|
+
centerMoveWithPanning ? controller === null || controller === void 0 ? void 0 : controller.panningTo(center) : controller === null || controller === void 0 ? void 0 : controller.setCenter(center);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
}, [center]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MarkerOptions, Offset } from "../../MintMap";
|
|
3
|
+
import { MintMapCanvasRenderer } from "../MintMapCanvasRenderer";
|
|
4
|
+
export declare type CanvasMarkerRenderer<T> = (ctx: MintMapCanvasRenderer, offset: Offset, payload?: T) => void;
|
|
5
|
+
export interface CanvasMarkerMouseEvent {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
export declare type CanvasMarkerMouseEventCallback = (e: CanvasMarkerMouseEvent) => boolean | undefined | void;
|
|
10
|
+
export interface MapCanvasMarkerWrapperProps<T> extends MarkerOptions {
|
|
11
|
+
renderer: CanvasMarkerRenderer<T>;
|
|
12
|
+
payload?: T;
|
|
13
|
+
boxWidth: number;
|
|
14
|
+
boxHeight: number;
|
|
15
|
+
onClick?: CanvasMarkerMouseEventCallback;
|
|
16
|
+
onMouseOver?: CanvasMarkerMouseEventCallback;
|
|
17
|
+
onMouseOut?: CanvasMarkerMouseEventCallback;
|
|
18
|
+
}
|
|
19
|
+
export declare function MapCanvasMarkerWrapper<T>(_props: MapCanvasMarkerWrapperProps<T>): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
|
|
11
|
+
function MapCanvasMarkerWrapper(_props) {
|
|
12
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.MapCanvasMarkerWrapper = MapCanvasMarkerWrapper;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var MintMapProvider = require('../provider/MintMapProvider.js');
|
|
8
|
+
var MintMapCanvasRenderer = require('../MintMapCanvasRenderer.js');
|
|
9
|
+
var MintMap = require('../../MintMap.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
+
|
|
15
|
+
var console = {
|
|
16
|
+
log: function () {
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function MapCanvasWrapper(_a) {
|
|
20
|
+
var children = _a.children;
|
|
21
|
+
tslib.__rest(_a, ["children"]);
|
|
22
|
+
var controller = MintMapProvider.useMintMapController();
|
|
23
|
+
|
|
24
|
+
var _b = React.useState(false),
|
|
25
|
+
renderFlag = _b[0],
|
|
26
|
+
setRenderFlag = _b[1];
|
|
27
|
+
|
|
28
|
+
var invokeRender = React.useCallback(function () {
|
|
29
|
+
setRenderFlag(!renderFlag);
|
|
30
|
+
}, []);
|
|
31
|
+
var renderer = React.useRef();
|
|
32
|
+
var containerRef = React.useRef(null);
|
|
33
|
+
var canvasRef = React.useRef(null);
|
|
34
|
+
var contextRef = React.useRef();
|
|
35
|
+
var clearRect = React.useCallback(function () {
|
|
36
|
+
if (contextRef.current && canvasRef.current) {
|
|
37
|
+
contextRef.current.clearRect(canvasRef.current.width * -1, canvasRef.current.height * -1, canvasRef.current.width * 3, canvasRef.current.height * 3);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
}, []);
|
|
42
|
+
var scaleCanvas = React.useCallback(function (containerRef, canvasElement, canvasContext) {
|
|
43
|
+
var devicePixelRatio = window.devicePixelRatio;
|
|
44
|
+
var width = containerRef.offsetWidth;
|
|
45
|
+
var height = containerRef.offsetHeight;
|
|
46
|
+
canvasElement.width = width * devicePixelRatio;
|
|
47
|
+
canvasElement.height = height * devicePixelRatio;
|
|
48
|
+
canvasElement.style.width = "".concat(width, "px");
|
|
49
|
+
canvasElement.style.height = "".concat(height, "px");
|
|
50
|
+
canvasContext.scale(devicePixelRatio, devicePixelRatio);
|
|
51
|
+
}, []);
|
|
52
|
+
var parseClickParamToPosition = React.useCallback(function (mapType, e) {
|
|
53
|
+
var latlng = e.latlng || e.latLng;
|
|
54
|
+
|
|
55
|
+
if (!latlng) {
|
|
56
|
+
throw new Error("Map Type ".concat(mapType, " canvas marker click not supported (latlng not found)"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var clickPosition = new MintMap.Position(0, 0);
|
|
60
|
+
|
|
61
|
+
if (mapType === 'naver') {
|
|
62
|
+
clickPosition.lat = latlng._lat;
|
|
63
|
+
clickPosition.lng = latlng._lng;
|
|
64
|
+
} else if (mapType === 'google') {
|
|
65
|
+
clickPosition.lat = latlng.lat();
|
|
66
|
+
clickPosition.lng = latlng.lng();
|
|
67
|
+
} else if (mapType === 'kakao') {
|
|
68
|
+
clickPosition.lat = latlng.Ma;
|
|
69
|
+
clickPosition.lng = latlng.La;
|
|
70
|
+
} else {
|
|
71
|
+
throw new Error("Map Type ".concat(mapType, " canvas marker click not supported"));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return clickPosition;
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
var includes = function (point, targetPoint, width, height) {
|
|
78
|
+
if (point.x >= targetPoint.x && point.x <= targetPoint.x + width && point.y >= targetPoint.y && point.y <= targetPoint.y + height) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var processMouseEvent = React.useCallback(function (clickedOffset, eventName) {
|
|
86
|
+
var items = renderItemsOnView.current;
|
|
87
|
+
var hitSet = new Set();
|
|
88
|
+
|
|
89
|
+
for (var i = items.length - 1; i >= 0; i--) {
|
|
90
|
+
var item = items[i];
|
|
91
|
+
|
|
92
|
+
if (item.visible === undefined || item.visible) {
|
|
93
|
+
var event_1 = item[eventName];
|
|
94
|
+
|
|
95
|
+
if (!event_1) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var pos = item.position;
|
|
100
|
+
|
|
101
|
+
if (pos && !pos.offset) {
|
|
102
|
+
pos.offset = controller.positionToOffset(pos);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!pos || !pos.offset || !includes(clickedOffset, pos.offset, item.boxWidth, item.boxHeight)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
event_1(clickedOffset);
|
|
110
|
+
hitSet.add(item);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return hitSet;
|
|
116
|
+
}, []);
|
|
117
|
+
React.useEffect(function () {
|
|
118
|
+
var resizeObserver;
|
|
119
|
+
|
|
120
|
+
if (canvasRef.current && containerRef.current) {
|
|
121
|
+
resizeObserver = new ResizeObserver(function (entries) {
|
|
122
|
+
var elem = entries[0];
|
|
123
|
+
canvasRef.current && contextRef.current && scaleCanvas(elem.target, canvasRef.current, contextRef.current);
|
|
124
|
+
renderMain();
|
|
125
|
+
});
|
|
126
|
+
resizeObserver.observe(containerRef.current);
|
|
127
|
+
var map = controller.getMap();
|
|
128
|
+
|
|
129
|
+
if (map) {
|
|
130
|
+
map.addListener('zooming', function () {
|
|
131
|
+
clearRect();
|
|
132
|
+
});
|
|
133
|
+
map.addListener('zoom_start', function () {
|
|
134
|
+
clearRect();
|
|
135
|
+
});
|
|
136
|
+
map.addListener('center_changed', function () {
|
|
137
|
+
|
|
138
|
+
if (containerRef.current) {
|
|
139
|
+
containerRef.current.style.visibility = 'hidden';
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
map.addListener('idle', function () {
|
|
143
|
+
|
|
144
|
+
if (containerRef.current) {
|
|
145
|
+
containerRef.current.style.visibility = '';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
clearRect();
|
|
149
|
+
invokeRender();
|
|
150
|
+
});
|
|
151
|
+
map.addListener('mousemove', function (e) {
|
|
152
|
+
var clickPosition = parseClickParamToPosition(controller.getMapType(), e);
|
|
153
|
+
var clickedOffset = controller.positionToOffset(clickPosition);
|
|
154
|
+
var hitSet = processMouseEvent(clickedOffset, 'onMouseOver');
|
|
155
|
+
renderItemsMouseOverStatus.current.forEach(function (item) {
|
|
156
|
+
if (!hitSet.has(item)) {
|
|
157
|
+
item.onMouseOut && item.onMouseOut(clickedOffset);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
renderItemsMouseOverStatus.current = hitSet;
|
|
161
|
+
});
|
|
162
|
+
map.addListener('click', function (e) {
|
|
163
|
+
var clickPosition = parseClickParamToPosition(controller.getMapType(), e);
|
|
164
|
+
var clickedOffset = controller.positionToOffset(clickPosition);
|
|
165
|
+
processMouseEvent(clickedOffset, 'onClick');
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
contextRef.current = canvasRef.current.getContext('2d');
|
|
170
|
+
|
|
171
|
+
if (contextRef.current) {
|
|
172
|
+
scaleCanvas(containerRef.current, canvasRef.current, contextRef.current);
|
|
173
|
+
renderer.current = new MintMapCanvasRenderer.MintMapCanvasRenderer(contextRef.current);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return function () {
|
|
178
|
+
resizeObserver && resizeObserver.disconnect();
|
|
179
|
+
};
|
|
180
|
+
}, []);
|
|
181
|
+
var renderItems = React.useRef([]);
|
|
182
|
+
var renderItemsOnView = React.useRef([]);
|
|
183
|
+
var renderItemsMouseOverStatus = React.useRef(new Set());
|
|
184
|
+
React.useEffect(function () {
|
|
185
|
+
renderItems.current = (Array.isArray(children) ? children : [children]).map(function (item) {
|
|
186
|
+
return item.props;
|
|
187
|
+
});
|
|
188
|
+
var zIndexList = [];
|
|
189
|
+
var undefinedList = [];
|
|
190
|
+
|
|
191
|
+
for (var _i = 0, _a = renderItems.current; _i < _a.length; _i++) {
|
|
192
|
+
var item = _a[_i];
|
|
193
|
+
|
|
194
|
+
if (item.zIndex !== undefined) {
|
|
195
|
+
zIndexList.push(item);
|
|
196
|
+
} else {
|
|
197
|
+
undefinedList.push(item);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
renderItems.current = undefinedList;
|
|
202
|
+
zIndexList.sort(function (a, b) {
|
|
203
|
+
return a > b ? 1 : -1;
|
|
204
|
+
}).forEach(function (item) {
|
|
205
|
+
renderItems.current.push(item);
|
|
206
|
+
});
|
|
207
|
+
}, [children]);
|
|
208
|
+
var renderMain = React.useCallback(function () {
|
|
209
|
+
var ctx = contextRef.current;
|
|
210
|
+
var container = containerRef.current;
|
|
211
|
+
|
|
212
|
+
if (!ctx || !container || !renderer.current) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
clearRect();
|
|
217
|
+
var t = new Date().getTime();
|
|
218
|
+
var items = renderItems.current;
|
|
219
|
+
renderItemsOnView.current.length = 0;
|
|
220
|
+
var newSet = new Set();
|
|
221
|
+
|
|
222
|
+
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
223
|
+
var item = items_1[_i];
|
|
224
|
+
|
|
225
|
+
if (item.visible === undefined || item.visible) {
|
|
226
|
+
var pos = item.position;
|
|
227
|
+
pos.offset = controller.positionToOffset(pos);
|
|
228
|
+
|
|
229
|
+
if (item.anchor) {
|
|
230
|
+
pos.offset.x += item.anchor.x;
|
|
231
|
+
pos.offset.y += item.anchor.y;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
console.log('canvas marker', pos.offset);
|
|
235
|
+
|
|
236
|
+
if (pos.offset.x < 0 || pos.offset.x > container.offsetWidth || pos.offset.y < 0 || pos.offset.y > container.offsetHeight) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
item.renderer(renderer.current, pos.offset, item.payload);
|
|
241
|
+
renderItemsOnView.current.push(item);
|
|
242
|
+
newSet.add(item);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
renderItemsMouseOverStatus.current.forEach(function (item) {
|
|
247
|
+
if (!newSet.has(item)) {
|
|
248
|
+
renderItemsMouseOverStatus.current.delete(item);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
console.log("[render ends] ".concat(new Date().getTime() - t, " ms"));
|
|
252
|
+
}, []);
|
|
253
|
+
renderMain();
|
|
254
|
+
return React__default["default"].createElement("div", {
|
|
255
|
+
ref: containerRef,
|
|
256
|
+
style: {
|
|
257
|
+
position: 'absolute',
|
|
258
|
+
width: '100%',
|
|
259
|
+
height: '100%',
|
|
260
|
+
zIndex: 2,
|
|
261
|
+
pointerEvents: 'none'
|
|
262
|
+
}
|
|
263
|
+
}, React__default["default"].createElement("canvas", {
|
|
264
|
+
ref: canvasRef,
|
|
265
|
+
style: {
|
|
266
|
+
pointerEvents: 'revert-layer'
|
|
267
|
+
}
|
|
268
|
+
}), renderFlag && React__default["default"].createElement(React__default["default"].Fragment, null));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
exports.MapCanvasWrapper = MapCanvasWrapper;
|
|
@@ -28,11 +28,8 @@ var GoogleMintMapController = function (_super) {
|
|
|
28
28
|
} catch (e) {
|
|
29
29
|
console.log('google map destroy error', e);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
console.log("".concat(_this.type, " map destroyed"));
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
console.log("".concat(_this.type, " controller loadded"));
|
|
36
33
|
return _this;
|
|
37
34
|
}
|
|
38
35
|
|
|
@@ -328,7 +325,6 @@ var GoogleMintMapController = function (_super) {
|
|
|
328
325
|
loaded = false;
|
|
329
326
|
|
|
330
327
|
window[callbackName] = function () {
|
|
331
|
-
console.log('google api loaded');
|
|
332
328
|
loaded = true;
|
|
333
329
|
delete window[callbackName];
|
|
334
330
|
};
|
|
@@ -357,7 +353,6 @@ var GoogleMintMapController = function (_super) {
|
|
|
357
353
|
|
|
358
354
|
this.mapApiLoaded = true;
|
|
359
355
|
resolve(true);
|
|
360
|
-
console.log("".concat(this.type, " map script api loaded"));
|
|
361
356
|
return [2];
|
|
362
357
|
}
|
|
363
358
|
});
|
|
@@ -372,6 +367,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
372
367
|
var _this = this;
|
|
373
368
|
|
|
374
369
|
return tslib.__generator(this, function (_a) {
|
|
370
|
+
this.mapDivElement = divElement;
|
|
375
371
|
return [2, new Promise(function (resolve) {
|
|
376
372
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
377
373
|
var map;
|
|
@@ -432,7 +428,6 @@ var GoogleMintMapController = function (_super) {
|
|
|
432
428
|
_this.mapProps.onMouseMove(pos);
|
|
433
429
|
});
|
|
434
430
|
this.mapInitialized = true;
|
|
435
|
-
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
436
431
|
resolve(map);
|
|
437
432
|
return [2];
|
|
438
433
|
}
|
|
@@ -23,7 +23,6 @@ var KakaoMintMapController = function (_super) {
|
|
|
23
23
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
24
24
|
_this.dragStartPoint = [0, 0];
|
|
25
25
|
_this.dragged = false;
|
|
26
|
-
console.log("".concat(_this.type, " controller loadded"));
|
|
27
26
|
return _this;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -341,7 +340,6 @@ var KakaoMintMapController = function (_super) {
|
|
|
341
340
|
|
|
342
341
|
this.mapApiLoaded = true;
|
|
343
342
|
resolve(true);
|
|
344
|
-
console.log("".concat(this.type, " map script loaded"));
|
|
345
343
|
return [2];
|
|
346
344
|
}
|
|
347
345
|
});
|
|
@@ -356,6 +354,7 @@ var KakaoMintMapController = function (_super) {
|
|
|
356
354
|
var _this = this;
|
|
357
355
|
|
|
358
356
|
return tslib.__generator(this, function (_a) {
|
|
357
|
+
this.mapDivElement = divElement;
|
|
359
358
|
return [2, new Promise(function (resolve) {
|
|
360
359
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
361
360
|
var options, maxZoom, minZoom, map;
|
|
@@ -433,7 +432,6 @@ var KakaoMintMapController = function (_super) {
|
|
|
433
432
|
});
|
|
434
433
|
this.mapInitialized = true;
|
|
435
434
|
this.initMarkerPool();
|
|
436
|
-
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
437
435
|
resolve(map);
|
|
438
436
|
return [2];
|
|
439
437
|
}
|
|
@@ -464,8 +462,6 @@ var KakaoMintMapController = function (_super) {
|
|
|
464
462
|
} catch (e) {
|
|
465
463
|
console.log('kakao map destroy error', e);
|
|
466
464
|
}
|
|
467
|
-
|
|
468
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
469
465
|
};
|
|
470
466
|
|
|
471
467
|
KakaoMintMapController.prototype.getCurrBounds = function () {
|
|
@@ -23,7 +23,6 @@ var NaverMintMapController = function (_super) {
|
|
|
23
23
|
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
24
24
|
_this.dragStartPoint = [0, 0];
|
|
25
25
|
_this.dragged = false;
|
|
26
|
-
console.log("".concat(_this.type, " controller loadded"));
|
|
27
26
|
return _this;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -309,7 +308,7 @@ var NaverMintMapController = function (_super) {
|
|
|
309
308
|
var _this = this;
|
|
310
309
|
|
|
311
310
|
return tslib.__generator(this, function (_a) {
|
|
312
|
-
return [2, new Promise(function (resolve) {
|
|
311
|
+
return [2, new Promise(function (resolve, error) {
|
|
313
312
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
314
313
|
var callbackName, loaded, params, ok;
|
|
315
314
|
return tslib.__generator(this, function (_a) {
|
|
@@ -319,7 +318,6 @@ var NaverMintMapController = function (_super) {
|
|
|
319
318
|
loaded = false;
|
|
320
319
|
|
|
321
320
|
window[callbackName] = function () {
|
|
322
|
-
console.log('naver api loaded');
|
|
323
321
|
loaded = true;
|
|
324
322
|
delete window[callbackName];
|
|
325
323
|
};
|
|
@@ -342,12 +340,11 @@ var NaverMintMapController = function (_super) {
|
|
|
342
340
|
ok = _a.sent();
|
|
343
341
|
|
|
344
342
|
if (!ok) {
|
|
345
|
-
|
|
343
|
+
error('naver script api load failed!!');
|
|
346
344
|
}
|
|
347
345
|
|
|
348
346
|
this.mapApiLoaded = true;
|
|
349
347
|
resolve(true);
|
|
350
|
-
console.log("".concat(this.type, " map script loaded"));
|
|
351
348
|
return [2];
|
|
352
349
|
}
|
|
353
350
|
});
|
|
@@ -362,6 +359,7 @@ var NaverMintMapController = function (_super) {
|
|
|
362
359
|
var _this = this;
|
|
363
360
|
|
|
364
361
|
return tslib.__generator(this, function (_a) {
|
|
362
|
+
this.mapDivElement = divElement;
|
|
365
363
|
return [2, new Promise(function (resolve) {
|
|
366
364
|
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
367
365
|
var options, maxZoom, minZoom, map;
|
|
@@ -454,7 +452,6 @@ var NaverMintMapController = function (_super) {
|
|
|
454
452
|
});
|
|
455
453
|
this.mapInitialized = true;
|
|
456
454
|
this.initMarkerPool();
|
|
457
|
-
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
458
455
|
resolve(map);
|
|
459
456
|
map.trigger('idle');
|
|
460
457
|
return [2];
|
|
@@ -485,8 +482,6 @@ var NaverMintMapController = function (_super) {
|
|
|
485
482
|
} catch (e) {
|
|
486
483
|
console.log('naver map destroy error', e);
|
|
487
484
|
}
|
|
488
|
-
|
|
489
|
-
console.log("".concat(this.type, " map destroyed"));
|
|
490
485
|
};
|
|
491
486
|
|
|
492
487
|
NaverMintMapController.prototype.getCurrBounds = function () {
|