kor-mapi 0.1.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.
- package/LICENSE +21 -0
- package/README.eng.md +124 -0
- package/README.md +126 -0
- package/dist/chunk-222QLGRB.js +1884 -0
- package/dist/chunk-222QLGRB.js.map +1 -0
- package/dist/chunk-HUS54ONW.js +17 -0
- package/dist/chunk-HUS54ONW.js.map +1 -0
- package/dist/core.d.ts +206 -0
- package/dist/core.js +4 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +232 -0
- package/dist/index.js.map +1 -0
- package/dist/types-BWnSkE6e.d.ts +221 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,1884 @@
|
|
|
1
|
+
// src/providers/base/HandleRegistry.ts
|
|
2
|
+
var HandleRegistry = class {
|
|
3
|
+
map = /* @__PURE__ */ new Map();
|
|
4
|
+
counter = 0;
|
|
5
|
+
register(value) {
|
|
6
|
+
const id = ++this.counter;
|
|
7
|
+
this.map.set(id, value);
|
|
8
|
+
return id;
|
|
9
|
+
}
|
|
10
|
+
get(id) {
|
|
11
|
+
const value = this.map.get(id);
|
|
12
|
+
if (value === void 0) throw new Error(`Handle ${id} not found in registry`);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
delete(id) {
|
|
16
|
+
this.map.delete(id);
|
|
17
|
+
}
|
|
18
|
+
has(id) {
|
|
19
|
+
return this.map.has(id);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var eventListenerCounter = 0;
|
|
23
|
+
function makeEventListener(type) {
|
|
24
|
+
return { _type: type, _id: ++eventListenerCounter };
|
|
25
|
+
}
|
|
26
|
+
function makeHandle(id) {
|
|
27
|
+
return { _handleId: id };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/core/errors.ts
|
|
31
|
+
var KorMapError = class extends Error {
|
|
32
|
+
provider;
|
|
33
|
+
originalError;
|
|
34
|
+
constructor(message, options) {
|
|
35
|
+
super(message, { cause: options?.cause });
|
|
36
|
+
this.name = "KorMapError";
|
|
37
|
+
this.provider = options?.provider;
|
|
38
|
+
this.originalError = options?.cause;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var ProviderLoadError = class extends KorMapError {
|
|
42
|
+
constructor(provider, cause) {
|
|
43
|
+
super(`Failed to load ${provider} Maps SDK`, { provider, cause });
|
|
44
|
+
this.name = "ProviderLoadError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var ProviderNotSupportedError = class extends KorMapError {
|
|
48
|
+
feature;
|
|
49
|
+
constructor(provider, feature) {
|
|
50
|
+
super(`Feature "${feature}" is not supported by provider "${provider}"`, { provider });
|
|
51
|
+
this.name = "ProviderNotSupportedError";
|
|
52
|
+
this.feature = feature;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var ConfigurationError = class extends KorMapError {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = "ConfigurationError";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/providers/kakao/KakaoLoader.ts
|
|
63
|
+
var loadPromise = null;
|
|
64
|
+
function loadKakaoSdk(appKey) {
|
|
65
|
+
if (loadPromise) return loadPromise;
|
|
66
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
67
|
+
if (typeof window !== "undefined" && window.kakao?.maps?.Map) {
|
|
68
|
+
resolve();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const script = document.createElement("script");
|
|
72
|
+
script.type = "text/javascript";
|
|
73
|
+
script.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${encodeURIComponent(appKey)}&autoload=false`;
|
|
74
|
+
script.onload = () => {
|
|
75
|
+
window.kakao.maps.load(() => resolve());
|
|
76
|
+
};
|
|
77
|
+
script.onerror = () => {
|
|
78
|
+
loadPromise = null;
|
|
79
|
+
reject(new ProviderLoadError("kakao", new Error("Kakao Maps SDK script failed to load")));
|
|
80
|
+
};
|
|
81
|
+
document.head.appendChild(script);
|
|
82
|
+
});
|
|
83
|
+
return loadPromise;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/utils/coordinateUtils.ts
|
|
87
|
+
var FACADE_MIN = 7;
|
|
88
|
+
var FACADE_MAX = 19;
|
|
89
|
+
var KAKAO_MIN = 1;
|
|
90
|
+
var KAKAO_MAX = 13;
|
|
91
|
+
var KAKAO_OFFSET = 20;
|
|
92
|
+
function clampFacadeZoom(zoom) {
|
|
93
|
+
return Math.max(FACADE_MIN, Math.min(FACADE_MAX, zoom));
|
|
94
|
+
}
|
|
95
|
+
function toGoogleZoom(facadeZoom) {
|
|
96
|
+
return clampFacadeZoom(facadeZoom);
|
|
97
|
+
}
|
|
98
|
+
function fromGoogleZoom(googleZoom) {
|
|
99
|
+
return clampFacadeZoom(googleZoom);
|
|
100
|
+
}
|
|
101
|
+
function toNaverZoom(facadeZoom) {
|
|
102
|
+
return Math.round(clampFacadeZoom(facadeZoom));
|
|
103
|
+
}
|
|
104
|
+
function fromNaverZoom(naverZoom) {
|
|
105
|
+
return Math.round(clampFacadeZoom(naverZoom));
|
|
106
|
+
}
|
|
107
|
+
function toKakaoZoom(facadeZoom) {
|
|
108
|
+
const clamped = clampFacadeZoom(facadeZoom);
|
|
109
|
+
return Math.max(KAKAO_MIN, Math.min(KAKAO_MAX, Math.round(KAKAO_OFFSET - clamped)));
|
|
110
|
+
}
|
|
111
|
+
function fromKakaoZoom(kakaoZoom) {
|
|
112
|
+
const clamped = Math.max(KAKAO_MIN, Math.min(KAKAO_MAX, Math.round(kakaoZoom)));
|
|
113
|
+
return Math.round(clampFacadeZoom(KAKAO_OFFSET - clamped));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/providers/kakao/KakaoAdapter.ts
|
|
117
|
+
function toKakaoMapType(type) {
|
|
118
|
+
switch (type) {
|
|
119
|
+
case "satellite" /* SATELLITE */:
|
|
120
|
+
return kakao.maps.MapTypeId.SKYVIEW;
|
|
121
|
+
case "hybrid" /* HYBRID */:
|
|
122
|
+
return kakao.maps.MapTypeId.HYBRID;
|
|
123
|
+
// Kakao TERRAIN is an overlay type, not a standalone base map — use ROADMAP
|
|
124
|
+
default:
|
|
125
|
+
return kakao.maps.MapTypeId.ROADMAP;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function fromKakaoMapType(typeId) {
|
|
129
|
+
if (typeId === kakao.maps.MapTypeId.SKYVIEW) return "satellite" /* SATELLITE */;
|
|
130
|
+
if (typeId === kakao.maps.MapTypeId.HYBRID) return "hybrid" /* HYBRID */;
|
|
131
|
+
if (typeId === kakao.maps.MapTypeId.TERRAIN) return "terrain" /* TERRAIN */;
|
|
132
|
+
return "roadmap" /* ROADMAP */;
|
|
133
|
+
}
|
|
134
|
+
var FACADE_TO_KAKAO_EVENT = {
|
|
135
|
+
click: "click",
|
|
136
|
+
dblclick: "dblclick",
|
|
137
|
+
rightclick: "rightclick",
|
|
138
|
+
mousemove: "mousemove",
|
|
139
|
+
drag: "drag",
|
|
140
|
+
dragstart: "dragstart",
|
|
141
|
+
dragend: "dragend",
|
|
142
|
+
zoom_changed: "zoom_changed",
|
|
143
|
+
center_changed: "center_changed",
|
|
144
|
+
bounds_changed: "bounds_changed",
|
|
145
|
+
tilesloaded: "tilesloaded"
|
|
146
|
+
// 'idle' is synthesized below — not in this map
|
|
147
|
+
};
|
|
148
|
+
var SUPPORTED_FEATURES = [];
|
|
149
|
+
var POINTER_EVENTS = /* @__PURE__ */ new Set(["click", "dblclick", "rightclick"]);
|
|
150
|
+
var KakaoAdapter = class {
|
|
151
|
+
provider = "kakao";
|
|
152
|
+
map;
|
|
153
|
+
markerReg = new HandleRegistry();
|
|
154
|
+
overlayReg = new HandleRegistry();
|
|
155
|
+
infoWindowReg = new HandleRegistry();
|
|
156
|
+
// Listener bookkeeping: handle id → [ { event, nativeHandler } ]
|
|
157
|
+
markerListeners = /* @__PURE__ */ new Map();
|
|
158
|
+
// idle synthesis: debounce timer
|
|
159
|
+
idleTimer = null;
|
|
160
|
+
idleHandlers = [];
|
|
161
|
+
get nativeMap() {
|
|
162
|
+
return this.map;
|
|
163
|
+
}
|
|
164
|
+
async init(container, config) {
|
|
165
|
+
const appKey = resolveAppKey(config.apiKey);
|
|
166
|
+
await loadKakaoSdk(appKey);
|
|
167
|
+
const center = config.center ?? { lat: 37.5665, lng: 126.978 };
|
|
168
|
+
const zoom = config.zoom ?? 10;
|
|
169
|
+
this.map = new kakao.maps.Map(container, {
|
|
170
|
+
center: new kakao.maps.LatLng(center.lat, center.lng),
|
|
171
|
+
level: toKakaoZoom(zoom),
|
|
172
|
+
minLevel: 1,
|
|
173
|
+
maxLevel: 13,
|
|
174
|
+
...config.mapType && { mapTypeId: toKakaoMapType(config.mapType) }
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
destroy() {
|
|
178
|
+
if (this.map) ;
|
|
179
|
+
}
|
|
180
|
+
// -------------------------------------------------------------------------
|
|
181
|
+
// Camera
|
|
182
|
+
// -------------------------------------------------------------------------
|
|
183
|
+
setCenter(latlng) {
|
|
184
|
+
this.map.setCenter(new kakao.maps.LatLng(latlng.lat, latlng.lng));
|
|
185
|
+
}
|
|
186
|
+
getCenter() {
|
|
187
|
+
const c = this.map.getCenter();
|
|
188
|
+
return { lat: c.getLat(), lng: c.getLng() };
|
|
189
|
+
}
|
|
190
|
+
setZoom(zoom) {
|
|
191
|
+
const level = toKakaoZoom(zoom);
|
|
192
|
+
if (level !== this.map.getLevel()) {
|
|
193
|
+
this.map.setLevel(level);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
getZoom() {
|
|
197
|
+
return fromKakaoZoom(this.map.getLevel());
|
|
198
|
+
}
|
|
199
|
+
getBounds() {
|
|
200
|
+
const b = this.map.getBounds();
|
|
201
|
+
const sw = b.getSouthWest();
|
|
202
|
+
const ne = b.getNorthEast();
|
|
203
|
+
return {
|
|
204
|
+
sw: { lat: sw.getLat(), lng: sw.getLng() },
|
|
205
|
+
ne: { lat: ne.getLat(), lng: ne.getLng() }
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
fitBounds(bounds, options) {
|
|
209
|
+
const kb = new kakao.maps.LatLngBounds(
|
|
210
|
+
new kakao.maps.LatLng(bounds.sw.lat, bounds.sw.lng),
|
|
211
|
+
new kakao.maps.LatLng(bounds.ne.lat, bounds.ne.lng)
|
|
212
|
+
);
|
|
213
|
+
const p = normalizePadding(options?.padding);
|
|
214
|
+
this.map.setBounds(kb, p.top, p.right, p.bottom, p.left);
|
|
215
|
+
}
|
|
216
|
+
panTo(latlng, _options) {
|
|
217
|
+
this.map.panTo(new kakao.maps.LatLng(latlng.lat, latlng.lng));
|
|
218
|
+
}
|
|
219
|
+
panBy(x, y) {
|
|
220
|
+
this.map.panBy(x, y);
|
|
221
|
+
}
|
|
222
|
+
// -------------------------------------------------------------------------
|
|
223
|
+
// Map type
|
|
224
|
+
// -------------------------------------------------------------------------
|
|
225
|
+
setMapType(type) {
|
|
226
|
+
const level = this.map.getLevel();
|
|
227
|
+
this.map.setMapTypeId(toKakaoMapType(type));
|
|
228
|
+
if (this.map.getLevel() !== level) this.map.setLevel(level);
|
|
229
|
+
}
|
|
230
|
+
getMapType() {
|
|
231
|
+
const raw = this.map.getMapTypeId();
|
|
232
|
+
return fromKakaoMapType(raw);
|
|
233
|
+
}
|
|
234
|
+
// -------------------------------------------------------------------------
|
|
235
|
+
// Capability
|
|
236
|
+
// -------------------------------------------------------------------------
|
|
237
|
+
supports(feature) {
|
|
238
|
+
return SUPPORTED_FEATURES.includes(feature);
|
|
239
|
+
}
|
|
240
|
+
// -------------------------------------------------------------------------
|
|
241
|
+
// Events
|
|
242
|
+
// -------------------------------------------------------------------------
|
|
243
|
+
on(event, handler) {
|
|
244
|
+
const listener = makeEventListener(event);
|
|
245
|
+
if (event === "idle") {
|
|
246
|
+
this.idleHandlers.push(handler);
|
|
247
|
+
this._ensureIdleSynthesis();
|
|
248
|
+
} else {
|
|
249
|
+
const kakaoEvent = FACADE_TO_KAKAO_EVENT[event];
|
|
250
|
+
if (kakaoEvent) {
|
|
251
|
+
const wrapped = POINTER_EVENTS.has(event) ? (e) => handler({ latlng: { lat: e.latLng.getLat(), lng: e.latLng.getLng() } }) : handler;
|
|
252
|
+
kakao.maps.event.addListener(this.map, kakaoEvent, wrapped);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return listener;
|
|
256
|
+
}
|
|
257
|
+
once(event, handler) {
|
|
258
|
+
const wrapper = (...args) => {
|
|
259
|
+
this.off(event, listener);
|
|
260
|
+
handler(...args);
|
|
261
|
+
};
|
|
262
|
+
const listener = this.on(event, wrapper);
|
|
263
|
+
return listener;
|
|
264
|
+
}
|
|
265
|
+
off(event, _listener) {
|
|
266
|
+
if (event === "idle") {
|
|
267
|
+
this.idleHandlers.length = 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
_ensureIdleSynthesis() {
|
|
271
|
+
const synthesize = () => {
|
|
272
|
+
if (this.idleTimer !== null) clearTimeout(this.idleTimer);
|
|
273
|
+
this.idleTimer = setTimeout(() => {
|
|
274
|
+
for (const h of this.idleHandlers) h();
|
|
275
|
+
}, 150);
|
|
276
|
+
};
|
|
277
|
+
kakao.maps.event.addListener(this.map, "center_changed", synthesize);
|
|
278
|
+
kakao.maps.event.addListener(this.map, "zoom_changed", synthesize);
|
|
279
|
+
}
|
|
280
|
+
// -------------------------------------------------------------------------
|
|
281
|
+
// Markers
|
|
282
|
+
// -------------------------------------------------------------------------
|
|
283
|
+
addMarker(options) {
|
|
284
|
+
const kakaoOptions = {
|
|
285
|
+
map: this.map,
|
|
286
|
+
position: new kakao.maps.LatLng(options.position.lat, options.position.lng),
|
|
287
|
+
title: options.title,
|
|
288
|
+
draggable: options.draggable,
|
|
289
|
+
clickable: options.clickable,
|
|
290
|
+
zIndex: options.zIndex,
|
|
291
|
+
opacity: options.opacity
|
|
292
|
+
};
|
|
293
|
+
if (options.icon) {
|
|
294
|
+
kakaoOptions.image = buildMarkerImage(options.icon);
|
|
295
|
+
}
|
|
296
|
+
const marker = new kakao.maps.Marker(kakaoOptions);
|
|
297
|
+
if (options.visible === false) marker.setVisible(false);
|
|
298
|
+
if (options.label) {
|
|
299
|
+
this._addLabelOverlay(marker, options.label.text, options.label);
|
|
300
|
+
}
|
|
301
|
+
const id = this.markerReg.register(marker);
|
|
302
|
+
this.markerListeners.set(id, []);
|
|
303
|
+
return makeHandle(id);
|
|
304
|
+
}
|
|
305
|
+
removeMarker(handle) {
|
|
306
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
307
|
+
marker.setMap(null);
|
|
308
|
+
this.markerReg.delete(handle._handleId);
|
|
309
|
+
this.markerListeners.delete(handle._handleId);
|
|
310
|
+
}
|
|
311
|
+
updateMarker(handle, options) {
|
|
312
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
313
|
+
if (options.position) marker.setPosition(new kakao.maps.LatLng(options.position.lat, options.position.lng));
|
|
314
|
+
if (options.icon !== void 0) marker.setImage(buildMarkerImage(options.icon));
|
|
315
|
+
if (options.title !== void 0) marker.setTitle(options.title);
|
|
316
|
+
if (options.draggable !== void 0) marker.setDraggable(options.draggable);
|
|
317
|
+
if (options.clickable !== void 0) marker.setClickable(options.clickable);
|
|
318
|
+
if (options.zIndex !== void 0) marker.setZIndex(options.zIndex);
|
|
319
|
+
if (options.opacity !== void 0) marker.setOpacity(options.opacity);
|
|
320
|
+
if (options.visible !== void 0) marker.setVisible(options.visible);
|
|
321
|
+
}
|
|
322
|
+
addMarkerEvent(handle, event, handler) {
|
|
323
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
324
|
+
kakao.maps.event.addListener(marker, event, handler);
|
|
325
|
+
const listener = makeEventListener(event);
|
|
326
|
+
return listener;
|
|
327
|
+
}
|
|
328
|
+
removeMarkerEvent(handle, event, _listener) {
|
|
329
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
330
|
+
kakao.maps.event.removeListener(marker, event, () => void 0);
|
|
331
|
+
}
|
|
332
|
+
// -------------------------------------------------------------------------
|
|
333
|
+
// InfoWindow
|
|
334
|
+
// -------------------------------------------------------------------------
|
|
335
|
+
openInfoWindow(options, anchor) {
|
|
336
|
+
const iw = new kakao.maps.InfoWindow({
|
|
337
|
+
content: options.content,
|
|
338
|
+
position: options.position ? new kakao.maps.LatLng(options.position.lat, options.position.lng) : void 0,
|
|
339
|
+
zIndex: options.zIndex,
|
|
340
|
+
removable: false
|
|
341
|
+
});
|
|
342
|
+
const marker = anchor ? this.markerReg.get(anchor._handleId) : void 0;
|
|
343
|
+
iw.open(this.map, marker);
|
|
344
|
+
const id = this.infoWindowReg.register(iw);
|
|
345
|
+
return makeHandle(id);
|
|
346
|
+
}
|
|
347
|
+
closeInfoWindow(handle) {
|
|
348
|
+
this.infoWindowReg.get(handle._handleId).close();
|
|
349
|
+
}
|
|
350
|
+
updateInfoWindow(handle, options) {
|
|
351
|
+
const iw = this.infoWindowReg.get(handle._handleId);
|
|
352
|
+
if (options.content !== void 0) iw.setContent(options.content);
|
|
353
|
+
if (options.position) iw.setPosition(new kakao.maps.LatLng(options.position.lat, options.position.lng));
|
|
354
|
+
if (options.zIndex !== void 0) iw.setZIndex(options.zIndex);
|
|
355
|
+
}
|
|
356
|
+
isInfoWindowOpen(_handle) {
|
|
357
|
+
return this.infoWindowReg.has(_handle._handleId);
|
|
358
|
+
}
|
|
359
|
+
// -------------------------------------------------------------------------
|
|
360
|
+
// Vector overlays
|
|
361
|
+
// -------------------------------------------------------------------------
|
|
362
|
+
addPolyline(options) {
|
|
363
|
+
const polyline = new kakao.maps.Polyline({
|
|
364
|
+
map: this.map,
|
|
365
|
+
path: toKakaoPath(options.path),
|
|
366
|
+
strokeWeight: options.strokeWeight,
|
|
367
|
+
strokeColor: options.strokeColor,
|
|
368
|
+
strokeOpacity: options.strokeOpacity,
|
|
369
|
+
strokeStyle: options.strokeStyle,
|
|
370
|
+
zIndex: options.zIndex
|
|
371
|
+
});
|
|
372
|
+
return makeHandle(this.overlayReg.register(polyline));
|
|
373
|
+
}
|
|
374
|
+
removePolyline(handle) {
|
|
375
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
376
|
+
this.overlayReg.delete(handle._handleId);
|
|
377
|
+
}
|
|
378
|
+
updatePolyline(handle, options) {
|
|
379
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
380
|
+
strokeWeight: options.strokeWeight,
|
|
381
|
+
strokeColor: options.strokeColor,
|
|
382
|
+
strokeOpacity: options.strokeOpacity
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
addPolygon(options) {
|
|
386
|
+
const polygon = new kakao.maps.Polygon({
|
|
387
|
+
map: this.map,
|
|
388
|
+
path: toKakaoPath(options.paths),
|
|
389
|
+
strokeWeight: options.strokeWeight,
|
|
390
|
+
strokeColor: options.strokeColor,
|
|
391
|
+
strokeOpacity: options.strokeOpacity,
|
|
392
|
+
fillColor: options.fillColor,
|
|
393
|
+
fillOpacity: options.fillOpacity,
|
|
394
|
+
zIndex: options.zIndex
|
|
395
|
+
});
|
|
396
|
+
return makeHandle(this.overlayReg.register(polygon));
|
|
397
|
+
}
|
|
398
|
+
removePolygon(handle) {
|
|
399
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
400
|
+
this.overlayReg.delete(handle._handleId);
|
|
401
|
+
}
|
|
402
|
+
updatePolygon(handle, options) {
|
|
403
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
404
|
+
strokeColor: options.strokeColor,
|
|
405
|
+
fillColor: options.fillColor,
|
|
406
|
+
fillOpacity: options.fillOpacity
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
addCircle(options) {
|
|
410
|
+
const circle = new kakao.maps.Circle({
|
|
411
|
+
map: this.map,
|
|
412
|
+
center: new kakao.maps.LatLng(options.center.lat, options.center.lng),
|
|
413
|
+
radius: options.radius,
|
|
414
|
+
strokeWeight: options.strokeWeight,
|
|
415
|
+
strokeColor: options.strokeColor,
|
|
416
|
+
strokeOpacity: options.strokeOpacity,
|
|
417
|
+
fillColor: options.fillColor,
|
|
418
|
+
fillOpacity: options.fillOpacity,
|
|
419
|
+
zIndex: options.zIndex
|
|
420
|
+
});
|
|
421
|
+
return makeHandle(this.overlayReg.register(circle));
|
|
422
|
+
}
|
|
423
|
+
removeCircle(handle) {
|
|
424
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
425
|
+
this.overlayReg.delete(handle._handleId);
|
|
426
|
+
}
|
|
427
|
+
updateCircle(handle, options) {
|
|
428
|
+
const circle = this.overlayReg.get(handle._handleId);
|
|
429
|
+
if (options.center) circle.setCenter(new kakao.maps.LatLng(options.center.lat, options.center.lng));
|
|
430
|
+
if (options.radius !== void 0) circle.setRadius(options.radius);
|
|
431
|
+
circle.setOptions({
|
|
432
|
+
strokeColor: options.strokeColor,
|
|
433
|
+
fillColor: options.fillColor,
|
|
434
|
+
fillOpacity: options.fillOpacity
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
addRectangle(options) {
|
|
438
|
+
const rect = new kakao.maps.Rectangle({
|
|
439
|
+
map: this.map,
|
|
440
|
+
bounds: new kakao.maps.LatLngBounds(
|
|
441
|
+
new kakao.maps.LatLng(options.bounds.sw.lat, options.bounds.sw.lng),
|
|
442
|
+
new kakao.maps.LatLng(options.bounds.ne.lat, options.bounds.ne.lng)
|
|
443
|
+
),
|
|
444
|
+
strokeWeight: options.strokeWeight,
|
|
445
|
+
strokeColor: options.strokeColor,
|
|
446
|
+
strokeOpacity: options.strokeOpacity,
|
|
447
|
+
fillColor: options.fillColor,
|
|
448
|
+
fillOpacity: options.fillOpacity,
|
|
449
|
+
zIndex: options.zIndex
|
|
450
|
+
});
|
|
451
|
+
return makeHandle(this.overlayReg.register(rect));
|
|
452
|
+
}
|
|
453
|
+
removeRectangle(handle) {
|
|
454
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
455
|
+
this.overlayReg.delete(handle._handleId);
|
|
456
|
+
}
|
|
457
|
+
updateRectangle(handle, options) {
|
|
458
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
459
|
+
strokeColor: options.strokeColor,
|
|
460
|
+
fillColor: options.fillColor,
|
|
461
|
+
fillOpacity: options.fillOpacity
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
addCustomOverlay(options) {
|
|
465
|
+
const overlay = new kakao.maps.CustomOverlay({
|
|
466
|
+
position: new kakao.maps.LatLng(options.position.lat, options.position.lng),
|
|
467
|
+
content: options.content,
|
|
468
|
+
xAnchor: 0,
|
|
469
|
+
yAnchor: 0,
|
|
470
|
+
zIndex: options.zIndex ?? 100
|
|
471
|
+
});
|
|
472
|
+
overlay.setMap(this.map);
|
|
473
|
+
return makeHandle(this.overlayReg.register(overlay));
|
|
474
|
+
}
|
|
475
|
+
removeCustomOverlay(handle) {
|
|
476
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
477
|
+
this.overlayReg.delete(handle._handleId);
|
|
478
|
+
}
|
|
479
|
+
addTileLayer(options) {
|
|
480
|
+
const tileSize = options.tileSize ?? 256;
|
|
481
|
+
const tileLayer = new kakao.maps.TileLayer({
|
|
482
|
+
getTile: (x, y, z) => {
|
|
483
|
+
const img = document.createElement("img");
|
|
484
|
+
img.src = options.getTileUrl({ x, y }, z);
|
|
485
|
+
img.width = tileSize;
|
|
486
|
+
img.height = tileSize;
|
|
487
|
+
if (options.opacity !== void 0) img.style.opacity = String(options.opacity);
|
|
488
|
+
return img;
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
tileLayer.setMap(this.map);
|
|
492
|
+
return makeHandle(this.overlayReg.register(tileLayer));
|
|
493
|
+
}
|
|
494
|
+
removeTileLayer(handle) {
|
|
495
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
496
|
+
this.overlayReg.delete(handle._handleId);
|
|
497
|
+
}
|
|
498
|
+
// -------------------------------------------------------------------------
|
|
499
|
+
// Projection
|
|
500
|
+
// -------------------------------------------------------------------------
|
|
501
|
+
getProjection() {
|
|
502
|
+
return {
|
|
503
|
+
fromLatLngToPoint: (latlng) => ({ x: latlng.lng, y: latlng.lat }),
|
|
504
|
+
fromPointToLatLng: (point) => ({ lat: point.y, lng: point.x }),
|
|
505
|
+
fromLatLngToDivPixel: (latlng) => ({ x: latlng.lng, y: latlng.lat })
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
// -------------------------------------------------------------------------
|
|
509
|
+
// Private helpers
|
|
510
|
+
// -------------------------------------------------------------------------
|
|
511
|
+
_addLabelOverlay(marker, text, label) {
|
|
512
|
+
const div = document.createElement("div");
|
|
513
|
+
div.textContent = text;
|
|
514
|
+
div.style.cssText = [
|
|
515
|
+
"position:absolute",
|
|
516
|
+
"white-space:nowrap",
|
|
517
|
+
"pointer-events:none",
|
|
518
|
+
`color:${label?.color ?? "#000"}`,
|
|
519
|
+
`font-size:${label?.fontSize ?? "12px"}`,
|
|
520
|
+
`font-weight:${label?.fontWeight ?? "normal"}`
|
|
521
|
+
].join(";");
|
|
522
|
+
const LabelOverlay = class extends kakao.maps.AbstractOverlay {
|
|
523
|
+
onAdd() {
|
|
524
|
+
this.getPanels().overlayLayer.appendChild(div);
|
|
525
|
+
}
|
|
526
|
+
onRemove() {
|
|
527
|
+
div.parentNode?.removeChild(div);
|
|
528
|
+
}
|
|
529
|
+
draw() {
|
|
530
|
+
const proj = this.getProjection();
|
|
531
|
+
const pos = marker.getPosition();
|
|
532
|
+
const pt = proj.containerPointFromCoords(pos);
|
|
533
|
+
div.style.left = `${pt.x}px`;
|
|
534
|
+
div.style.top = `${pt.y - 20}px`;
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
new LabelOverlay().setMap(this.map);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
function resolveAppKey(apiKey) {
|
|
541
|
+
if (typeof apiKey === "string") return apiKey;
|
|
542
|
+
if (apiKey.appKey) return apiKey.appKey;
|
|
543
|
+
throw new ConfigurationError("Kakao Maps requires an appKey");
|
|
544
|
+
}
|
|
545
|
+
function normalizePadding(padding) {
|
|
546
|
+
if (padding === void 0) return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
547
|
+
if (typeof padding === "number") return { top: padding, right: padding, bottom: padding, left: padding };
|
|
548
|
+
return { top: padding.top ?? 0, right: padding.right ?? 0, bottom: padding.bottom ?? 0, left: padding.left ?? 0 };
|
|
549
|
+
}
|
|
550
|
+
function toKakaoLatLng(latlng) {
|
|
551
|
+
return new kakao.maps.LatLng(latlng.lat, latlng.lng);
|
|
552
|
+
}
|
|
553
|
+
function toKakaoPath(path) {
|
|
554
|
+
if (path.length === 0) return [];
|
|
555
|
+
const first = path[0];
|
|
556
|
+
if (Array.isArray(first)) {
|
|
557
|
+
return path.map((ring) => ring.map(toKakaoLatLng));
|
|
558
|
+
}
|
|
559
|
+
return path.map(toKakaoLatLng);
|
|
560
|
+
}
|
|
561
|
+
function buildMarkerImage(icon) {
|
|
562
|
+
if (!icon) throw new Error("icon is required");
|
|
563
|
+
const url = typeof icon === "string" ? icon : icon.url;
|
|
564
|
+
const size = typeof icon === "object" && icon.size ? new kakao.maps.Size(icon.size.width, icon.size.height) : new kakao.maps.Size(24, 35);
|
|
565
|
+
const opts = {};
|
|
566
|
+
if (typeof icon === "object") {
|
|
567
|
+
if (icon.anchor) opts.offset = new kakao.maps.Point(icon.anchor.x, icon.anchor.y);
|
|
568
|
+
if (icon.origin) opts.spriteOrigin = new kakao.maps.Point(icon.origin.x, icon.origin.y);
|
|
569
|
+
if (icon.scaledSize) opts.spriteSize = new kakao.maps.Size(icon.scaledSize.width, icon.scaledSize.height);
|
|
570
|
+
}
|
|
571
|
+
return new kakao.maps.MarkerImage(url, size, opts);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/providers/naver/NaverLoader.ts
|
|
575
|
+
var loadPromise2 = null;
|
|
576
|
+
function loadNaverSdk(clientId, submodules = []) {
|
|
577
|
+
if (loadPromise2) return loadPromise2;
|
|
578
|
+
loadPromise2 = new Promise((resolve, reject) => {
|
|
579
|
+
if (typeof window !== "undefined" && window.naver?.maps?.Map) {
|
|
580
|
+
resolve();
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
const params = new URLSearchParams({ ncpKeyId: clientId });
|
|
584
|
+
if (submodules.length > 0) params.set("submodules", submodules.join(","));
|
|
585
|
+
const script = document.createElement("script");
|
|
586
|
+
script.type = "text/javascript";
|
|
587
|
+
script.src = `https://oapi.map.naver.com/openapi/v3/maps.js?${params.toString()}`;
|
|
588
|
+
script.onload = () => resolve();
|
|
589
|
+
script.onerror = () => {
|
|
590
|
+
loadPromise2 = null;
|
|
591
|
+
reject(new ProviderLoadError("naver", new Error("Naver Maps SDK script failed to load")));
|
|
592
|
+
};
|
|
593
|
+
document.head.appendChild(script);
|
|
594
|
+
});
|
|
595
|
+
return loadPromise2;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/providers/naver/NaverAdapter.ts
|
|
599
|
+
function toNaverMapType(type) {
|
|
600
|
+
switch (type) {
|
|
601
|
+
case "satellite" /* SATELLITE */:
|
|
602
|
+
return naver.maps.MapTypeId.SATELLITE;
|
|
603
|
+
case "hybrid" /* HYBRID */:
|
|
604
|
+
return naver.maps.MapTypeId.HYBRID;
|
|
605
|
+
case "terrain" /* TERRAIN */:
|
|
606
|
+
return naver.maps.MapTypeId.TERRAIN;
|
|
607
|
+
default:
|
|
608
|
+
return naver.maps.MapTypeId.NORMAL;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
function fromNaverMapType(typeId) {
|
|
612
|
+
if (typeId === naver.maps.MapTypeId.SATELLITE) return "satellite" /* SATELLITE */;
|
|
613
|
+
if (typeId === naver.maps.MapTypeId.HYBRID) return "hybrid" /* HYBRID */;
|
|
614
|
+
if (typeId === naver.maps.MapTypeId.TERRAIN) return "terrain" /* TERRAIN */;
|
|
615
|
+
return "roadmap" /* ROADMAP */;
|
|
616
|
+
}
|
|
617
|
+
var FACADE_TO_NAVER_EVENT = {
|
|
618
|
+
click: "click",
|
|
619
|
+
dblclick: "dblclick",
|
|
620
|
+
rightclick: "rightclick",
|
|
621
|
+
mousemove: "mousemove",
|
|
622
|
+
drag: "drag",
|
|
623
|
+
dragstart: "dragstart",
|
|
624
|
+
dragend: "dragend",
|
|
625
|
+
zoom_changed: "zoom_changed",
|
|
626
|
+
center_changed: "center_changed",
|
|
627
|
+
bounds_changed: "bounds_changed",
|
|
628
|
+
idle: "idle",
|
|
629
|
+
tilesloaded: "tilesloaded"
|
|
630
|
+
};
|
|
631
|
+
var SUPPORTED_FEATURES2 = [];
|
|
632
|
+
var POINTER_EVENTS2 = /* @__PURE__ */ new Set(["click", "dblclick", "rightclick"]);
|
|
633
|
+
var NaverAdapter = class {
|
|
634
|
+
provider = "naver";
|
|
635
|
+
map;
|
|
636
|
+
markerReg = new HandleRegistry();
|
|
637
|
+
overlayReg = new HandleRegistry();
|
|
638
|
+
infoWindowReg = new HandleRegistry();
|
|
639
|
+
get nativeMap() {
|
|
640
|
+
return this.map;
|
|
641
|
+
}
|
|
642
|
+
async init(container, config) {
|
|
643
|
+
const clientId = resolveClientId(config.apiKey);
|
|
644
|
+
await loadNaverSdk(clientId);
|
|
645
|
+
const center = config.center ?? { lat: 37.5665, lng: 126.978 };
|
|
646
|
+
const zoom = config.zoom ?? 10;
|
|
647
|
+
const mapTarget = container.id ? container.id : container;
|
|
648
|
+
this.map = new naver.maps.Map(mapTarget, {
|
|
649
|
+
center: new naver.maps.LatLng(center.lat, center.lng),
|
|
650
|
+
zoom: toNaverZoom(zoom),
|
|
651
|
+
minZoom: 7,
|
|
652
|
+
maxZoom: 19,
|
|
653
|
+
...config.mapType && { mapTypeId: toNaverMapType(config.mapType) }
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
destroy() {
|
|
657
|
+
if (this.map) this.map.destroy();
|
|
658
|
+
}
|
|
659
|
+
// -------------------------------------------------------------------------
|
|
660
|
+
// Camera
|
|
661
|
+
// -------------------------------------------------------------------------
|
|
662
|
+
setCenter(latlng) {
|
|
663
|
+
this.map.setCenter(new naver.maps.LatLng(latlng.lat, latlng.lng));
|
|
664
|
+
}
|
|
665
|
+
getCenter() {
|
|
666
|
+
const c = this.map.getCenter();
|
|
667
|
+
return { lat: c.lat(), lng: c.lng() };
|
|
668
|
+
}
|
|
669
|
+
setZoom(zoom) {
|
|
670
|
+
this.map.setZoom(toNaverZoom(zoom), true);
|
|
671
|
+
}
|
|
672
|
+
getZoom() {
|
|
673
|
+
return fromNaverZoom(this.map.getZoom());
|
|
674
|
+
}
|
|
675
|
+
getBounds() {
|
|
676
|
+
const b = this.map.getBounds();
|
|
677
|
+
const sw = b.getSW();
|
|
678
|
+
const ne = b.getNE();
|
|
679
|
+
return {
|
|
680
|
+
sw: { lat: sw.lat(), lng: sw.lng() },
|
|
681
|
+
ne: { lat: ne.lat(), lng: ne.lng() }
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
fitBounds(bounds, options) {
|
|
685
|
+
const nb = new naver.maps.LatLngBounds(
|
|
686
|
+
new naver.maps.LatLng(bounds.sw.lat, bounds.sw.lng),
|
|
687
|
+
new naver.maps.LatLng(bounds.ne.lat, bounds.ne.lng)
|
|
688
|
+
);
|
|
689
|
+
const padding = normalizePaddingForNaver(options?.padding);
|
|
690
|
+
this.map.fitBounds(nb, { padding });
|
|
691
|
+
}
|
|
692
|
+
panTo(latlng, options) {
|
|
693
|
+
this.map.panTo(new naver.maps.LatLng(latlng.lat, latlng.lng), {
|
|
694
|
+
duration: options?.duration
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
panBy(x, y) {
|
|
698
|
+
this.map.panBy(x, y);
|
|
699
|
+
}
|
|
700
|
+
// -------------------------------------------------------------------------
|
|
701
|
+
// Map type
|
|
702
|
+
// -------------------------------------------------------------------------
|
|
703
|
+
setMapType(type) {
|
|
704
|
+
this.map.setMapTypeId(toNaverMapType(type));
|
|
705
|
+
}
|
|
706
|
+
getMapType() {
|
|
707
|
+
return fromNaverMapType(this.map.getMapTypeId());
|
|
708
|
+
}
|
|
709
|
+
// -------------------------------------------------------------------------
|
|
710
|
+
// Capability
|
|
711
|
+
// -------------------------------------------------------------------------
|
|
712
|
+
supports(feature) {
|
|
713
|
+
return SUPPORTED_FEATURES2.includes(feature);
|
|
714
|
+
}
|
|
715
|
+
// -------------------------------------------------------------------------
|
|
716
|
+
// Events
|
|
717
|
+
// -------------------------------------------------------------------------
|
|
718
|
+
on(event, handler) {
|
|
719
|
+
const naverEvent = FACADE_TO_NAVER_EVENT[event];
|
|
720
|
+
if (naverEvent) {
|
|
721
|
+
const wrapped = POINTER_EVENTS2.has(event) ? (e) => handler({ latlng: { lat: e.coord.lat(), lng: e.coord.lng() } }) : handler;
|
|
722
|
+
naver.maps.Event.addListener(this.map, naverEvent, wrapped);
|
|
723
|
+
}
|
|
724
|
+
return makeEventListener(event);
|
|
725
|
+
}
|
|
726
|
+
once(event, handler) {
|
|
727
|
+
const wrapper = (...args) => {
|
|
728
|
+
this.off(event, listener);
|
|
729
|
+
handler(...args);
|
|
730
|
+
};
|
|
731
|
+
const listener = this.on(event, wrapper);
|
|
732
|
+
return listener;
|
|
733
|
+
}
|
|
734
|
+
off(event, _listener) {
|
|
735
|
+
}
|
|
736
|
+
// -------------------------------------------------------------------------
|
|
737
|
+
// Markers
|
|
738
|
+
// -------------------------------------------------------------------------
|
|
739
|
+
addMarker(options) {
|
|
740
|
+
const icon = buildNaverIcon(options.icon);
|
|
741
|
+
const marker = new naver.maps.Marker({
|
|
742
|
+
map: this.map,
|
|
743
|
+
position: new naver.maps.LatLng(options.position.lat, options.position.lng),
|
|
744
|
+
icon,
|
|
745
|
+
title: options.title,
|
|
746
|
+
zIndex: options.zIndex,
|
|
747
|
+
visible: options.visible,
|
|
748
|
+
draggable: options.draggable,
|
|
749
|
+
opacity: options.opacity,
|
|
750
|
+
clickable: options.clickable,
|
|
751
|
+
animation: options.animation ? options.animation === "bounce" /* BOUNCE */ ? naver.maps.Animation.BOUNCE : naver.maps.Animation.DROP : void 0
|
|
752
|
+
});
|
|
753
|
+
const id = this.markerReg.register(marker);
|
|
754
|
+
return makeHandle(id);
|
|
755
|
+
}
|
|
756
|
+
removeMarker(handle) {
|
|
757
|
+
this.markerReg.get(handle._handleId).setMap(null);
|
|
758
|
+
this.markerReg.delete(handle._handleId);
|
|
759
|
+
}
|
|
760
|
+
updateMarker(handle, options) {
|
|
761
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
762
|
+
if (options.position) marker.setPosition(new naver.maps.LatLng(options.position.lat, options.position.lng));
|
|
763
|
+
if (options.icon !== void 0) marker.setIcon(buildNaverIcon(options.icon) ?? "");
|
|
764
|
+
if (options.title !== void 0) marker.setTitle(options.title);
|
|
765
|
+
if (options.visible !== void 0) marker.setVisible(options.visible);
|
|
766
|
+
if (options.draggable !== void 0) marker.setDraggable(options.draggable);
|
|
767
|
+
if (options.clickable !== void 0) marker.setClickable(options.clickable);
|
|
768
|
+
if (options.zIndex !== void 0) marker.setZIndex(options.zIndex);
|
|
769
|
+
if (options.opacity !== void 0) marker.setOpacity(options.opacity);
|
|
770
|
+
if (options.animation !== void 0) {
|
|
771
|
+
marker.setAnimation(
|
|
772
|
+
options.animation === null ? null : options.animation === "bounce" /* BOUNCE */ ? naver.maps.Animation.BOUNCE : naver.maps.Animation.DROP
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
addMarkerEvent(handle, event, handler) {
|
|
777
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
778
|
+
naver.maps.Event.addListener(marker, event, handler);
|
|
779
|
+
return makeEventListener(event);
|
|
780
|
+
}
|
|
781
|
+
removeMarkerEvent(handle, event, _listener) {
|
|
782
|
+
}
|
|
783
|
+
// -------------------------------------------------------------------------
|
|
784
|
+
// InfoWindow
|
|
785
|
+
// -------------------------------------------------------------------------
|
|
786
|
+
openInfoWindow(options, anchor) {
|
|
787
|
+
const iw = new naver.maps.InfoWindow({
|
|
788
|
+
content: options.content,
|
|
789
|
+
position: options.position ? new naver.maps.LatLng(options.position.lat, options.position.lng) : void 0,
|
|
790
|
+
maxWidth: options.maxWidth,
|
|
791
|
+
zIndex: options.zIndex
|
|
792
|
+
});
|
|
793
|
+
const marker = anchor ? this.markerReg.get(anchor._handleId) : void 0;
|
|
794
|
+
iw.open(this.map, marker);
|
|
795
|
+
return makeHandle(this.infoWindowReg.register(iw));
|
|
796
|
+
}
|
|
797
|
+
closeInfoWindow(handle) {
|
|
798
|
+
this.infoWindowReg.get(handle._handleId).close();
|
|
799
|
+
}
|
|
800
|
+
updateInfoWindow(handle, options) {
|
|
801
|
+
const iw = this.infoWindowReg.get(handle._handleId);
|
|
802
|
+
if (options.content !== void 0) iw.setContent(options.content);
|
|
803
|
+
if (options.position) iw.setPosition(new naver.maps.LatLng(options.position.lat, options.position.lng));
|
|
804
|
+
if (options.zIndex !== void 0) iw.setZIndex(options.zIndex);
|
|
805
|
+
}
|
|
806
|
+
isInfoWindowOpen(handle) {
|
|
807
|
+
return this.infoWindowReg.get(handle._handleId).getMap() !== null;
|
|
808
|
+
}
|
|
809
|
+
// -------------------------------------------------------------------------
|
|
810
|
+
// Vector overlays
|
|
811
|
+
// -------------------------------------------------------------------------
|
|
812
|
+
addPolyline(options) {
|
|
813
|
+
const polyline = new naver.maps.Polyline({
|
|
814
|
+
map: this.map,
|
|
815
|
+
path: toNaverPath(options.path),
|
|
816
|
+
strokeWeight: options.strokeWeight,
|
|
817
|
+
strokeColor: options.strokeColor,
|
|
818
|
+
strokeOpacity: options.strokeOpacity,
|
|
819
|
+
strokeStyle: options.strokeStyle,
|
|
820
|
+
geodesic: options.geodesic,
|
|
821
|
+
clickable: options.clickable,
|
|
822
|
+
zIndex: options.zIndex,
|
|
823
|
+
visible: options.visible
|
|
824
|
+
});
|
|
825
|
+
return makeHandle(this.overlayReg.register(polyline));
|
|
826
|
+
}
|
|
827
|
+
removePolyline(handle) {
|
|
828
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
829
|
+
this.overlayReg.delete(handle._handleId);
|
|
830
|
+
}
|
|
831
|
+
updatePolyline(handle, options) {
|
|
832
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
833
|
+
strokeColor: options.strokeColor,
|
|
834
|
+
strokeWeight: options.strokeWeight,
|
|
835
|
+
strokeOpacity: options.strokeOpacity
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
addPolygon(options) {
|
|
839
|
+
const polygon = new naver.maps.Polygon({
|
|
840
|
+
map: this.map,
|
|
841
|
+
paths: toNaverPath(options.paths),
|
|
842
|
+
strokeWeight: options.strokeWeight,
|
|
843
|
+
strokeColor: options.strokeColor,
|
|
844
|
+
strokeOpacity: options.strokeOpacity,
|
|
845
|
+
fillColor: options.fillColor,
|
|
846
|
+
fillOpacity: options.fillOpacity,
|
|
847
|
+
geodesic: options.geodesic,
|
|
848
|
+
clickable: options.clickable,
|
|
849
|
+
zIndex: options.zIndex,
|
|
850
|
+
visible: options.visible
|
|
851
|
+
});
|
|
852
|
+
return makeHandle(this.overlayReg.register(polygon));
|
|
853
|
+
}
|
|
854
|
+
removePolygon(handle) {
|
|
855
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
856
|
+
this.overlayReg.delete(handle._handleId);
|
|
857
|
+
}
|
|
858
|
+
updatePolygon(handle, options) {
|
|
859
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
860
|
+
strokeColor: options.strokeColor,
|
|
861
|
+
fillColor: options.fillColor,
|
|
862
|
+
fillOpacity: options.fillOpacity
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
addCircle(options) {
|
|
866
|
+
const circle = new naver.maps.Circle({
|
|
867
|
+
map: this.map,
|
|
868
|
+
center: new naver.maps.LatLng(options.center.lat, options.center.lng),
|
|
869
|
+
radius: options.radius,
|
|
870
|
+
strokeWeight: options.strokeWeight,
|
|
871
|
+
strokeColor: options.strokeColor,
|
|
872
|
+
strokeOpacity: options.strokeOpacity,
|
|
873
|
+
fillColor: options.fillColor,
|
|
874
|
+
fillOpacity: options.fillOpacity,
|
|
875
|
+
clickable: options.clickable,
|
|
876
|
+
zIndex: options.zIndex,
|
|
877
|
+
visible: options.visible
|
|
878
|
+
});
|
|
879
|
+
return makeHandle(this.overlayReg.register(circle));
|
|
880
|
+
}
|
|
881
|
+
removeCircle(handle) {
|
|
882
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
883
|
+
this.overlayReg.delete(handle._handleId);
|
|
884
|
+
}
|
|
885
|
+
updateCircle(handle, options) {
|
|
886
|
+
const circle = this.overlayReg.get(handle._handleId);
|
|
887
|
+
if (options.center) circle.setCenter(new naver.maps.LatLng(options.center.lat, options.center.lng));
|
|
888
|
+
if (options.radius !== void 0) circle.setRadius(options.radius);
|
|
889
|
+
circle.setOptions({
|
|
890
|
+
strokeColor: options.strokeColor,
|
|
891
|
+
fillColor: options.fillColor,
|
|
892
|
+
fillOpacity: options.fillOpacity
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
addRectangle(options) {
|
|
896
|
+
const rect = new naver.maps.Rectangle({
|
|
897
|
+
map: this.map,
|
|
898
|
+
bounds: new naver.maps.LatLngBounds(
|
|
899
|
+
new naver.maps.LatLng(options.bounds.sw.lat, options.bounds.sw.lng),
|
|
900
|
+
new naver.maps.LatLng(options.bounds.ne.lat, options.bounds.ne.lng)
|
|
901
|
+
),
|
|
902
|
+
strokeWeight: options.strokeWeight,
|
|
903
|
+
strokeColor: options.strokeColor,
|
|
904
|
+
strokeOpacity: options.strokeOpacity,
|
|
905
|
+
fillColor: options.fillColor,
|
|
906
|
+
fillOpacity: options.fillOpacity,
|
|
907
|
+
clickable: options.clickable,
|
|
908
|
+
zIndex: options.zIndex,
|
|
909
|
+
visible: options.visible
|
|
910
|
+
});
|
|
911
|
+
return makeHandle(this.overlayReg.register(rect));
|
|
912
|
+
}
|
|
913
|
+
removeRectangle(handle) {
|
|
914
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
915
|
+
this.overlayReg.delete(handle._handleId);
|
|
916
|
+
}
|
|
917
|
+
updateRectangle(handle, options) {
|
|
918
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
919
|
+
strokeColor: options.strokeColor,
|
|
920
|
+
fillColor: options.fillColor,
|
|
921
|
+
fillOpacity: options.fillOpacity
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
addCustomOverlay(options) {
|
|
925
|
+
const self = this;
|
|
926
|
+
const CustomOverlayClass = class extends naver.maps.OverlayView {
|
|
927
|
+
onAdd() {
|
|
928
|
+
this.getPanes().overlayLayer.appendChild(options.content);
|
|
929
|
+
}
|
|
930
|
+
onRemove() {
|
|
931
|
+
options.content.parentNode?.removeChild(options.content);
|
|
932
|
+
}
|
|
933
|
+
draw() {
|
|
934
|
+
const proj = this.getProjection();
|
|
935
|
+
const pt = proj.fromCoordToOffset(
|
|
936
|
+
new naver.maps.LatLng(options.position.lat, options.position.lng)
|
|
937
|
+
);
|
|
938
|
+
options.content.style.left = `${pt.x}px`;
|
|
939
|
+
options.content.style.top = `${pt.y}px`;
|
|
940
|
+
options.content.style.position = "absolute";
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
const overlay = new CustomOverlayClass();
|
|
944
|
+
overlay.setMap(self.map);
|
|
945
|
+
return makeHandle(this.overlayReg.register(overlay));
|
|
946
|
+
}
|
|
947
|
+
removeCustomOverlay(handle) {
|
|
948
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
949
|
+
this.overlayReg.delete(handle._handleId);
|
|
950
|
+
}
|
|
951
|
+
addTileLayer(options) {
|
|
952
|
+
const tileSize = options.tileSize ?? 256;
|
|
953
|
+
const layer = new naver.maps.ImageTileLayer({
|
|
954
|
+
getTileUrl: (x, y, z) => options.getTileUrl({ x, y }, z),
|
|
955
|
+
tileSize: new naver.maps.Size(tileSize, tileSize),
|
|
956
|
+
minZoom: options.minZoom,
|
|
957
|
+
maxZoom: options.maxZoom,
|
|
958
|
+
opacity: options.opacity,
|
|
959
|
+
zIndex: options.zIndex
|
|
960
|
+
});
|
|
961
|
+
layer.setMap(this.map);
|
|
962
|
+
return makeHandle(this.overlayReg.register(layer));
|
|
963
|
+
}
|
|
964
|
+
removeTileLayer(handle) {
|
|
965
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
966
|
+
this.overlayReg.delete(handle._handleId);
|
|
967
|
+
}
|
|
968
|
+
// -------------------------------------------------------------------------
|
|
969
|
+
// Projection
|
|
970
|
+
// -------------------------------------------------------------------------
|
|
971
|
+
getProjection() {
|
|
972
|
+
const proj = this.map.getProjection();
|
|
973
|
+
return {
|
|
974
|
+
fromLatLngToPoint: (latlng) => {
|
|
975
|
+
const pt = proj.fromCoordToOffset(new naver.maps.LatLng(latlng.lat, latlng.lng));
|
|
976
|
+
return { x: pt.x, y: pt.y };
|
|
977
|
+
},
|
|
978
|
+
fromPointToLatLng: (point) => {
|
|
979
|
+
const c = proj.fromOffsetToCoord(new naver.maps.Point(point.x, point.y));
|
|
980
|
+
return { lat: c.lat(), lng: c.lng() };
|
|
981
|
+
},
|
|
982
|
+
fromLatLngToDivPixel: (latlng) => {
|
|
983
|
+
const pt = proj.fromCoordToOffset(new naver.maps.LatLng(latlng.lat, latlng.lng));
|
|
984
|
+
return { x: pt.x, y: pt.y };
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
function resolveClientId(apiKey) {
|
|
990
|
+
if (typeof apiKey === "string") return apiKey;
|
|
991
|
+
if (apiKey.clientId) return apiKey.clientId;
|
|
992
|
+
throw new ConfigurationError("Naver Maps requires a clientId");
|
|
993
|
+
}
|
|
994
|
+
function normalizePaddingForNaver(padding) {
|
|
995
|
+
if (padding === void 0) return 0;
|
|
996
|
+
if (typeof padding === "number") return padding;
|
|
997
|
+
return { top: padding.top, right: padding.right, bottom: padding.bottom, left: padding.left };
|
|
998
|
+
}
|
|
999
|
+
function toNaverLatLng(latlng) {
|
|
1000
|
+
return new naver.maps.LatLng(latlng.lat, latlng.lng);
|
|
1001
|
+
}
|
|
1002
|
+
function toNaverPath(path) {
|
|
1003
|
+
if (path.length === 0) return [];
|
|
1004
|
+
const first = path[0];
|
|
1005
|
+
if (Array.isArray(first)) {
|
|
1006
|
+
return path.map((ring) => ring.map(toNaverLatLng));
|
|
1007
|
+
}
|
|
1008
|
+
return path.map(toNaverLatLng);
|
|
1009
|
+
}
|
|
1010
|
+
function buildNaverIcon(icon) {
|
|
1011
|
+
if (!icon) return void 0;
|
|
1012
|
+
if (typeof icon === "string") return icon;
|
|
1013
|
+
return {
|
|
1014
|
+
url: icon.url,
|
|
1015
|
+
size: icon.size ? new naver.maps.Size(icon.size.width, icon.size.height) : void 0,
|
|
1016
|
+
scaledSize: icon.scaledSize ? new naver.maps.Size(icon.scaledSize.width, icon.scaledSize.height) : void 0,
|
|
1017
|
+
origin: icon.origin ? new naver.maps.Point(icon.origin.x, icon.origin.y) : void 0,
|
|
1018
|
+
anchor: icon.anchor ? new naver.maps.Point(icon.anchor.x, icon.anchor.y) : void 0
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// src/providers/google/GoogleLoader.ts
|
|
1023
|
+
var loadPromise3 = null;
|
|
1024
|
+
function loadGoogleSdk(apiKey, libraries = ["marker"]) {
|
|
1025
|
+
if (loadPromise3) return loadPromise3;
|
|
1026
|
+
loadPromise3 = new Promise((resolve, reject) => {
|
|
1027
|
+
if (typeof window !== "undefined" && window.google?.maps?.Map) {
|
|
1028
|
+
resolve();
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
const params = new URLSearchParams({ key: apiKey, loading: "async" });
|
|
1032
|
+
if (libraries.length > 0) params.set("libraries", libraries.join(","));
|
|
1033
|
+
const callbackName = `__korMapiGoogleMapsCallback__`;
|
|
1034
|
+
params.set("callback", callbackName);
|
|
1035
|
+
window[callbackName] = () => {
|
|
1036
|
+
delete window[callbackName];
|
|
1037
|
+
resolve();
|
|
1038
|
+
};
|
|
1039
|
+
const script = document.createElement("script");
|
|
1040
|
+
script.type = "text/javascript";
|
|
1041
|
+
script.async = true;
|
|
1042
|
+
script.defer = true;
|
|
1043
|
+
script.src = `https://maps.googleapis.com/maps/api/js?${params.toString()}`;
|
|
1044
|
+
script.onerror = () => {
|
|
1045
|
+
loadPromise3 = null;
|
|
1046
|
+
delete window[callbackName];
|
|
1047
|
+
reject(new ProviderLoadError("google", new Error("Google Maps SDK script failed to load")));
|
|
1048
|
+
};
|
|
1049
|
+
document.head.appendChild(script);
|
|
1050
|
+
});
|
|
1051
|
+
return loadPromise3;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// src/providers/google/GoogleAdapter.ts
|
|
1055
|
+
var FACADE_TO_GOOGLE_TYPE = {
|
|
1056
|
+
["roadmap" /* ROADMAP */]: "roadmap",
|
|
1057
|
+
["satellite" /* SATELLITE */]: "satellite",
|
|
1058
|
+
["hybrid" /* HYBRID */]: "hybrid",
|
|
1059
|
+
["terrain" /* TERRAIN */]: "terrain"
|
|
1060
|
+
};
|
|
1061
|
+
var GOOGLE_TO_FACADE_TYPE = {
|
|
1062
|
+
roadmap: "roadmap" /* ROADMAP */,
|
|
1063
|
+
satellite: "satellite" /* SATELLITE */,
|
|
1064
|
+
hybrid: "hybrid" /* HYBRID */,
|
|
1065
|
+
terrain: "terrain" /* TERRAIN */
|
|
1066
|
+
};
|
|
1067
|
+
var FACADE_TO_GOOGLE_EVENT = {
|
|
1068
|
+
click: "click",
|
|
1069
|
+
dblclick: "dblclick",
|
|
1070
|
+
rightclick: "rightclick",
|
|
1071
|
+
mousemove: "mousemove",
|
|
1072
|
+
drag: "drag",
|
|
1073
|
+
dragstart: "dragstart",
|
|
1074
|
+
dragend: "dragend",
|
|
1075
|
+
zoom_changed: "zoom_changed",
|
|
1076
|
+
center_changed: "center_changed",
|
|
1077
|
+
bounds_changed: "bounds_changed",
|
|
1078
|
+
idle: "idle",
|
|
1079
|
+
tilesloaded: "tilesloaded"
|
|
1080
|
+
};
|
|
1081
|
+
var SUPPORTED_FEATURES3 = ["elevation", "streetview", "heatmap", "drawing", "mapStyles", "tilt", "heading", "trafficLayer"];
|
|
1082
|
+
var POINTER_EVENTS3 = /* @__PURE__ */ new Set(["click", "dblclick", "rightclick"]);
|
|
1083
|
+
var GoogleAdapter = class {
|
|
1084
|
+
provider = "google";
|
|
1085
|
+
map;
|
|
1086
|
+
markerReg = new HandleRegistry();
|
|
1087
|
+
overlayReg = new HandleRegistry();
|
|
1088
|
+
infoWindowReg = new HandleRegistry();
|
|
1089
|
+
// Track MapsEventListeners for proper cleanup
|
|
1090
|
+
eventListeners = /* @__PURE__ */ new Map();
|
|
1091
|
+
eventListenerIdCounter = 0;
|
|
1092
|
+
get nativeMap() {
|
|
1093
|
+
return this.map;
|
|
1094
|
+
}
|
|
1095
|
+
async init(container, config) {
|
|
1096
|
+
const apiKey = resolveApiKey(config.apiKey);
|
|
1097
|
+
await loadGoogleSdk(apiKey);
|
|
1098
|
+
const center = config.center ?? { lat: 37.5665, lng: 126.978 };
|
|
1099
|
+
const zoom = config.zoom ?? 10;
|
|
1100
|
+
this.map = new google.maps.Map(container, {
|
|
1101
|
+
center: new google.maps.LatLng(center.lat, center.lng),
|
|
1102
|
+
zoom: toGoogleZoom(zoom),
|
|
1103
|
+
minZoom: 7,
|
|
1104
|
+
maxZoom: 19,
|
|
1105
|
+
mapId: config.mapId ?? "DEMO_MAP_ID",
|
|
1106
|
+
...config.mapType && { mapTypeId: FACADE_TO_GOOGLE_TYPE[config.mapType] }
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
destroy() {
|
|
1110
|
+
for (const listener of this.eventListeners.values()) {
|
|
1111
|
+
listener.remove();
|
|
1112
|
+
}
|
|
1113
|
+
this.eventListeners.clear();
|
|
1114
|
+
}
|
|
1115
|
+
// -------------------------------------------------------------------------
|
|
1116
|
+
// Camera
|
|
1117
|
+
// -------------------------------------------------------------------------
|
|
1118
|
+
setCenter(latlng) {
|
|
1119
|
+
this.map.setCenter(new google.maps.LatLng(latlng.lat, latlng.lng));
|
|
1120
|
+
}
|
|
1121
|
+
getCenter() {
|
|
1122
|
+
const c = this.map.getCenter();
|
|
1123
|
+
if (!c) return { lat: 0, lng: 0 };
|
|
1124
|
+
return { lat: c.lat(), lng: c.lng() };
|
|
1125
|
+
}
|
|
1126
|
+
setZoom(zoom) {
|
|
1127
|
+
this.map.setZoom(toGoogleZoom(zoom));
|
|
1128
|
+
}
|
|
1129
|
+
getZoom() {
|
|
1130
|
+
return fromGoogleZoom(this.map.getZoom() ?? 10);
|
|
1131
|
+
}
|
|
1132
|
+
getBounds() {
|
|
1133
|
+
const b = this.map.getBounds();
|
|
1134
|
+
if (!b) return { sw: { lat: 0, lng: 0 }, ne: { lat: 0, lng: 0 } };
|
|
1135
|
+
const sw = b.getSouthWest();
|
|
1136
|
+
const ne = b.getNorthEast();
|
|
1137
|
+
return {
|
|
1138
|
+
sw: { lat: sw.lat(), lng: sw.lng() },
|
|
1139
|
+
ne: { lat: ne.lat(), lng: ne.lng() }
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
fitBounds(bounds, options) {
|
|
1143
|
+
const gb = new google.maps.LatLngBounds(
|
|
1144
|
+
new google.maps.LatLng(bounds.sw.lat, bounds.sw.lng),
|
|
1145
|
+
new google.maps.LatLng(bounds.ne.lat, bounds.ne.lng)
|
|
1146
|
+
);
|
|
1147
|
+
const padding = normalizePaddingForGoogle(options?.padding);
|
|
1148
|
+
this.map.fitBounds(gb, padding);
|
|
1149
|
+
}
|
|
1150
|
+
panTo(latlng, _options) {
|
|
1151
|
+
this.map.panTo(new google.maps.LatLng(latlng.lat, latlng.lng));
|
|
1152
|
+
}
|
|
1153
|
+
panBy(x, y) {
|
|
1154
|
+
this.map.panBy(x, y);
|
|
1155
|
+
}
|
|
1156
|
+
// -------------------------------------------------------------------------
|
|
1157
|
+
// Map type
|
|
1158
|
+
// -------------------------------------------------------------------------
|
|
1159
|
+
setMapType(type) {
|
|
1160
|
+
this.map.setMapTypeId(FACADE_TO_GOOGLE_TYPE[type]);
|
|
1161
|
+
}
|
|
1162
|
+
getMapType() {
|
|
1163
|
+
return GOOGLE_TO_FACADE_TYPE[this.map.getMapTypeId()] ?? "roadmap" /* ROADMAP */;
|
|
1164
|
+
}
|
|
1165
|
+
// -------------------------------------------------------------------------
|
|
1166
|
+
// Capability
|
|
1167
|
+
// -------------------------------------------------------------------------
|
|
1168
|
+
supports(feature) {
|
|
1169
|
+
return SUPPORTED_FEATURES3.includes(feature);
|
|
1170
|
+
}
|
|
1171
|
+
// -------------------------------------------------------------------------
|
|
1172
|
+
// Events
|
|
1173
|
+
// -------------------------------------------------------------------------
|
|
1174
|
+
on(event, handler) {
|
|
1175
|
+
const googleEvent = FACADE_TO_GOOGLE_EVENT[event];
|
|
1176
|
+
const listener = makeEventListener(event);
|
|
1177
|
+
if (googleEvent) {
|
|
1178
|
+
const wrapped = POINTER_EVENTS3.has(event) ? (e) => handler({ latlng: { lat: e.latLng?.lat() ?? 0, lng: e.latLng?.lng() ?? 0 } }) : handler;
|
|
1179
|
+
const mapsListener = google.maps.event.addListener(
|
|
1180
|
+
this.map,
|
|
1181
|
+
googleEvent,
|
|
1182
|
+
wrapped
|
|
1183
|
+
);
|
|
1184
|
+
this.eventListeners.set(++this.eventListenerIdCounter, mapsListener);
|
|
1185
|
+
}
|
|
1186
|
+
return listener;
|
|
1187
|
+
}
|
|
1188
|
+
once(event, handler) {
|
|
1189
|
+
const wrapper = (...args) => {
|
|
1190
|
+
this.off(event, listener);
|
|
1191
|
+
handler(...args);
|
|
1192
|
+
};
|
|
1193
|
+
const listener = this.on(event, wrapper);
|
|
1194
|
+
return listener;
|
|
1195
|
+
}
|
|
1196
|
+
off(_event, _listener) {
|
|
1197
|
+
}
|
|
1198
|
+
// -------------------------------------------------------------------------
|
|
1199
|
+
// Markers
|
|
1200
|
+
// -------------------------------------------------------------------------
|
|
1201
|
+
addMarker(options) {
|
|
1202
|
+
const content = buildAdvancedMarkerContent(options);
|
|
1203
|
+
const marker = new google.maps.marker.AdvancedMarkerElement({
|
|
1204
|
+
map: this.map,
|
|
1205
|
+
position: { lat: options.position.lat, lng: options.position.lng },
|
|
1206
|
+
title: options.title ?? "",
|
|
1207
|
+
content,
|
|
1208
|
+
gmpClickable: options.clickable ?? true,
|
|
1209
|
+
gmpDraggable: options.draggable ?? false,
|
|
1210
|
+
zIndex: options.zIndex ?? null
|
|
1211
|
+
});
|
|
1212
|
+
if (options.visible === false) marker.map = null;
|
|
1213
|
+
if (options.opacity !== void 0 && marker.content) marker.content.style.opacity = String(options.opacity);
|
|
1214
|
+
return makeHandle(this.markerReg.register(marker));
|
|
1215
|
+
}
|
|
1216
|
+
removeMarker(handle) {
|
|
1217
|
+
this.markerReg.get(handle._handleId).map = null;
|
|
1218
|
+
this.markerReg.delete(handle._handleId);
|
|
1219
|
+
}
|
|
1220
|
+
updateMarker(handle, options) {
|
|
1221
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
1222
|
+
if (options.position) marker.position = { lat: options.position.lat, lng: options.position.lng };
|
|
1223
|
+
if (options.title !== void 0) marker.title = options.title ?? "";
|
|
1224
|
+
if (options.zIndex !== void 0) marker.zIndex = options.zIndex ?? null;
|
|
1225
|
+
if (options.draggable !== void 0) marker.gmpDraggable = options.draggable;
|
|
1226
|
+
if (options.clickable !== void 0) marker.gmpClickable = options.clickable;
|
|
1227
|
+
if (options.icon !== void 0) marker.content = buildAdvancedMarkerContent(options) ?? null;
|
|
1228
|
+
if (options.visible !== void 0) {
|
|
1229
|
+
marker.map = options.visible ? this.map : null;
|
|
1230
|
+
}
|
|
1231
|
+
if (options.opacity !== void 0 && marker.content) marker.content.style.opacity = String(options.opacity);
|
|
1232
|
+
}
|
|
1233
|
+
addMarkerEvent(handle, event, handler) {
|
|
1234
|
+
const marker = this.markerReg.get(handle._handleId);
|
|
1235
|
+
marker.addListener(event, handler);
|
|
1236
|
+
return makeEventListener(event);
|
|
1237
|
+
}
|
|
1238
|
+
removeMarkerEvent(_handle, _event, _listener) {
|
|
1239
|
+
}
|
|
1240
|
+
// -------------------------------------------------------------------------
|
|
1241
|
+
// InfoWindow
|
|
1242
|
+
// -------------------------------------------------------------------------
|
|
1243
|
+
openInfoWindow(options, anchor) {
|
|
1244
|
+
const iw = new google.maps.InfoWindow({
|
|
1245
|
+
content: options.content,
|
|
1246
|
+
position: options.position ? new google.maps.LatLng(options.position.lat, options.position.lng) : void 0,
|
|
1247
|
+
maxWidth: options.maxWidth,
|
|
1248
|
+
disableAutoPan: options.disableAutoPan,
|
|
1249
|
+
zIndex: options.zIndex
|
|
1250
|
+
});
|
|
1251
|
+
const advMarker = anchor ? this.markerReg.get(anchor._handleId) : void 0;
|
|
1252
|
+
iw.open({ map: this.map, anchor: advMarker });
|
|
1253
|
+
return makeHandle(this.infoWindowReg.register(iw));
|
|
1254
|
+
}
|
|
1255
|
+
closeInfoWindow(handle) {
|
|
1256
|
+
this.infoWindowReg.get(handle._handleId).close();
|
|
1257
|
+
}
|
|
1258
|
+
updateInfoWindow(handle, options) {
|
|
1259
|
+
const iw = this.infoWindowReg.get(handle._handleId);
|
|
1260
|
+
if (options.content !== void 0) iw.setContent(options.content);
|
|
1261
|
+
if (options.position) iw.setPosition(new google.maps.LatLng(options.position.lat, options.position.lng));
|
|
1262
|
+
if (options.zIndex !== void 0) iw.setZIndex(options.zIndex);
|
|
1263
|
+
}
|
|
1264
|
+
isInfoWindowOpen(handle) {
|
|
1265
|
+
return this.infoWindowReg.get(handle._handleId).getMap() !== null;
|
|
1266
|
+
}
|
|
1267
|
+
// -------------------------------------------------------------------------
|
|
1268
|
+
// Vector overlays
|
|
1269
|
+
// -------------------------------------------------------------------------
|
|
1270
|
+
addPolyline(options) {
|
|
1271
|
+
const polyline = new google.maps.Polyline({
|
|
1272
|
+
map: this.map,
|
|
1273
|
+
path: toGoogleFlatPath(options.path),
|
|
1274
|
+
strokeColor: options.strokeColor,
|
|
1275
|
+
strokeOpacity: options.strokeOpacity,
|
|
1276
|
+
strokeWeight: options.strokeWeight,
|
|
1277
|
+
geodesic: options.geodesic,
|
|
1278
|
+
clickable: options.clickable,
|
|
1279
|
+
zIndex: options.zIndex,
|
|
1280
|
+
visible: options.visible
|
|
1281
|
+
});
|
|
1282
|
+
return makeHandle(this.overlayReg.register(polyline));
|
|
1283
|
+
}
|
|
1284
|
+
removePolyline(handle) {
|
|
1285
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
1286
|
+
this.overlayReg.delete(handle._handleId);
|
|
1287
|
+
}
|
|
1288
|
+
updatePolyline(handle, options) {
|
|
1289
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
1290
|
+
strokeColor: options.strokeColor,
|
|
1291
|
+
strokeOpacity: options.strokeOpacity,
|
|
1292
|
+
strokeWeight: options.strokeWeight
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
addPolygon(options) {
|
|
1296
|
+
const polygon = new google.maps.Polygon({
|
|
1297
|
+
map: this.map,
|
|
1298
|
+
paths: toGooglePaths(options.paths),
|
|
1299
|
+
strokeColor: options.strokeColor,
|
|
1300
|
+
strokeOpacity: options.strokeOpacity,
|
|
1301
|
+
strokeWeight: options.strokeWeight,
|
|
1302
|
+
fillColor: options.fillColor,
|
|
1303
|
+
fillOpacity: options.fillOpacity,
|
|
1304
|
+
geodesic: options.geodesic,
|
|
1305
|
+
clickable: options.clickable,
|
|
1306
|
+
zIndex: options.zIndex,
|
|
1307
|
+
visible: options.visible
|
|
1308
|
+
});
|
|
1309
|
+
return makeHandle(this.overlayReg.register(polygon));
|
|
1310
|
+
}
|
|
1311
|
+
removePolygon(handle) {
|
|
1312
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
1313
|
+
this.overlayReg.delete(handle._handleId);
|
|
1314
|
+
}
|
|
1315
|
+
updatePolygon(handle, options) {
|
|
1316
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
1317
|
+
strokeColor: options.strokeColor,
|
|
1318
|
+
fillColor: options.fillColor,
|
|
1319
|
+
fillOpacity: options.fillOpacity
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
addCircle(options) {
|
|
1323
|
+
const circle = new google.maps.Circle({
|
|
1324
|
+
map: this.map,
|
|
1325
|
+
center: new google.maps.LatLng(options.center.lat, options.center.lng),
|
|
1326
|
+
radius: options.radius,
|
|
1327
|
+
strokeColor: options.strokeColor,
|
|
1328
|
+
strokeOpacity: options.strokeOpacity,
|
|
1329
|
+
strokeWeight: options.strokeWeight,
|
|
1330
|
+
fillColor: options.fillColor,
|
|
1331
|
+
fillOpacity: options.fillOpacity,
|
|
1332
|
+
clickable: options.clickable,
|
|
1333
|
+
zIndex: options.zIndex,
|
|
1334
|
+
visible: options.visible
|
|
1335
|
+
});
|
|
1336
|
+
return makeHandle(this.overlayReg.register(circle));
|
|
1337
|
+
}
|
|
1338
|
+
removeCircle(handle) {
|
|
1339
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
1340
|
+
this.overlayReg.delete(handle._handleId);
|
|
1341
|
+
}
|
|
1342
|
+
updateCircle(handle, options) {
|
|
1343
|
+
const circle = this.overlayReg.get(handle._handleId);
|
|
1344
|
+
if (options.center) circle.setCenter(new google.maps.LatLng(options.center.lat, options.center.lng));
|
|
1345
|
+
if (options.radius !== void 0) circle.setRadius(options.radius);
|
|
1346
|
+
circle.setOptions({
|
|
1347
|
+
strokeColor: options.strokeColor,
|
|
1348
|
+
fillColor: options.fillColor,
|
|
1349
|
+
fillOpacity: options.fillOpacity
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
addRectangle(options) {
|
|
1353
|
+
const rect = new google.maps.Rectangle({
|
|
1354
|
+
map: this.map,
|
|
1355
|
+
bounds: new google.maps.LatLngBounds(
|
|
1356
|
+
new google.maps.LatLng(options.bounds.sw.lat, options.bounds.sw.lng),
|
|
1357
|
+
new google.maps.LatLng(options.bounds.ne.lat, options.bounds.ne.lng)
|
|
1358
|
+
),
|
|
1359
|
+
strokeColor: options.strokeColor,
|
|
1360
|
+
strokeOpacity: options.strokeOpacity,
|
|
1361
|
+
strokeWeight: options.strokeWeight,
|
|
1362
|
+
fillColor: options.fillColor,
|
|
1363
|
+
fillOpacity: options.fillOpacity,
|
|
1364
|
+
clickable: options.clickable,
|
|
1365
|
+
zIndex: options.zIndex,
|
|
1366
|
+
visible: options.visible
|
|
1367
|
+
});
|
|
1368
|
+
return makeHandle(this.overlayReg.register(rect));
|
|
1369
|
+
}
|
|
1370
|
+
removeRectangle(handle) {
|
|
1371
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
1372
|
+
this.overlayReg.delete(handle._handleId);
|
|
1373
|
+
}
|
|
1374
|
+
updateRectangle(handle, options) {
|
|
1375
|
+
this.overlayReg.get(handle._handleId).setOptions({
|
|
1376
|
+
strokeColor: options.strokeColor,
|
|
1377
|
+
fillColor: options.fillColor,
|
|
1378
|
+
fillOpacity: options.fillOpacity
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
addCustomOverlay(options) {
|
|
1382
|
+
const self = this;
|
|
1383
|
+
const CustomOverlayClass = class extends google.maps.OverlayView {
|
|
1384
|
+
onAdd() {
|
|
1385
|
+
const panes = this.getPanes();
|
|
1386
|
+
if (!panes) return;
|
|
1387
|
+
const pane = options.clickable ? panes.overlayMouseTarget : panes.overlayLayer;
|
|
1388
|
+
pane.appendChild(options.content);
|
|
1389
|
+
}
|
|
1390
|
+
onRemove() {
|
|
1391
|
+
options.content.parentNode?.removeChild(options.content);
|
|
1392
|
+
}
|
|
1393
|
+
draw() {
|
|
1394
|
+
const proj = this.getProjection();
|
|
1395
|
+
const pt = proj.fromLatLngToDivPixel(
|
|
1396
|
+
new google.maps.LatLng(options.position.lat, options.position.lng)
|
|
1397
|
+
);
|
|
1398
|
+
if (pt) {
|
|
1399
|
+
options.content.style.left = `${pt.x}px`;
|
|
1400
|
+
options.content.style.top = `${pt.y}px`;
|
|
1401
|
+
options.content.style.position = "absolute";
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
const overlay = new CustomOverlayClass();
|
|
1406
|
+
overlay.setMap(self.map);
|
|
1407
|
+
return makeHandle(this.overlayReg.register(overlay));
|
|
1408
|
+
}
|
|
1409
|
+
removeCustomOverlay(handle) {
|
|
1410
|
+
this.overlayReg.get(handle._handleId).setMap(null);
|
|
1411
|
+
this.overlayReg.delete(handle._handleId);
|
|
1412
|
+
}
|
|
1413
|
+
addTileLayer(options) {
|
|
1414
|
+
const tileSize = options.tileSize ?? 256;
|
|
1415
|
+
const layer = new google.maps.ImageMapType({
|
|
1416
|
+
getTileUrl: (coord, zoom) => options.getTileUrl({ x: coord.x, y: coord.y }, zoom),
|
|
1417
|
+
tileSize: new google.maps.Size(tileSize, tileSize),
|
|
1418
|
+
minZoom: options.minZoom,
|
|
1419
|
+
maxZoom: options.maxZoom,
|
|
1420
|
+
opacity: options.opacity
|
|
1421
|
+
});
|
|
1422
|
+
if (options.opacity !== void 0) layer.setOpacity(options.opacity);
|
|
1423
|
+
this.map.overlayMapTypes?.push?.(layer);
|
|
1424
|
+
return makeHandle(this.overlayReg.register(layer));
|
|
1425
|
+
}
|
|
1426
|
+
removeTileLayer(handle) {
|
|
1427
|
+
this.overlayReg.delete(handle._handleId);
|
|
1428
|
+
}
|
|
1429
|
+
// -------------------------------------------------------------------------
|
|
1430
|
+
// Projection
|
|
1431
|
+
// -------------------------------------------------------------------------
|
|
1432
|
+
getProjection() {
|
|
1433
|
+
const proj = this.map.getProjection();
|
|
1434
|
+
return {
|
|
1435
|
+
fromLatLngToPoint: (latlng) => {
|
|
1436
|
+
const pt = proj?.fromLatLngToPoint(new google.maps.LatLng(latlng.lat, latlng.lng));
|
|
1437
|
+
return pt ? { x: pt.x, y: pt.y } : { x: 0, y: 0 };
|
|
1438
|
+
},
|
|
1439
|
+
fromPointToLatLng: (point) => {
|
|
1440
|
+
const c = proj?.fromPointToLatLng(new google.maps.Point(point.x, point.y));
|
|
1441
|
+
return c ? { lat: c.lat(), lng: c.lng() } : { lat: 0, lng: 0 };
|
|
1442
|
+
},
|
|
1443
|
+
fromLatLngToDivPixel: (latlng) => {
|
|
1444
|
+
const pt = proj?.fromLatLngToPoint(new google.maps.LatLng(latlng.lat, latlng.lng));
|
|
1445
|
+
return pt ? { x: pt.x, y: pt.y } : { x: 0, y: 0 };
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
function resolveApiKey(apiKey) {
|
|
1451
|
+
if (typeof apiKey === "string") return apiKey;
|
|
1452
|
+
if (apiKey.apiKey) return apiKey.apiKey;
|
|
1453
|
+
throw new ConfigurationError("Google Maps requires an apiKey");
|
|
1454
|
+
}
|
|
1455
|
+
function normalizePaddingForGoogle(padding) {
|
|
1456
|
+
if (padding === void 0) return 0;
|
|
1457
|
+
if (typeof padding === "number") return padding;
|
|
1458
|
+
return {
|
|
1459
|
+
top: padding.top ?? 0,
|
|
1460
|
+
right: padding.right ?? 0,
|
|
1461
|
+
bottom: padding.bottom ?? 0,
|
|
1462
|
+
left: padding.left ?? 0
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function toGoogleLatLng(latlng) {
|
|
1466
|
+
return new google.maps.LatLng(latlng.lat, latlng.lng);
|
|
1467
|
+
}
|
|
1468
|
+
function toGoogleFlatPath(path) {
|
|
1469
|
+
if (path.length === 0) return [];
|
|
1470
|
+
if (Array.isArray(path[0])) {
|
|
1471
|
+
return path[0].map(toGoogleLatLng);
|
|
1472
|
+
}
|
|
1473
|
+
return path.map(toGoogleLatLng);
|
|
1474
|
+
}
|
|
1475
|
+
function toGooglePaths(paths) {
|
|
1476
|
+
if (paths.length === 0) return [];
|
|
1477
|
+
if (Array.isArray(paths[0])) {
|
|
1478
|
+
return paths.map((ring) => ring.map(toGoogleLatLng));
|
|
1479
|
+
}
|
|
1480
|
+
return paths.map(toGoogleLatLng);
|
|
1481
|
+
}
|
|
1482
|
+
function buildAdvancedMarkerContent(options) {
|
|
1483
|
+
const { icon, label } = options;
|
|
1484
|
+
if (!icon && !label) return void 0;
|
|
1485
|
+
const container = document.createElement("div");
|
|
1486
|
+
container.style.cssText = "display:flex;flex-direction:column;align-items:center;cursor:pointer";
|
|
1487
|
+
if (icon) {
|
|
1488
|
+
const img = document.createElement("img");
|
|
1489
|
+
img.src = typeof icon === "string" ? icon : icon.url;
|
|
1490
|
+
if (typeof icon === "object") {
|
|
1491
|
+
const sz = icon.scaledSize ?? icon.size;
|
|
1492
|
+
if (sz) {
|
|
1493
|
+
img.style.width = `${sz.width}px`;
|
|
1494
|
+
img.style.height = `${sz.height}px`;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
container.appendChild(img);
|
|
1498
|
+
}
|
|
1499
|
+
if (label) {
|
|
1500
|
+
const span = document.createElement("span");
|
|
1501
|
+
span.textContent = label.text;
|
|
1502
|
+
span.style.cssText = [
|
|
1503
|
+
`color:${label.color ?? "#000"}`,
|
|
1504
|
+
`font-size:${label.fontSize ?? "12px"}`,
|
|
1505
|
+
`font-weight:${label.fontWeight ?? "normal"}`,
|
|
1506
|
+
"white-space:nowrap"
|
|
1507
|
+
].join(";");
|
|
1508
|
+
container.appendChild(span);
|
|
1509
|
+
}
|
|
1510
|
+
return container;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// src/core/KorMap.ts
|
|
1514
|
+
var KorMap = class _KorMap {
|
|
1515
|
+
adapter;
|
|
1516
|
+
constructor(adapter) {
|
|
1517
|
+
this.adapter = adapter;
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Async factory. Loads the provider SDK and initializes the map.
|
|
1521
|
+
*/
|
|
1522
|
+
static async create(config) {
|
|
1523
|
+
const container = resolveContainer(config.container);
|
|
1524
|
+
const adapter = createAdapter(config.provider);
|
|
1525
|
+
await adapter.init(container, config);
|
|
1526
|
+
return new _KorMap(adapter);
|
|
1527
|
+
}
|
|
1528
|
+
// -------------------------------------------------------------------------
|
|
1529
|
+
// Provider info
|
|
1530
|
+
// -------------------------------------------------------------------------
|
|
1531
|
+
getProvider() {
|
|
1532
|
+
return this.adapter.provider;
|
|
1533
|
+
}
|
|
1534
|
+
supports(feature) {
|
|
1535
|
+
return this.adapter.supports(feature);
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* The raw underlying map object.
|
|
1539
|
+
* Typed via generic when the provider is known at compile time:
|
|
1540
|
+
* const map = await KorMap.create<'naver'>({ provider: 'naver', ... });
|
|
1541
|
+
* map.native // → naver.maps.Map
|
|
1542
|
+
*/
|
|
1543
|
+
get native() {
|
|
1544
|
+
return this.adapter.nativeMap;
|
|
1545
|
+
}
|
|
1546
|
+
// -------------------------------------------------------------------------
|
|
1547
|
+
// Camera / viewport
|
|
1548
|
+
// -------------------------------------------------------------------------
|
|
1549
|
+
setCenter(latlng) {
|
|
1550
|
+
this.adapter.setCenter(latlng);
|
|
1551
|
+
}
|
|
1552
|
+
getCenter() {
|
|
1553
|
+
return this.adapter.getCenter();
|
|
1554
|
+
}
|
|
1555
|
+
setZoom(zoom) {
|
|
1556
|
+
this.adapter.setZoom(zoom);
|
|
1557
|
+
}
|
|
1558
|
+
getZoom() {
|
|
1559
|
+
return this.adapter.getZoom();
|
|
1560
|
+
}
|
|
1561
|
+
getBounds() {
|
|
1562
|
+
return this.adapter.getBounds();
|
|
1563
|
+
}
|
|
1564
|
+
fitBounds(bounds, options) {
|
|
1565
|
+
this.adapter.fitBounds(bounds, options);
|
|
1566
|
+
}
|
|
1567
|
+
panTo(latlng, options) {
|
|
1568
|
+
this.adapter.panTo(latlng, options);
|
|
1569
|
+
}
|
|
1570
|
+
panBy(x, y) {
|
|
1571
|
+
this.adapter.panBy(x, y);
|
|
1572
|
+
}
|
|
1573
|
+
// -------------------------------------------------------------------------
|
|
1574
|
+
// Map type
|
|
1575
|
+
// -------------------------------------------------------------------------
|
|
1576
|
+
setMapType(type) {
|
|
1577
|
+
this.adapter.setMapType(type);
|
|
1578
|
+
}
|
|
1579
|
+
getMapType() {
|
|
1580
|
+
return this.adapter.getMapType();
|
|
1581
|
+
}
|
|
1582
|
+
// -------------------------------------------------------------------------
|
|
1583
|
+
// Events
|
|
1584
|
+
// -------------------------------------------------------------------------
|
|
1585
|
+
on(event, handler) {
|
|
1586
|
+
return this.adapter.on(event, handler);
|
|
1587
|
+
}
|
|
1588
|
+
once(event, handler) {
|
|
1589
|
+
return this.adapter.once(event, handler);
|
|
1590
|
+
}
|
|
1591
|
+
off(event, listener) {
|
|
1592
|
+
this.adapter.off(event, listener);
|
|
1593
|
+
}
|
|
1594
|
+
// -------------------------------------------------------------------------
|
|
1595
|
+
// Lifecycle
|
|
1596
|
+
// -------------------------------------------------------------------------
|
|
1597
|
+
destroy() {
|
|
1598
|
+
this.adapter.destroy();
|
|
1599
|
+
}
|
|
1600
|
+
// -------------------------------------------------------------------------
|
|
1601
|
+
// Internal adapter access (for overlay classes)
|
|
1602
|
+
// -------------------------------------------------------------------------
|
|
1603
|
+
/** @internal */
|
|
1604
|
+
_adapter() {
|
|
1605
|
+
return this.adapter;
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
function resolveContainer(container) {
|
|
1609
|
+
if (typeof container === "string") {
|
|
1610
|
+
const el = /^[#.[[]/.test(container) ? document.querySelector(container) : document.getElementById(container);
|
|
1611
|
+
if (!el) throw new ConfigurationError(`Container element not found: "${container}"`);
|
|
1612
|
+
return el;
|
|
1613
|
+
}
|
|
1614
|
+
return container;
|
|
1615
|
+
}
|
|
1616
|
+
function createAdapter(provider) {
|
|
1617
|
+
switch (provider) {
|
|
1618
|
+
case "kakao":
|
|
1619
|
+
return new KakaoAdapter();
|
|
1620
|
+
case "naver":
|
|
1621
|
+
return new NaverAdapter();
|
|
1622
|
+
case "google":
|
|
1623
|
+
return new GoogleAdapter();
|
|
1624
|
+
default:
|
|
1625
|
+
throw new ConfigurationError(`Unknown provider: "${String(provider)}"`);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
// src/core/overlays.ts
|
|
1630
|
+
var Marker = class {
|
|
1631
|
+
constructor(options) {
|
|
1632
|
+
this.options = options;
|
|
1633
|
+
}
|
|
1634
|
+
handle = null;
|
|
1635
|
+
currentMap = null;
|
|
1636
|
+
setMap(map) {
|
|
1637
|
+
if (this.currentMap && this.handle) {
|
|
1638
|
+
this.currentMap._adapter().removeMarker(this.handle);
|
|
1639
|
+
this.handle = null;
|
|
1640
|
+
this.currentMap = null;
|
|
1641
|
+
}
|
|
1642
|
+
if (map) {
|
|
1643
|
+
this.handle = map._adapter().addMarker(this.options);
|
|
1644
|
+
this.currentMap = map;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
getMap() {
|
|
1648
|
+
return this.currentMap;
|
|
1649
|
+
}
|
|
1650
|
+
setPosition(latlng) {
|
|
1651
|
+
this.options = { ...this.options, position: latlng };
|
|
1652
|
+
if (this.handle && this.currentMap) {
|
|
1653
|
+
this.currentMap._adapter().updateMarker(this.handle, { position: latlng });
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
getPosition() {
|
|
1657
|
+
return this.options.position;
|
|
1658
|
+
}
|
|
1659
|
+
setVisible(visible) {
|
|
1660
|
+
this.options = { ...this.options, visible };
|
|
1661
|
+
if (this.handle && this.currentMap) {
|
|
1662
|
+
this.currentMap._adapter().updateMarker(this.handle, { visible });
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
setOpacity(opacity) {
|
|
1666
|
+
this.options = { ...this.options, opacity };
|
|
1667
|
+
if (this.handle && this.currentMap) {
|
|
1668
|
+
this.currentMap._adapter().updateMarker(this.handle, { opacity });
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
setZIndex(zIndex) {
|
|
1672
|
+
this.options = { ...this.options, zIndex };
|
|
1673
|
+
if (this.handle && this.currentMap) {
|
|
1674
|
+
this.currentMap._adapter().updateMarker(this.handle, { zIndex });
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
setDraggable(draggable) {
|
|
1678
|
+
this.options = { ...this.options, draggable };
|
|
1679
|
+
if (this.handle && this.currentMap) {
|
|
1680
|
+
this.currentMap._adapter().updateMarker(this.handle, { draggable });
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
setIcon(icon) {
|
|
1684
|
+
this.options = { ...this.options, icon };
|
|
1685
|
+
if (this.handle && this.currentMap) {
|
|
1686
|
+
this.currentMap._adapter().updateMarker(this.handle, { icon });
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
setOptions(options) {
|
|
1690
|
+
this.options = { ...this.options, ...options };
|
|
1691
|
+
if (this.handle && this.currentMap) {
|
|
1692
|
+
this.currentMap._adapter().updateMarker(this.handle, options);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
on(event, handler) {
|
|
1696
|
+
if (!this.handle || !this.currentMap) return null;
|
|
1697
|
+
return this.currentMap._adapter().addMarkerEvent(this.handle, event, handler);
|
|
1698
|
+
}
|
|
1699
|
+
off(event, listener) {
|
|
1700
|
+
if (!this.handle || !this.currentMap) return;
|
|
1701
|
+
this.currentMap._adapter().removeMarkerEvent(this.handle, event, listener);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
var InfoWindow = class {
|
|
1705
|
+
constructor(options) {
|
|
1706
|
+
this.options = options;
|
|
1707
|
+
}
|
|
1708
|
+
handle = null;
|
|
1709
|
+
currentMap = null;
|
|
1710
|
+
open(map, anchor) {
|
|
1711
|
+
if (this.handle && this.currentMap) this.close();
|
|
1712
|
+
const markerHandle = anchor ? anchor.handle : void 0;
|
|
1713
|
+
this.handle = map._adapter().openInfoWindow(this.options, markerHandle ?? void 0);
|
|
1714
|
+
this.currentMap = map;
|
|
1715
|
+
}
|
|
1716
|
+
close() {
|
|
1717
|
+
if (this.handle && this.currentMap) {
|
|
1718
|
+
this.currentMap._adapter().closeInfoWindow(this.handle);
|
|
1719
|
+
this.handle = null;
|
|
1720
|
+
this.currentMap = null;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
setContent(content) {
|
|
1724
|
+
this.options = { ...this.options, content };
|
|
1725
|
+
if (this.handle && this.currentMap) {
|
|
1726
|
+
this.currentMap._adapter().updateInfoWindow(this.handle, { content });
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
getContent() {
|
|
1730
|
+
return this.options.content;
|
|
1731
|
+
}
|
|
1732
|
+
setPosition(latlng) {
|
|
1733
|
+
this.options = { ...this.options, position: latlng };
|
|
1734
|
+
if (this.handle && this.currentMap) {
|
|
1735
|
+
this.currentMap._adapter().updateInfoWindow(this.handle, { position: latlng });
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
isOpen() {
|
|
1739
|
+
if (!this.handle || !this.currentMap) return false;
|
|
1740
|
+
return this.currentMap._adapter().isInfoWindowOpen(this.handle);
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
var Polyline = class {
|
|
1744
|
+
constructor(options) {
|
|
1745
|
+
this.options = options;
|
|
1746
|
+
}
|
|
1747
|
+
handle = null;
|
|
1748
|
+
currentMap = null;
|
|
1749
|
+
setMap(map) {
|
|
1750
|
+
if (this.currentMap && this.handle) {
|
|
1751
|
+
this.currentMap._adapter().removePolyline(this.handle);
|
|
1752
|
+
this.handle = null;
|
|
1753
|
+
this.currentMap = null;
|
|
1754
|
+
}
|
|
1755
|
+
if (map) {
|
|
1756
|
+
this.handle = map._adapter().addPolyline(this.options);
|
|
1757
|
+
this.currentMap = map;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
setOptions(options) {
|
|
1761
|
+
this.options = { ...this.options, ...options };
|
|
1762
|
+
if (this.handle && this.currentMap) {
|
|
1763
|
+
this.currentMap._adapter().updatePolyline(this.handle, options);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
var Polygon = class {
|
|
1768
|
+
constructor(options) {
|
|
1769
|
+
this.options = options;
|
|
1770
|
+
}
|
|
1771
|
+
handle = null;
|
|
1772
|
+
currentMap = null;
|
|
1773
|
+
setMap(map) {
|
|
1774
|
+
if (this.currentMap && this.handle) {
|
|
1775
|
+
this.currentMap._adapter().removePolygon(this.handle);
|
|
1776
|
+
this.handle = null;
|
|
1777
|
+
this.currentMap = null;
|
|
1778
|
+
}
|
|
1779
|
+
if (map) {
|
|
1780
|
+
this.handle = map._adapter().addPolygon(this.options);
|
|
1781
|
+
this.currentMap = map;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
setOptions(options) {
|
|
1785
|
+
this.options = { ...this.options, ...options };
|
|
1786
|
+
if (this.handle && this.currentMap) {
|
|
1787
|
+
this.currentMap._adapter().updatePolygon(this.handle, options);
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
var Circle = class {
|
|
1792
|
+
constructor(options) {
|
|
1793
|
+
this.options = options;
|
|
1794
|
+
}
|
|
1795
|
+
handle = null;
|
|
1796
|
+
currentMap = null;
|
|
1797
|
+
setMap(map) {
|
|
1798
|
+
if (this.currentMap && this.handle) {
|
|
1799
|
+
this.currentMap._adapter().removeCircle(this.handle);
|
|
1800
|
+
this.handle = null;
|
|
1801
|
+
this.currentMap = null;
|
|
1802
|
+
}
|
|
1803
|
+
if (map) {
|
|
1804
|
+
this.handle = map._adapter().addCircle(this.options);
|
|
1805
|
+
this.currentMap = map;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
setOptions(options) {
|
|
1809
|
+
this.options = { ...this.options, ...options };
|
|
1810
|
+
if (this.handle && this.currentMap) {
|
|
1811
|
+
this.currentMap._adapter().updateCircle(this.handle, options);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
var Rectangle = class {
|
|
1816
|
+
constructor(options) {
|
|
1817
|
+
this.options = options;
|
|
1818
|
+
}
|
|
1819
|
+
handle = null;
|
|
1820
|
+
currentMap = null;
|
|
1821
|
+
setMap(map) {
|
|
1822
|
+
if (this.currentMap && this.handle) {
|
|
1823
|
+
this.currentMap._adapter().removeRectangle(this.handle);
|
|
1824
|
+
this.handle = null;
|
|
1825
|
+
this.currentMap = null;
|
|
1826
|
+
}
|
|
1827
|
+
if (map) {
|
|
1828
|
+
this.handle = map._adapter().addRectangle(this.options);
|
|
1829
|
+
this.currentMap = map;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
setOptions(options) {
|
|
1833
|
+
this.options = { ...this.options, ...options };
|
|
1834
|
+
if (this.handle && this.currentMap) {
|
|
1835
|
+
this.currentMap._adapter().updateRectangle(this.handle, options);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
var CustomOverlay = class {
|
|
1840
|
+
constructor(options) {
|
|
1841
|
+
this.options = options;
|
|
1842
|
+
}
|
|
1843
|
+
handle = null;
|
|
1844
|
+
currentMap = null;
|
|
1845
|
+
setMap(map) {
|
|
1846
|
+
if (this.currentMap && this.handle) {
|
|
1847
|
+
this.currentMap._adapter().removeCustomOverlay(this.handle);
|
|
1848
|
+
this.handle = null;
|
|
1849
|
+
this.currentMap = null;
|
|
1850
|
+
}
|
|
1851
|
+
if (map) {
|
|
1852
|
+
this.handle = map._adapter().addCustomOverlay(this.options);
|
|
1853
|
+
this.currentMap = map;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
setPosition(latlng) {
|
|
1857
|
+
this.options = { ...this.options, position: latlng };
|
|
1858
|
+
}
|
|
1859
|
+
getPosition() {
|
|
1860
|
+
return this.options.position;
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
var TileLayer = class {
|
|
1864
|
+
constructor(options) {
|
|
1865
|
+
this.options = options;
|
|
1866
|
+
}
|
|
1867
|
+
handle = null;
|
|
1868
|
+
currentMap = null;
|
|
1869
|
+
setMap(map) {
|
|
1870
|
+
if (this.currentMap && this.handle) {
|
|
1871
|
+
this.currentMap._adapter().removeTileLayer(this.handle);
|
|
1872
|
+
this.handle = null;
|
|
1873
|
+
this.currentMap = null;
|
|
1874
|
+
}
|
|
1875
|
+
if (map) {
|
|
1876
|
+
this.handle = map._adapter().addTileLayer(this.options);
|
|
1877
|
+
this.currentMap = map;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
|
|
1882
|
+
export { Circle, ConfigurationError, CustomOverlay, InfoWindow, KorMap, KorMapError, Marker, Polygon, Polyline, ProviderLoadError, ProviderNotSupportedError, Rectangle, TileLayer };
|
|
1883
|
+
//# sourceMappingURL=chunk-222QLGRB.js.map
|
|
1884
|
+
//# sourceMappingURL=chunk-222QLGRB.js.map
|