@rousen/react-naver-maps 0.1.3 → 0.1.5
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 +12 -1
- package/dist/components/DataLayer.d.ts +2 -2
- package/dist/components/DataLayer.d.ts.map +1 -1
- package/dist/components/Map.d.ts +3 -1
- package/dist/components/Map.d.ts.map +1 -1
- package/dist/components/Marker.d.ts.map +1 -1
- package/dist/components/Overlay.d.ts +1 -1
- package/dist/components/Overlay.d.ts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.esm.js +149 -68
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +149 -68
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# react-naver-maps
|
|
2
2
|
|
|
3
|
-
네이버 지도 API를 React에서 쉽게 사용할 수 있도록 만든 라이브러리입니다.
|
|
3
|
+
네이버 지도 API v3를 React에서 쉽게 사용할 수 있도록 만든 라이브러리입니다. 공식 API 문서는 https://navermaps.github.io/maps.js.ncp/docs/index.html 를 참고하세요.
|
|
4
4
|
|
|
5
5
|
## 설치
|
|
6
6
|
|
|
@@ -12,6 +12,16 @@ yarn add @rousen/react-naver-maps
|
|
|
12
12
|
pnpm add @rousen/react-naver-maps
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
TypeScript에서 `naver.maps.*` 전역 타입을 쓰려면 `@types/navermaps`를 개발 의존성으로 추가하세요.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -D @types/navermaps
|
|
19
|
+
# 또는
|
|
20
|
+
yarn add -D @types/navermaps
|
|
21
|
+
# 또는
|
|
22
|
+
pnpm add -D @types/navermaps
|
|
23
|
+
```
|
|
24
|
+
|
|
15
25
|
## 빠른 시작
|
|
16
26
|
|
|
17
27
|
```tsx
|
|
@@ -76,6 +86,7 @@ npm run lint
|
|
|
76
86
|
- 📦 트리 쉐이킹 지원
|
|
77
87
|
- 🔌 GL 기본 활성(실패 시 자동 non-GL 폴백), Traffic, Transit 등 서브모듈 지원
|
|
78
88
|
- ⚡ 풍부한 이벤트 핸들러 지원
|
|
89
|
+
- ♻️ `reuseMap`으로 동일 `id` 지도 인스턴스 재사용 지원
|
|
79
90
|
|
|
80
91
|
## 호환성
|
|
81
92
|
|
|
@@ -41,12 +41,12 @@ type DataLayerEventProps = {
|
|
|
41
41
|
type DataLayerType = "gpx" | "kml" | "geojson";
|
|
42
42
|
export interface DataLayerProps extends DataLayerEventProps {
|
|
43
43
|
type: DataLayerType;
|
|
44
|
-
|
|
44
|
+
data: string | naver.maps.GeoJSON | naver.maps.GPX | naver.maps.KML;
|
|
45
45
|
autoStyle?: boolean;
|
|
46
46
|
style?: naver.maps.StyleOptions | naver.maps.StylingFunction;
|
|
47
47
|
onLoad?: (layer: naver.maps.Data) => void;
|
|
48
48
|
onError?: (error: Error) => void;
|
|
49
49
|
}
|
|
50
|
-
declare const DataLayer: ({ type,
|
|
50
|
+
declare const DataLayer: ({ type, data, autoStyle, style, onLoad, onError, ...eventProps }: DataLayerProps) => null;
|
|
51
51
|
export default DataLayer;
|
|
52
52
|
//# sourceMappingURL=DataLayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataLayer.d.ts","sourceRoot":"","sources":["../../src/components/DataLayer.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;CAeT,CAAC;AAEX,KAAK,QAAQ,GAAG,MAAM,OAAO,aAAa,CAAC;AAC3C,KAAK,OAAO,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEhD,UAAU,kBAAkB;IAC1B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;IACtD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAA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CAAC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;IAC7D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,QAAA,MAAM,SAAS,GAAI,kEAQhB,cAAc,SA8GhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/components/Map.d.ts
CHANGED
|
@@ -91,12 +91,14 @@ export interface MapProps extends MapEventProps {
|
|
|
91
91
|
ncpKeyId: string;
|
|
92
92
|
id?: string;
|
|
93
93
|
mapTypeId?: naver.maps.MapTypeId;
|
|
94
|
-
|
|
94
|
+
initialOptions?: Omit<naver.maps.MapOptions, "gl">;
|
|
95
95
|
children?: ReactNode;
|
|
96
96
|
submodules?: NaverMapsSubmodule[];
|
|
97
97
|
style?: React.CSSProperties;
|
|
98
98
|
disableGL?: boolean;
|
|
99
99
|
reuseMap?: boolean;
|
|
100
|
+
center?: naver.maps.MapOptions["center"];
|
|
101
|
+
zoom?: naver.maps.MapOptions["zoom"];
|
|
100
102
|
}
|
|
101
103
|
declare const Map: import("react").ForwardRefExoticComponent<MapProps & import("react").RefAttributes<naver.maps.Map>>;
|
|
102
104
|
export default Map;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Map.d.ts","sourceRoot":"","sources":["../../src/components/Map.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,SAAS,EAIV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAI3D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCT,CAAC;AAEX,KAAK,QAAQ,GAAG,MAAM,OAAO,aAAa,CAAC;AAC3C,KAAK,OAAO,GAAG,CAAC,OAAO,aAAa,CAAC,CAA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,IAAI,QAAQ,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK;CACjE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEb,KAAK,aAAa,GAAG;KAClB,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;IACjC,cAAc,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACnD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,QAAA,MAAM,GAAG,qGA8KR,CAAC;AAIF,eAAe,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../src/components/Marker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../src/components/Marker.tsx"],"names":[],"mappings":"AASA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;CAkBT,CAAC;AAEX,KAAK,QAAQ,GAAG,MAAM,OAAO,aAAa,CAAC;AAC3C,KAAK,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,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;IACnD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,IAAI,eAAe,CAAC;KACrD,CAAC,IAAI,QAAQ,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK;CACjE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEb,KAAK,gBAAgB,GAAG;KACrB,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,KAAK,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAE7D,MAAM,WAAW,WAAY,SAAQ,eAAe,EAAE,gBAAgB;CAAG;AAEzE,QAAA,MAAM,MAAM,2GAmKX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -6,6 +6,6 @@ interface Props {
|
|
|
6
6
|
zIndex?: number;
|
|
7
7
|
anchor?: OverlayAnchorType;
|
|
8
8
|
}
|
|
9
|
-
declare const Overlay: ({ children,
|
|
9
|
+
declare const Overlay: ({ children, position, zIndex, anchor }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export default Overlay;
|
|
11
11
|
//# sourceMappingURL=Overlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Overlay.d.ts","sourceRoot":"","sources":["../../src/components/Overlay.tsx"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAiC,EAE/B,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,QAAA,MAAM,OAAO,GAAI,
|
|
1
|
+
{"version":3,"file":"Overlay.d.ts","sourceRoot":"","sources":["../../src/components/Overlay.tsx"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAiC,EAE/B,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,QAAA,MAAM,OAAO,GAAI,wCAAwC,KAAK,4CA+C7D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -95,12 +95,14 @@ interface MapProps extends MapEventProps {
|
|
|
95
95
|
ncpKeyId: string;
|
|
96
96
|
id?: string;
|
|
97
97
|
mapTypeId?: naver.maps.MapTypeId;
|
|
98
|
-
|
|
98
|
+
initialOptions?: Omit<naver.maps.MapOptions, "gl">;
|
|
99
99
|
children?: ReactNode;
|
|
100
100
|
submodules?: NaverMapsSubmodule[];
|
|
101
101
|
style?: React.CSSProperties;
|
|
102
102
|
disableGL?: boolean;
|
|
103
103
|
reuseMap?: boolean;
|
|
104
|
+
center?: naver.maps.MapOptions["center"];
|
|
105
|
+
zoom?: naver.maps.MapOptions["zoom"];
|
|
104
106
|
}
|
|
105
107
|
declare const Map: react.ForwardRefExoticComponent<MapProps & react.RefAttributes<naver.maps.Map>>;
|
|
106
108
|
|
|
@@ -173,7 +175,7 @@ interface Props {
|
|
|
173
175
|
zIndex?: number;
|
|
174
176
|
anchor?: OverlayAnchorType;
|
|
175
177
|
}
|
|
176
|
-
declare const Overlay: ({ children,
|
|
178
|
+
declare const Overlay: ({ children, position, zIndex, anchor }: Props) => react_jsx_runtime.JSX.Element;
|
|
177
179
|
|
|
178
180
|
declare const EVENT_TO_PROP$5: {
|
|
179
181
|
readonly click: "onClick";
|
|
@@ -393,13 +395,13 @@ type DataLayerEventProps = {
|
|
|
393
395
|
type DataLayerType = "gpx" | "kml" | "geojson";
|
|
394
396
|
interface DataLayerProps extends DataLayerEventProps {
|
|
395
397
|
type: DataLayerType;
|
|
396
|
-
|
|
398
|
+
data: string | naver.maps.GeoJSON | naver.maps.GPX | naver.maps.KML;
|
|
397
399
|
autoStyle?: boolean;
|
|
398
400
|
style?: naver.maps.StyleOptions | naver.maps.StylingFunction;
|
|
399
401
|
onLoad?: (layer: naver.maps.Data) => void;
|
|
400
402
|
onError?: (error: Error) => void;
|
|
401
403
|
}
|
|
402
|
-
declare const DataLayer: ({ type,
|
|
404
|
+
declare const DataLayer: ({ type, data, autoStyle, style, onLoad, onError, ...eventProps }: DataLayerProps) => null;
|
|
403
405
|
|
|
404
406
|
export { Circle, DataLayer, Ellipse, Map, MapProvider, Marker, Overlay, Polygon, Polyline, Rectangle, useMap };
|
|
405
407
|
export type { CircleProps, DataLayerProps, EllipseProps, MapProps, MarkerProps, PolylineProps, RectangleProps };
|
package/dist/index.esm.js
CHANGED
|
@@ -211,7 +211,7 @@ const EVENT_TO_PROP$7 = {
|
|
|
211
211
|
zoomend: "onZoomEnd",
|
|
212
212
|
zoomstart: "onZoomStart",
|
|
213
213
|
};
|
|
214
|
-
const Map = forwardRef(({ id, mapTypeId = "normal", ncpKeyId, children,
|
|
214
|
+
const Map = forwardRef(({ id, mapTypeId = "normal", ncpKeyId, children, initialOptions = {}, submodules = [], style, disableGL = false, reuseMap = false, center, zoom, ...eventProps }, ref) => {
|
|
215
215
|
const mountedMapContext = useContext(MountedMapContext);
|
|
216
216
|
const containerRef = useRef(null);
|
|
217
217
|
const [mapInstance, setMapInstance] = useState();
|
|
@@ -221,9 +221,6 @@ const Map = forwardRef(({ id, mapTypeId = "normal", ncpKeyId, children, mapOptio
|
|
|
221
221
|
submodules,
|
|
222
222
|
disableGL,
|
|
223
223
|
});
|
|
224
|
-
const keyedMapOptions = useMemo(() => {
|
|
225
|
-
return JSON.stringify(mapOptions) || "";
|
|
226
|
-
}, [mapOptions]);
|
|
227
224
|
useEffect(() => {
|
|
228
225
|
if (!isScriptLoaded || !containerRef.current)
|
|
229
226
|
return;
|
|
@@ -261,7 +258,7 @@ const Map = forwardRef(({ id, mapTypeId = "normal", ncpKeyId, children, mapOptio
|
|
|
261
258
|
};
|
|
262
259
|
}
|
|
263
260
|
const newInstance = new naver.maps.Map(containerRef.current, {
|
|
264
|
-
...
|
|
261
|
+
...initialOptions,
|
|
265
262
|
gl: !disableGL,
|
|
266
263
|
});
|
|
267
264
|
setMapInstance(newInstance);
|
|
@@ -309,11 +306,25 @@ const Map = forwardRef(({ id, mapTypeId = "normal", ncpKeyId, children, mapOptio
|
|
|
309
306
|
});
|
|
310
307
|
return () => disposers.forEach((d) => d());
|
|
311
308
|
}, [mapInstance]);
|
|
309
|
+
const prevCenterRef = useRef(undefined);
|
|
312
310
|
useEffect(() => {
|
|
313
|
-
if (!mapInstance)
|
|
311
|
+
if (!mapInstance || !center)
|
|
312
|
+
return;
|
|
313
|
+
const next = center instanceof naver.maps.LatLng
|
|
314
|
+
? center
|
|
315
|
+
: new naver.maps.LatLng(center);
|
|
316
|
+
if (!prevCenterRef.current?.equals(next)) {
|
|
317
|
+
mapInstance.setCenter(next);
|
|
318
|
+
prevCenterRef.current = next;
|
|
319
|
+
}
|
|
320
|
+
}, [mapInstance, center]);
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (!mapInstance || !zoom)
|
|
314
323
|
return;
|
|
315
|
-
|
|
316
|
-
|
|
324
|
+
if (zoom !== undefined) {
|
|
325
|
+
mapInstance.setZoom(zoom, true);
|
|
326
|
+
}
|
|
327
|
+
}, [mapInstance, zoom]);
|
|
317
328
|
useImperativeHandle(ref, () => contextValueRef.current, [mapInstance]);
|
|
318
329
|
const containerStyle = useMemo(() => {
|
|
319
330
|
return { width: "100%", height: "100%", ...style };
|
|
@@ -322,7 +333,6 @@ const Map = forwardRef(({ id, mapTypeId = "normal", ncpKeyId, children, mapOptio
|
|
|
322
333
|
});
|
|
323
334
|
Map.displayName = "Map";
|
|
324
335
|
|
|
325
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
326
336
|
const EVENT_TO_PROP$6 = {
|
|
327
337
|
click: "onClick",
|
|
328
338
|
position_changed: "onPositionChanged",
|
|
@@ -342,11 +352,10 @@ const EVENT_TO_PROP$6 = {
|
|
|
342
352
|
mouseover: "onMouseOver",
|
|
343
353
|
mouseout: "onMouseOut",
|
|
344
354
|
};
|
|
345
|
-
const Marker = forwardRef((props, ref) => {
|
|
355
|
+
const Marker = forwardRef(({ position, animation, clickable, zIndex, cursor, draggable, icon, shape, title, visible, ...props }, ref) => {
|
|
346
356
|
const { current: map } = useMap();
|
|
347
357
|
const [instance, setInstance] = useState();
|
|
348
358
|
const eventProps = {};
|
|
349
|
-
const options = {};
|
|
350
359
|
Object.keys(props).forEach((key) => {
|
|
351
360
|
const propKey = key;
|
|
352
361
|
if (Object.values(EVENT_TO_PROP$6).includes(propKey)) {
|
|
@@ -355,17 +364,22 @@ const Marker = forwardRef((props, ref) => {
|
|
|
355
364
|
eventProps[propKey] = value;
|
|
356
365
|
}
|
|
357
366
|
}
|
|
358
|
-
else {
|
|
359
|
-
const value = props[key];
|
|
360
|
-
if (value !== undefined) {
|
|
361
|
-
options[key] = value;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
367
|
});
|
|
365
368
|
useEffect(() => {
|
|
366
369
|
if (!map)
|
|
367
370
|
return undefined;
|
|
368
|
-
const newInstance = new naver.maps.Marker(
|
|
371
|
+
const newInstance = new naver.maps.Marker({
|
|
372
|
+
position,
|
|
373
|
+
animation,
|
|
374
|
+
clickable,
|
|
375
|
+
zIndex,
|
|
376
|
+
cursor,
|
|
377
|
+
draggable,
|
|
378
|
+
icon,
|
|
379
|
+
shape,
|
|
380
|
+
title,
|
|
381
|
+
visible,
|
|
382
|
+
});
|
|
369
383
|
setInstance(newInstance);
|
|
370
384
|
newInstance.setMap(map);
|
|
371
385
|
return () => {
|
|
@@ -374,76 +388,73 @@ const Marker = forwardRef((props, ref) => {
|
|
|
374
388
|
newInstance.setMap(null);
|
|
375
389
|
};
|
|
376
390
|
}, [map]);
|
|
391
|
+
const prevPositionRef = useRef(undefined);
|
|
377
392
|
useEffect(() => {
|
|
378
393
|
if (!instance)
|
|
379
394
|
return;
|
|
380
|
-
const position = options.position;
|
|
381
395
|
if (position) {
|
|
382
|
-
|
|
396
|
+
const next = position instanceof naver.maps.LatLng
|
|
397
|
+
? position
|
|
398
|
+
: new naver.maps.LatLng(position);
|
|
399
|
+
if (!prevPositionRef.current?.equals(next)) {
|
|
400
|
+
instance.setPosition(next);
|
|
401
|
+
prevPositionRef.current = next;
|
|
402
|
+
}
|
|
383
403
|
}
|
|
384
|
-
}, [instance,
|
|
404
|
+
}, [instance, position]);
|
|
385
405
|
useEffect(() => {
|
|
386
406
|
if (!instance)
|
|
387
407
|
return;
|
|
388
|
-
const animation = options.animation;
|
|
389
408
|
instance.setAnimation(animation ?? null);
|
|
390
|
-
}, [instance,
|
|
409
|
+
}, [instance, animation]);
|
|
391
410
|
useEffect(() => {
|
|
392
411
|
if (!instance)
|
|
393
412
|
return;
|
|
394
|
-
const clickable = options.clickable;
|
|
395
413
|
instance.setClickable(clickable ?? false);
|
|
396
|
-
}, [instance,
|
|
414
|
+
}, [instance, clickable]);
|
|
397
415
|
useEffect(() => {
|
|
398
416
|
if (!instance)
|
|
399
417
|
return;
|
|
400
|
-
const zIndex = options.zIndex;
|
|
401
418
|
if (zIndex !== undefined) {
|
|
402
419
|
instance.setZIndex(zIndex);
|
|
403
420
|
}
|
|
404
|
-
}, [instance,
|
|
421
|
+
}, [instance, zIndex]);
|
|
405
422
|
useEffect(() => {
|
|
406
423
|
if (!instance)
|
|
407
424
|
return;
|
|
408
|
-
const cursor = options.cursor;
|
|
409
425
|
instance.setCursor(cursor ?? "");
|
|
410
|
-
}, [instance,
|
|
426
|
+
}, [instance, cursor]);
|
|
411
427
|
useEffect(() => {
|
|
412
428
|
if (!instance)
|
|
413
429
|
return;
|
|
414
|
-
const draggable = options.draggable;
|
|
415
430
|
instance.setDraggable(draggable ?? false);
|
|
416
|
-
}, [instance,
|
|
431
|
+
}, [instance, draggable]);
|
|
417
432
|
useEffect(() => {
|
|
418
433
|
if (!instance)
|
|
419
434
|
return;
|
|
420
|
-
const icon = options.icon;
|
|
421
435
|
if (icon) {
|
|
422
436
|
instance.setIcon(icon);
|
|
423
437
|
}
|
|
424
|
-
}, [instance,
|
|
438
|
+
}, [instance, icon]);
|
|
425
439
|
useEffect(() => {
|
|
426
440
|
if (!instance)
|
|
427
441
|
return;
|
|
428
|
-
const shape = options.shape;
|
|
429
442
|
if (shape) {
|
|
430
443
|
instance.setShape(shape);
|
|
431
444
|
}
|
|
432
|
-
}, [instance,
|
|
445
|
+
}, [instance, shape]);
|
|
433
446
|
useEffect(() => {
|
|
434
447
|
if (!instance)
|
|
435
448
|
return;
|
|
436
|
-
const title = options.title;
|
|
437
449
|
if (title) {
|
|
438
450
|
instance.setTitle(title);
|
|
439
451
|
}
|
|
440
|
-
}, [instance,
|
|
452
|
+
}, [instance, title]);
|
|
441
453
|
useEffect(() => {
|
|
442
454
|
if (!instance)
|
|
443
455
|
return;
|
|
444
|
-
const visible = options.visible;
|
|
445
456
|
instance.setVisible(visible ?? true);
|
|
446
|
-
}, [instance,
|
|
457
|
+
}, [instance, visible]);
|
|
447
458
|
const handlersRef = useRef({});
|
|
448
459
|
useEffect(() => {
|
|
449
460
|
const next = {};
|
|
@@ -532,17 +543,18 @@ const createCustomOverlayClass = () => {
|
|
|
532
543
|
};
|
|
533
544
|
};
|
|
534
545
|
|
|
535
|
-
const Overlay = ({ children,
|
|
546
|
+
const Overlay = ({ children, position, zIndex, anchor }) => {
|
|
536
547
|
const { current: map } = useMap();
|
|
537
548
|
const containerRef = useRef(null);
|
|
538
549
|
const [instance, setInstance] = useState();
|
|
550
|
+
const prevPositionRef = useRef(undefined);
|
|
539
551
|
useEffect(() => {
|
|
540
552
|
if (!map || !containerRef.current)
|
|
541
553
|
return;
|
|
542
554
|
const CustomOverlay = createCustomOverlayClass();
|
|
543
555
|
const newInstance = new CustomOverlay({
|
|
544
556
|
element: containerRef.current,
|
|
545
|
-
|
|
557
|
+
position,
|
|
546
558
|
});
|
|
547
559
|
newInstance.setMap(map);
|
|
548
560
|
setInstance(newInstance);
|
|
@@ -553,18 +565,24 @@ const Overlay = ({ children, ...options }) => {
|
|
|
553
565
|
useEffect(() => {
|
|
554
566
|
if (!instance)
|
|
555
567
|
return;
|
|
556
|
-
|
|
557
|
-
|
|
568
|
+
const next = position instanceof naver.maps.LatLng
|
|
569
|
+
? position
|
|
570
|
+
: new naver.maps.LatLng(position);
|
|
571
|
+
if (!prevPositionRef.current?.equals(next)) {
|
|
572
|
+
instance.setPosition(next);
|
|
573
|
+
prevPositionRef.current = next;
|
|
574
|
+
}
|
|
575
|
+
}, [instance, position]);
|
|
558
576
|
useEffect(() => {
|
|
559
577
|
if (!instance)
|
|
560
578
|
return;
|
|
561
|
-
instance.setZIndex(
|
|
562
|
-
}, [instance,
|
|
579
|
+
instance.setZIndex(zIndex);
|
|
580
|
+
}, [instance, zIndex]);
|
|
563
581
|
useEffect(() => {
|
|
564
582
|
if (!instance)
|
|
565
583
|
return;
|
|
566
|
-
instance.setAnchor(
|
|
567
|
-
}, [instance,
|
|
584
|
+
instance.setAnchor(anchor);
|
|
585
|
+
}, [instance, anchor]);
|
|
568
586
|
return (jsx("div", { children: jsx("div", { ref: containerRef, children: children }) }));
|
|
569
587
|
};
|
|
570
588
|
|
|
@@ -964,9 +982,65 @@ const EVENT_TO_PROP = {
|
|
|
964
982
|
mouseout: "onMouseOut",
|
|
965
983
|
mousemove: "onMouseMove",
|
|
966
984
|
};
|
|
967
|
-
const
|
|
985
|
+
const isPlainObject = (value) => {
|
|
986
|
+
if (value === null || typeof value !== "object")
|
|
987
|
+
return false;
|
|
988
|
+
if (Array.isArray(value))
|
|
989
|
+
return false;
|
|
990
|
+
const proto = Object.getPrototypeOf(value);
|
|
991
|
+
return proto === Object.prototype || proto === null;
|
|
992
|
+
};
|
|
993
|
+
const isStyleEqual = (left, right, seen = new WeakMap()) => {
|
|
994
|
+
if (Object.is(left, right))
|
|
995
|
+
return true;
|
|
996
|
+
if (typeof left !== typeof right)
|
|
997
|
+
return false;
|
|
998
|
+
if (typeof left === "function")
|
|
999
|
+
return false;
|
|
1000
|
+
if (left === null || right === null)
|
|
1001
|
+
return false;
|
|
1002
|
+
if (Array.isArray(left)) {
|
|
1003
|
+
if (!Array.isArray(right))
|
|
1004
|
+
return false;
|
|
1005
|
+
if (left.length !== right.length)
|
|
1006
|
+
return false;
|
|
1007
|
+
for (let i = 0; i < left.length; i += 1) {
|
|
1008
|
+
if (!isStyleEqual(left[i], right[i], seen))
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
1011
|
+
return true;
|
|
1012
|
+
}
|
|
1013
|
+
if (isPlainObject(left)) {
|
|
1014
|
+
if (!isPlainObject(right))
|
|
1015
|
+
return false;
|
|
1016
|
+
const leftSeen = seen.get(left);
|
|
1017
|
+
if (leftSeen?.has(right))
|
|
1018
|
+
return true;
|
|
1019
|
+
if (leftSeen) {
|
|
1020
|
+
leftSeen.add(right);
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
seen.set(left, new WeakSet([right]));
|
|
1024
|
+
}
|
|
1025
|
+
const leftKeys = Object.keys(left);
|
|
1026
|
+
const rightKeys = Object.keys(right);
|
|
1027
|
+
if (leftKeys.length !== rightKeys.length)
|
|
1028
|
+
return false;
|
|
1029
|
+
for (const key of leftKeys) {
|
|
1030
|
+
if (!Object.prototype.hasOwnProperty.call(right, key))
|
|
1031
|
+
return false;
|
|
1032
|
+
if (!isStyleEqual(left[key], right[key], seen))
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
return false;
|
|
1038
|
+
};
|
|
1039
|
+
const DataLayer = ({ type, data, autoStyle = true, style, onLoad, onError, ...eventProps }) => {
|
|
968
1040
|
const { current: map } = useMap();
|
|
969
1041
|
const [layer, setLayer] = useState();
|
|
1042
|
+
const lastStyleRef = useRef();
|
|
1043
|
+
const lastLayerRef = useRef();
|
|
970
1044
|
const cleanUpFeatures = useMemo(() => {
|
|
971
1045
|
return (target) => {
|
|
972
1046
|
target.getAllFeature().forEach((feature) => {
|
|
@@ -992,27 +1066,27 @@ const DataLayer = ({ type, url, autoStyle = true, style, onLoad, onError, ...eve
|
|
|
992
1066
|
const load = async () => {
|
|
993
1067
|
try {
|
|
994
1068
|
cleanUpFeatures(layer);
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
if (type === "geojson") {
|
|
1000
|
-
const geojson = (await response.json());
|
|
1001
|
-
if (!controller.signal.aborted) {
|
|
1002
|
-
layer.addGeoJson(geojson, autoStyle);
|
|
1003
|
-
onLoad?.(layer);
|
|
1069
|
+
if (typeof data === "string") {
|
|
1070
|
+
const response = await fetch(data, { signal: controller.signal });
|
|
1071
|
+
if (!response.ok) {
|
|
1072
|
+
throw new Error(`Failed to fetch data layer: ${response.status}`);
|
|
1004
1073
|
}
|
|
1005
|
-
|
|
1074
|
+
if (type === "geojson") {
|
|
1075
|
+
const geojson = (await response.json());
|
|
1076
|
+
if (!controller.signal.aborted) {
|
|
1077
|
+
layer.addGeoJson(geojson, autoStyle);
|
|
1078
|
+
onLoad?.(layer);
|
|
1079
|
+
}
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const text = await response.text();
|
|
1083
|
+
const xml = new DOMParser().parseFromString(text, "text/xml");
|
|
1084
|
+
if (type === "gpx")
|
|
1085
|
+
layer.addGpx(xml, autoStyle);
|
|
1086
|
+
if (type === "kml")
|
|
1087
|
+
layer.addKml(xml, autoStyle);
|
|
1088
|
+
onLoad?.(layer);
|
|
1006
1089
|
}
|
|
1007
|
-
const text = await response.text();
|
|
1008
|
-
if (controller.signal.aborted)
|
|
1009
|
-
return;
|
|
1010
|
-
const xml = new DOMParser().parseFromString(text, "text/xml");
|
|
1011
|
-
if (type === "gpx")
|
|
1012
|
-
layer.addGpx(xml, autoStyle);
|
|
1013
|
-
if (type === "kml")
|
|
1014
|
-
layer.addKml(xml, autoStyle);
|
|
1015
|
-
onLoad?.(layer);
|
|
1016
1090
|
}
|
|
1017
1091
|
catch (error) {
|
|
1018
1092
|
if (controller.signal.aborted)
|
|
@@ -1022,11 +1096,18 @@ const DataLayer = ({ type, url, autoStyle = true, style, onLoad, onError, ...eve
|
|
|
1022
1096
|
};
|
|
1023
1097
|
load();
|
|
1024
1098
|
return () => controller.abort();
|
|
1025
|
-
}, [layer, type,
|
|
1099
|
+
}, [layer, type, data, autoStyle, cleanUpFeatures, onLoad, onError]);
|
|
1026
1100
|
useEffect(() => {
|
|
1027
1101
|
if (!layer || style === undefined)
|
|
1028
1102
|
return;
|
|
1103
|
+
if (lastLayerRef.current === layer &&
|
|
1104
|
+
lastStyleRef.current &&
|
|
1105
|
+
isStyleEqual(lastStyleRef.current, style)) {
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1029
1108
|
layer.setStyle(style);
|
|
1109
|
+
lastStyleRef.current = style;
|
|
1110
|
+
lastLayerRef.current = layer;
|
|
1030
1111
|
}, [layer, style]);
|
|
1031
1112
|
const handlersRef = useRef({});
|
|
1032
1113
|
useEffect(() => {
|