react-naver-maps-kit 1.0.0

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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -0
  3. package/dist/core/loader/loadNaverMapsScript.d.ts +13 -0
  4. package/dist/core/loader/loadNaverMapsScript.d.ts.map +1 -0
  5. package/dist/index.cjs +2646 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.ts +36 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +2631 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/overlays/circle/Circle.d.ts +79 -0
  12. package/dist/overlays/circle/Circle.d.ts.map +1 -0
  13. package/dist/overlays/ellipse/Ellipse.d.ts +74 -0
  14. package/dist/overlays/ellipse/Ellipse.d.ts.map +1 -0
  15. package/dist/overlays/ground-overlay/GroundOverlay.d.ts +46 -0
  16. package/dist/overlays/ground-overlay/GroundOverlay.d.ts.map +1 -0
  17. package/dist/overlays/infowindow/InfoWindow.d.ts +67 -0
  18. package/dist/overlays/infowindow/InfoWindow.d.ts.map +1 -0
  19. package/dist/overlays/marker/Marker.d.ts +81 -0
  20. package/dist/overlays/marker/Marker.d.ts.map +1 -0
  21. package/dist/overlays/polygon/Polygon.d.ts +78 -0
  22. package/dist/overlays/polygon/Polygon.d.ts.map +1 -0
  23. package/dist/overlays/polyline/Polyline.d.ts +79 -0
  24. package/dist/overlays/polyline/Polyline.d.ts.map +1 -0
  25. package/dist/overlays/rectangle/Rectangle.d.ts +74 -0
  26. package/dist/overlays/rectangle/Rectangle.d.ts.map +1 -0
  27. package/dist/overlays/shared/overlayUtils.d.ts +9 -0
  28. package/dist/overlays/shared/overlayUtils.d.ts.map +1 -0
  29. package/dist/react/components/NaverMap.d.ts +137 -0
  30. package/dist/react/components/NaverMap.d.ts.map +1 -0
  31. package/dist/react/components/NaverMap.test.d.ts +2 -0
  32. package/dist/react/components/NaverMap.test.d.ts.map +1 -0
  33. package/dist/react/hooks/useNaverMap.d.ts +10 -0
  34. package/dist/react/hooks/useNaverMap.d.ts.map +1 -0
  35. package/dist/react/provider/NaverMapProvider.d.ts +21 -0
  36. package/dist/react/provider/NaverMapProvider.d.ts.map +1 -0
  37. package/package.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cobocho
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,330 @@
1
+ # react-naver-maps-kit
2
+
3
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/react-naver-maps-kit.svg)](https://www.npmjs.com/package/react-naver-maps-kit)
5
+
6
+ 네이버 지도 SDK를 React에서 안전하고 직관적으로 사용할 수 있는 모던 툴킷입니다.
7
+
8
+ ## 특징
9
+
10
+ - **선언형 API**: React props로 지도와 오버레이를 선언형으로 제어
11
+ - **완전한 TypeScript 지원**: 네이버 지도 SDK 타입 정의 포함
12
+ - **안전한 생명주기 관리**: 지도 및 오버레이 생성/업데이트/정리 자동 처리
13
+ - **Context 기반 상태 관리**: SDK 로딩 상태, 에러, 지도 인스턴스를 컨텍스트로 관리
14
+ - **Custom React Hooks**: Provider 안전 가드가 포함된 편리한 훅 제공
15
+ - **오버레이 컴포넌트**: Marker, InfoWindow, Circle, Polygon 등 다양한 오버레이 지원
16
+
17
+ ## 설치
18
+
19
+ ```bash
20
+ # pnpm
21
+ pnpm add react-naver-maps-kit
22
+
23
+ # npm
24
+ npm install react-naver-maps-kit
25
+
26
+ # yarn
27
+ yarn add react-naver-maps-kit
28
+ ```
29
+
30
+ ### Peer Dependencies
31
+
32
+ - `react >= 18`
33
+ - `react-dom >= 18`
34
+
35
+ ## 빠른 시작
36
+
37
+ ### 1. API 키 발급
38
+
39
+ [네이버 클라우드 플랫폼](https://www.ncloud.com/)에서 Maps API 서비스를 신청하고 API 키를 발급받으세요.
40
+
41
+ ### 2. 기본 사용법
42
+
43
+ ```tsx
44
+ import { NaverMap, NaverMapProvider } from "react-naver-maps-kit";
45
+
46
+ function App() {
47
+ return (
48
+ <NaverMapProvider ncpKeyId={import.meta.env.VITE_NCP_KEY_ID}>
49
+ <NaverMap
50
+ center={{ lat: 37.3595704, lng: 127.105399 }}
51
+ zoom={10}
52
+ style={{ width: "100%", height: "400px" }}
53
+ />
54
+ </NaverMapProvider>
55
+ );
56
+ }
57
+ ```
58
+
59
+ ### 3. 마커 추가하기
60
+
61
+ ```tsx
62
+ import { NaverMap, NaverMapProvider, Marker } from "react-naver-maps-kit";
63
+
64
+ function MapWithMarker() {
65
+ return (
66
+ <NaverMapProvider ncpKeyId={import.meta.env.VITE_NCP_KEY_ID}>
67
+ <NaverMap
68
+ center={{ lat: 37.3595704, lng: 127.105399 }}
69
+ zoom={12}
70
+ style={{ width: "100%", height: "400px" }}
71
+ >
72
+ <Marker
73
+ position={{ lat: 37.3595704, lng: 127.105399 }}
74
+ title="네이버 그린팩토리"
75
+ onClick={(e) => console.log("Marker clicked!", e)}
76
+ />
77
+ </NaverMap>
78
+ </NaverMapProvider>
79
+ );
80
+ }
81
+ ```
82
+
83
+ ### 4. 커스텀 마커 (React 컴포넌트)
84
+
85
+ ```tsx
86
+ import { NaverMap, NaverMapProvider, Marker } from "react-naver-maps-kit";
87
+
88
+ function CustomMarker() {
89
+ return (
90
+ <Marker position={{ lat: 37.3595704, lng: 127.105399 }}>
91
+ <div
92
+ style={{
93
+ padding: "8px 16px",
94
+ background: "#03C75A",
95
+ color: "white",
96
+ borderRadius: "20px",
97
+ fontWeight: "bold",
98
+ whiteSpace: "nowrap"
99
+ }}
100
+ >
101
+ 네이버
102
+ </div>
103
+ </Marker>
104
+ );
105
+ }
106
+ ```
107
+
108
+ ## API 개요
109
+
110
+ ### Provider
111
+
112
+ #### `NaverMapProvider`
113
+
114
+ SDK 로딩과 상태를 관리하는 최상위 컴포넌트입니다.
115
+
116
+ ```tsx
117
+ interface NaverMapProviderProps {
118
+ children: ReactNode;
119
+ ncpKeyId?: string; // 권장: NCP API Key ID
120
+ ncpClientId?: string; // 레거시: NCP Client ID
121
+ govClientId?: string; // 공공기관용 Client ID
122
+ finClientId?: string; // 금융기관용 Client ID
123
+ submodules?: Array<"geocoder" | "panorama" | "drawing" | "visualization">;
124
+ timeoutMs?: number; // 로딩 타임아웃 (기본: 10000ms)
125
+ nonce?: string; // CSP nonce
126
+ autoLoad?: boolean; // 자동 로딩 (기본: true)
127
+ onReady?: () => void; // SDK 로딩 완료 콜백
128
+ onError?: (error: Error) => void; // 에러 콜백
129
+ }
130
+ ```
131
+
132
+ ### Components
133
+
134
+ #### `NaverMap`
135
+
136
+ 지도를 렌더링하는 메인 컴포넌트입니다.
137
+
138
+ ```tsx
139
+ interface NaverMapProps {
140
+ // 지도 옵션
141
+ center?: naver.maps.Coord | naver.maps.CoordLiteral;
142
+ defaultCenter?: naver.maps.Coord | naver.maps.CoordLiteral;
143
+ zoom?: number;
144
+ defaultZoom?: number;
145
+ mapTypeId?: string;
146
+ minZoom?: number;
147
+ maxZoom?: number;
148
+ bounds?: naver.maps.Bounds | naver.maps.BoundsLiteral;
149
+ maxBounds?: naver.maps.Bounds | naver.maps.BoundsLiteral;
150
+
151
+ // 컨트롤 옵션
152
+ zoomControl?: boolean;
153
+ zoomControlOptions?: naver.maps.ZoomControlOptions;
154
+ mapTypeControl?: boolean;
155
+ mapTypeControlOptions?: naver.maps.MapTypeControlOptions;
156
+ scaleControl?: boolean;
157
+ logoControl?: boolean;
158
+
159
+ // 인터랙션 옵션
160
+ draggable?: boolean;
161
+ scrollWheel?: boolean;
162
+ keyboardShortcuts?: boolean;
163
+ disableDoubleClickZoom?: boolean;
164
+ pinchZoom?: boolean;
165
+
166
+ // 생명주기 콜백
167
+ onMapReady?: (map: naver.maps.Map) => void;
168
+ onMapDestroy?: () => void;
169
+ onMapError?: (error: Error) => void;
170
+
171
+ // 이벤트 핸들러
172
+ onClick?: (pointerEvent: naver.maps.PointerEvent) => void;
173
+ onCenterChanged?: (center: naver.maps.Coord) => void;
174
+ onZoomChanged?: (zoom: number) => void;
175
+ onBoundsChanged?: (bounds: naver.maps.Bounds) => void;
176
+ // ... 더 많은 이벤트 지원
177
+ }
178
+ ```
179
+
180
+ #### Overlay Components
181
+
182
+ 모든 오버레이 컴포넌트는 `NaverMap` 내부에서 사용해야 합니다.
183
+
184
+ | 컴포넌트 | 설명 |
185
+ | --------------- | ---------------------- |
186
+ | `Marker` | 지도 위 마커 표시 |
187
+ | `InfoWindow` | 정보 창 표시 |
188
+ | `Circle` | 원형 오버레이 |
189
+ | `Ellipse` | 타원형 오버레이 |
190
+ | `Rectangle` | 사각형 오버레이 |
191
+ | `Polygon` | 다각형 오버레이 |
192
+ | `Polyline` | 선형 오버레이 |
193
+ | `GroundOverlay` | 지상 오버레이 (이미지) |
194
+
195
+ ```tsx
196
+ // 오버레이 예시
197
+ <NaverMap center={{ lat: 37.5665, lng: 126.978 }} zoom={12}>
198
+ <Marker position={{ lat: 37.5665, lng: 126.978 }} />
199
+ <Circle
200
+ center={{ lat: 37.5665, lng: 126.978 }}
201
+ radius={1000}
202
+ strokeColor="#03C75A"
203
+ fillColor="#03C75A"
204
+ fillOpacity={0.3}
205
+ />
206
+ <Polygon
207
+ paths={[
208
+ { lat: 37.56, lng: 126.97 },
209
+ { lat: 37.57, lng: 126.98 },
210
+ { lat: 37.58, lng: 126.97 }
211
+ ]}
212
+ fillColor="#FF0000"
213
+ />
214
+ </NaverMap>
215
+ ```
216
+
217
+ ### Hooks
218
+
219
+ #### `useNaverMap`
220
+
221
+ Provider 컨텍스트에 접근하기 위한 훅입니다.
222
+
223
+ ```tsx
224
+ import { useNaverMap } from "react-naver-maps-kit";
225
+
226
+ function MyComponent() {
227
+ const { sdkStatus, sdkError, map, reloadSdk } = useNaverMap();
228
+
229
+ if (sdkStatus === "loading") return <div>로딩 중...</div>;
230
+ if (sdkStatus === "error") return <div>에러: {sdkError?.message}</div>;
231
+
232
+ return <div>지도 준비 완료!</div>;
233
+ }
234
+ ```
235
+
236
+ #### `useNaverMapInstance`
237
+
238
+ 지도 인스턴스에 직접 접근하기 위한 훅입니다.
239
+
240
+ ```tsx
241
+ import { useNaverMapInstance } from "react-naver-maps-kit";
242
+
243
+ function MapController() {
244
+ const map = useNaverMapInstance();
245
+
246
+ const handlePanTo = () => {
247
+ map?.panTo(new naver.maps.LatLng(37.5665, 126.978));
248
+ };
249
+
250
+ return <button onClick={handlePanTo}>서울시청으로 이동</button>;
251
+ }
252
+ ```
253
+
254
+ ### Utilities
255
+
256
+ #### `loadNaverMapsScript`
257
+
258
+ SDK를 수동으로 로딩하기 위한 유틸리티 함수입니다.
259
+
260
+ ```tsx
261
+ import { loadNaverMapsScript } from "react-naver-maps-kit";
262
+
263
+ // 수동 로딩
264
+ await loadNaverMapsScript({
265
+ ncpKeyId: "YOUR_KEY",
266
+ submodules: ["geocoder"],
267
+ timeoutMs: 15000
268
+ });
269
+ ```
270
+
271
+ ## Ref API
272
+
273
+ 모든 컴포넌트는 `ref`를 통해 네이버 지도 SDK 인스턴스 메서드에 접근할 수 있습니다.
274
+
275
+ ```tsx
276
+ import { useRef } from "react";
277
+ import { NaverMap, Marker, type NaverMapRef, type MarkerRef } from "react-naver-maps-kit";
278
+
279
+ function MapWithRef() {
280
+ const mapRef = useRef<NaverMapRef>(null);
281
+ const markerRef = useRef<MarkerRef>(null);
282
+
283
+ const handleGetCenter = () => {
284
+ const center = mapRef.current?.getCenter();
285
+ console.log("Center:", center);
286
+ };
287
+
288
+ const handleMoveMarker = () => {
289
+ markerRef.current?.setPosition({ lat: 37.5, lng: 127.0 });
290
+ };
291
+
292
+ return (
293
+ <NaverMap ref={mapRef} center={{ lat: 37.3595704, lng: 127.105399 }} zoom={10}>
294
+ <Marker ref={markerRef} position={{ lat: 37.3595704, lng: 127.105399 }} />
295
+ </NaverMap>
296
+ );
297
+ }
298
+ ```
299
+
300
+ ## Controlled vs Uncontrolled
301
+
302
+ `center`/`defaultCenter`, `zoom`/`defaultZoom`을 통해 제어 모드를 선택할 수 있습니다.
303
+
304
+ ```tsx
305
+ // Controlled: React 상태로 관리
306
+ <NaverMap
307
+ center={center}
308
+ zoom={zoom}
309
+ onCenterChanged={setCenter}
310
+ onZoomChanged={setZoom}
311
+ />
312
+
313
+ // Uncontrolled: 내부 상태로 관리
314
+ <NaverMap
315
+ defaultCenter={{ lat: 37.3595704, lng: 127.105399 }}
316
+ defaultZoom={10}
317
+ />
318
+ ```
319
+
320
+ ## 문서
321
+
322
+ - [시작하기](/docs/guide/getting-started.md)
323
+ - [Provider & Hook](/docs/guide/provider-map-hook.md)
324
+ - [지도 통합](/docs/guide/integration-map.md)
325
+ - [오버레이 통합](/docs/guide/integration-overlay.md)
326
+ - [문제 해결](/docs/troubleshooting/common-issues.md)
327
+
328
+ ## 라이선스
329
+
330
+ MIT License
@@ -0,0 +1,13 @@
1
+ type Submodule = "geocoder" | "panorama" | "drawing" | "visualization";
2
+ export interface LoadNaverMapsScriptOptions {
3
+ ncpKeyId?: string;
4
+ ncpClientId?: string;
5
+ govClientId?: string;
6
+ finClientId?: string;
7
+ submodules?: Array<Submodule>;
8
+ timeoutMs?: number;
9
+ nonce?: string;
10
+ }
11
+ export declare function loadNaverMapsScript(options: LoadNaverMapsScriptOptions): Promise<void>;
12
+ export {};
13
+ //# sourceMappingURL=loadNaverMapsScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadNaverMapsScript.d.ts","sourceRoot":"","sources":["../../../src/core/loader/loadNaverMapsScript.ts"],"names":[],"mappings":"AAIA,KAAK,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;AAEvE,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAmGD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAyItF"}