@local-logic/maps 0.0.19 → 0.0.21

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 (38) hide show
  1. package/dist/index-29Y5fJR0.js +24 -0
  2. package/dist/{index-DnE7POcz.js → index-6JzOJU8O.js} +1 -1
  3. package/dist/{index-C_RtwL3E.js → index-AcZakyxd.js} +5 -5
  4. package/dist/{index-r9nwo0R7.js → index-CHSsiFtN.js} +1 -1
  5. package/dist/{index-DUdSU2pv.js → index-CqUTGwL0.js} +2 -2
  6. package/dist/{index-Be6RGKzc.js → index-Cwn0dgP_.js} +3 -3
  7. package/dist/{index-C1QREXT1.js → index-D--WdzK4.js} +2 -2
  8. package/dist/{index-DMwjyhBt.js → index-D1Phs0fA.js} +2 -2
  9. package/dist/{index-pztBT1mz.js → index-D1vI6Ww_.js} +1 -1
  10. package/dist/{index-Dvg9jDs5.js → index-DHHG0vNa.js} +1 -1
  11. package/dist/{index-C0nB-ZYI.js → index-DKFcZs0A.js} +2 -2
  12. package/dist/{index-CBfuS_n2.js → index-DZTFM839.js} +1 -1
  13. package/dist/index-DdYanSGw.js +23 -0
  14. package/dist/index-Dxh7aMoG.js +23 -0
  15. package/dist/{index-C9z8YU4t.js → index-_8n5sl1B.js} +3 -3
  16. package/dist/{index-gTk5Txmy.js → index-_n1FGHXc.js} +2 -2
  17. package/dist/index.es.js +1 -1
  18. package/dist/index.umd.js +305 -206
  19. package/dist/{logo-control-BALqfBGo.js → logo-control-C5ZdRec5.js} +1 -1
  20. package/dist/{mapbox-gl-Coz2msiN.js → mapbox-gl-D6JObe4m.js} +15957 -15589
  21. package/dist/{maplibre-gl-CAHhS7Ky.js → maplibre-gl-DDfJU6SR.js} +7506 -7216
  22. package/dist/scale-control-Cflgzbvb.js +744 -0
  23. package/dist/src/components/Map/Root/CenterPin/Google/index.d.ts +1 -1
  24. package/dist/src/components/Map/Root/CenterPin/Google/index.d.ts.map +1 -1
  25. package/dist/src/components/Map/Root/CenterPin/Mapbox/index.d.ts +1 -1
  26. package/dist/src/components/Map/Root/CenterPin/Mapbox/index.d.ts.map +1 -1
  27. package/dist/src/components/Map/Root/CenterPin/Maptiler/index.d.ts +1 -1
  28. package/dist/src/components/Map/Root/CenterPin/Maptiler/index.d.ts.map +1 -1
  29. package/dist/src/components/Map/Root/CenterPin/types.d.ts +1 -0
  30. package/dist/src/components/Map/Root/CenterPin/types.d.ts.map +1 -1
  31. package/dist/style.css +1 -1
  32. package/dist/styles-B8oT_wcC.js +2772 -0
  33. package/package.json +5 -4
  34. package/dist/index-C7cTTXxY.js +0 -24
  35. package/dist/index-DjQpPQGI.js +0 -23
  36. package/dist/index-t8m-nFSa.js +0 -23
  37. package/dist/scale-control-BOI2g14-.js +0 -726
  38. package/dist/styles-Do-o-qNU.js +0 -48
@@ -1,726 +0,0 @@
1
- import * as E from "react";
2
- import { useContext as T, useMemo as M, useLayoutEffect as K, useEffect as m, useState as $, useRef as b, useImperativeHandle as z, memo as L, forwardRef as A } from "react";
3
- import { createPortal as q } from "react-dom";
4
- const I = E.createContext(null);
5
- function _t() {
6
- var r;
7
- const t = (r = T(I)) == null ? void 0 : r.maps, e = T(R);
8
- return M(() => ({ ...t, current: e == null ? void 0 : e.map }), [t, e]);
9
- }
10
- function J(t, e) {
11
- const n = Array.isArray(t) ? t[0] : t ? t.x : 0, r = Array.isArray(t) ? t[1] : t ? t.y : 0, o = Array.isArray(e) ? e[0] : e ? e.x : 0, i = Array.isArray(e) ? e[1] : e ? e.y : 0;
12
- return n === o && r === i;
13
- }
14
- function _(t, e) {
15
- if (t === e)
16
- return !0;
17
- if (!t || !e)
18
- return !1;
19
- if (Array.isArray(t)) {
20
- if (!Array.isArray(e) || t.length !== e.length)
21
- return !1;
22
- for (let n = 0; n < t.length; n++)
23
- if (!_(t[n], e[n]))
24
- return !1;
25
- return !0;
26
- } else if (Array.isArray(e))
27
- return !1;
28
- if (typeof t == "object" && typeof e == "object") {
29
- const n = Object.keys(t), r = Object.keys(e);
30
- if (n.length !== r.length)
31
- return !1;
32
- for (const o of n)
33
- if (!e.hasOwnProperty(o) || !_(t[o], e[o]))
34
- return !1;
35
- return !0;
36
- }
37
- return !1;
38
- }
39
- function Y(t) {
40
- const e = t.clone();
41
- return e.pixelsToGLUnits = t.pixelsToGLUnits, e;
42
- }
43
- function O(t, e) {
44
- if (!t.getProjection)
45
- return;
46
- const n = t.getProjection(), r = e.getProjection();
47
- _(n, r) || e.setProjection(n);
48
- }
49
- function j(t) {
50
- return {
51
- longitude: t.center.lng,
52
- latitude: t.center.lat,
53
- zoom: t.zoom,
54
- pitch: t.pitch,
55
- bearing: t.bearing,
56
- padding: t.padding
57
- };
58
- }
59
- function D(t, e) {
60
- const n = e.viewState || e;
61
- let r = !1;
62
- if ("zoom" in n) {
63
- const o = t.zoom;
64
- t.zoom = n.zoom, r = r || o !== t.zoom;
65
- }
66
- if ("bearing" in n) {
67
- const o = t.bearing;
68
- t.bearing = n.bearing, r = r || o !== t.bearing;
69
- }
70
- if ("pitch" in n) {
71
- const o = t.pitch;
72
- t.pitch = n.pitch, r = r || o !== t.pitch;
73
- }
74
- if (n.padding && !t.isPaddingEqual(n.padding) && (r = !0, t.padding = n.padding), "longitude" in n && "latitude" in n) {
75
- const o = t.center;
76
- t.center = new o.constructor(n.longitude, n.latitude), r = r || o !== t.center;
77
- }
78
- return r;
79
- }
80
- const X = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
81
- function U(t) {
82
- if (!t)
83
- return null;
84
- if (typeof t == "string" || ("toJS" in t && (t = t.toJS()), !t.layers))
85
- return t;
86
- const e = {};
87
- for (const r of t.layers)
88
- e[r.id] = r;
89
- const n = t.layers.map((r) => {
90
- let o = null;
91
- "interactive" in r && (o = Object.assign({}, r), delete o.interactive);
92
- const i = e[r.ref];
93
- if (i) {
94
- o = o || Object.assign({}, r), delete o.ref;
95
- for (const s of X)
96
- s in i && (o[s] = i[s]);
97
- }
98
- return o || r;
99
- });
100
- return { ...t, layers: n };
101
- }
102
- const Z = { version: 8, sources: {}, layers: [] }, B = {
103
- mousedown: "onMouseDown",
104
- mouseup: "onMouseUp",
105
- mouseover: "onMouseOver",
106
- mousemove: "onMouseMove",
107
- click: "onClick",
108
- dblclick: "onDblClick",
109
- mouseenter: "onMouseEnter",
110
- mouseleave: "onMouseLeave",
111
- mouseout: "onMouseOut",
112
- contextmenu: "onContextMenu",
113
- touchstart: "onTouchStart",
114
- touchend: "onTouchEnd",
115
- touchmove: "onTouchMove",
116
- touchcancel: "onTouchCancel"
117
- }, P = {
118
- movestart: "onMoveStart",
119
- move: "onMove",
120
- moveend: "onMoveEnd",
121
- dragstart: "onDragStart",
122
- drag: "onDrag",
123
- dragend: "onDragEnd",
124
- zoomstart: "onZoomStart",
125
- zoom: "onZoom",
126
- zoomend: "onZoomEnd",
127
- rotatestart: "onRotateStart",
128
- rotate: "onRotate",
129
- rotateend: "onRotateEnd",
130
- pitchstart: "onPitchStart",
131
- pitch: "onPitch",
132
- pitchend: "onPitchEnd"
133
- }, W = {
134
- wheel: "onWheel",
135
- boxzoomstart: "onBoxZoomStart",
136
- boxzoomend: "onBoxZoomEnd",
137
- boxzoomcancel: "onBoxZoomCancel",
138
- resize: "onResize",
139
- load: "onLoad",
140
- render: "onRender",
141
- idle: "onIdle",
142
- remove: "onRemove",
143
- data: "onData",
144
- styledata: "onStyleData",
145
- sourcedata: "onSourceData",
146
- error: "onError"
147
- }, tt = [
148
- "minZoom",
149
- "maxZoom",
150
- "minPitch",
151
- "maxPitch",
152
- "maxBounds",
153
- "projection",
154
- "renderWorldCopies"
155
- ], et = [
156
- "scrollZoom",
157
- "boxZoom",
158
- "dragRotate",
159
- "dragPan",
160
- "keyboard",
161
- "doubleClickZoom",
162
- "touchZoomRotate",
163
- "touchPitch"
164
- ];
165
- class w {
166
- constructor(e, n, r) {
167
- this._map = null, this._internalUpdate = !1, this._inRender = !1, this._hoveredFeatures = null, this._deferredEvents = {
168
- move: !1,
169
- zoom: !1,
170
- pitch: !1,
171
- rotate: !1
172
- }, this._onEvent = (o) => {
173
- const i = this.props[W[o.type]];
174
- i ? i(o) : o.type === "error" && console.error(o.error);
175
- }, this._onPointerEvent = (o) => {
176
- (o.type === "mousemove" || o.type === "mouseout") && this._updateHover(o);
177
- const i = this.props[B[o.type]];
178
- i && (this.props.interactiveLayerIds && o.type !== "mouseover" && o.type !== "mouseout" && (o.features = this._hoveredFeatures || this._queryRenderedFeatures(o.point)), i(o), delete o.features);
179
- }, this._onCameraEvent = (o) => {
180
- if (!this._internalUpdate) {
181
- const i = this.props[P[o.type]];
182
- i && i(o);
183
- }
184
- o.type in this._deferredEvents && (this._deferredEvents[o.type] = !1);
185
- }, this._MapClass = e, this.props = n, this._initialize(r);
186
- }
187
- get map() {
188
- return this._map;
189
- }
190
- get transform() {
191
- return this._renderTransform;
192
- }
193
- setProps(e) {
194
- const n = this.props;
195
- this.props = e;
196
- const r = this._updateSettings(e, n);
197
- r && this._createShadowTransform(this._map);
198
- const o = this._updateSize(e), i = this._updateViewState(e, !0);
199
- this._updateStyle(e, n), this._updateStyleComponents(e, n), this._updateHandlers(e, n), (r || o || i && !this._map.isMoving()) && this.redraw();
200
- }
201
- static reuse(e, n) {
202
- const r = w.savedMaps.pop();
203
- if (!r)
204
- return null;
205
- const o = r.map, i = o.getContainer();
206
- for (n.className = i.className; i.childNodes.length > 0; )
207
- n.appendChild(i.childNodes[0]);
208
- o._container = n, r.setProps({ ...e, styleDiffing: !1 }), o.resize();
209
- const { initialViewState: s } = e;
210
- return s && (s.bounds ? o.fitBounds(s.bounds, { ...s.fitBoundsOptions, duration: 0 }) : r._updateViewState(s, !1)), o.isStyleLoaded() ? o.fire("load") : o.once("styledata", () => o.fire("load")), o._update(), r;
211
- }
212
- /* eslint-disable complexity,max-statements */
213
- _initialize(e) {
214
- const { props: n } = this, { mapStyle: r = Z } = n, o = {
215
- ...n,
216
- ...n.initialViewState,
217
- accessToken: n.mapboxAccessToken || nt() || null,
218
- container: e,
219
- style: U(r)
220
- }, i = o.initialViewState || o.viewState || o;
221
- if (Object.assign(o, {
222
- center: [i.longitude || 0, i.latitude || 0],
223
- zoom: i.zoom || 0,
224
- pitch: i.pitch || 0,
225
- bearing: i.bearing || 0
226
- }), n.gl) {
227
- const u = HTMLCanvasElement.prototype.getContext;
228
- HTMLCanvasElement.prototype.getContext = () => (HTMLCanvasElement.prototype.getContext = u, n.gl);
229
- }
230
- const s = new this._MapClass(o);
231
- i.padding && s.setPadding(i.padding), n.cursor && (s.getCanvas().style.cursor = n.cursor), this._createShadowTransform(s);
232
- const c = s._render;
233
- s._render = (u) => {
234
- this._inRender = !0, c.call(s, u), this._inRender = !1;
235
- };
236
- const a = s._renderTaskQueue.run;
237
- s._renderTaskQueue.run = (u) => {
238
- a.call(s._renderTaskQueue, u), this._onBeforeRepaint();
239
- }, s.on("render", () => this._onAfterRepaint());
240
- const l = s.fire;
241
- s.fire = this._fireEvent.bind(this, l), s.on("resize", () => {
242
- this._renderTransform.resize(s.transform.width, s.transform.height);
243
- }), s.on("styledata", () => {
244
- this._updateStyleComponents(this.props, {}), O(s.transform, this._renderTransform);
245
- }), s.on("sourcedata", () => this._updateStyleComponents(this.props, {}));
246
- for (const u in B)
247
- s.on(u, this._onPointerEvent);
248
- for (const u in P)
249
- s.on(u, this._onCameraEvent);
250
- for (const u in W)
251
- s.on(u, this._onEvent);
252
- this._map = s;
253
- }
254
- /* eslint-enable complexity,max-statements */
255
- recycle() {
256
- const n = this.map.getContainer().querySelector("[mapboxgl-children]");
257
- n == null || n.remove(), w.savedMaps.push(this);
258
- }
259
- destroy() {
260
- this._map.remove();
261
- }
262
- // Force redraw the map now. Typically resize() and jumpTo() is reflected in the next
263
- // render cycle, which is managed by Mapbox's animation loop.
264
- // This removes the synchronization issue caused by requestAnimationFrame.
265
- redraw() {
266
- const e = this._map;
267
- !this._inRender && e.style && (e._frame && (e._frame.cancel(), e._frame = null), e._render());
268
- }
269
- _createShadowTransform(e) {
270
- const n = Y(e.transform);
271
- e.painter.transform = n, this._renderTransform = n;
272
- }
273
- /* Trigger map resize if size is controlled
274
- @param {object} nextProps
275
- @returns {bool} true if size has changed
276
- */
277
- _updateSize(e) {
278
- const { viewState: n } = e;
279
- if (n) {
280
- const r = this._map;
281
- if (n.width !== r.transform.width || n.height !== r.transform.height)
282
- return r.resize(), !0;
283
- }
284
- return !1;
285
- }
286
- // Adapted from map.jumpTo
287
- /* Update camera to match props
288
- @param {object} nextProps
289
- @param {bool} triggerEvents - should fire camera events
290
- @returns {bool} true if anything is changed
291
- */
292
- _updateViewState(e, n) {
293
- if (this._internalUpdate)
294
- return !1;
295
- const r = this._map, o = this._renderTransform, { zoom: i, pitch: s, bearing: c } = o, a = r.isMoving();
296
- a && (o.cameraElevationReference = "sea");
297
- const l = D(o, {
298
- ...j(r.transform),
299
- ...e
300
- });
301
- if (a && (o.cameraElevationReference = "ground"), l && n) {
302
- const u = this._deferredEvents;
303
- u.move = !0, u.zoom || (u.zoom = i !== o.zoom), u.rotate || (u.rotate = c !== o.bearing), u.pitch || (u.pitch = s !== o.pitch);
304
- }
305
- return a || D(r.transform, e), l;
306
- }
307
- /* Update camera constraints and projection settings to match props
308
- @param {object} nextProps
309
- @param {object} currProps
310
- @returns {bool} true if anything is changed
311
- */
312
- _updateSettings(e, n) {
313
- const r = this._map;
314
- let o = !1;
315
- for (const i of tt)
316
- if (i in e && !_(e[i], n[i])) {
317
- o = !0;
318
- const s = r[`set${i[0].toUpperCase()}${i.slice(1)}`];
319
- s == null || s.call(r, e[i]);
320
- }
321
- return o;
322
- }
323
- /* Update map style to match props
324
- @param {object} nextProps
325
- @param {object} currProps
326
- @returns {bool} true if style is changed
327
- */
328
- _updateStyle(e, n) {
329
- if (e.cursor !== n.cursor && (this._map.getCanvas().style.cursor = e.cursor || ""), e.mapStyle !== n.mapStyle) {
330
- const { mapStyle: r = Z, styleDiffing: o = !0 } = e, i = {
331
- diff: o
332
- };
333
- return "localIdeographFontFamily" in e && (i.localIdeographFontFamily = e.localIdeographFontFamily), this._map.setStyle(U(r), i), !0;
334
- }
335
- return !1;
336
- }
337
- /* Update fog, light and terrain to match props
338
- @param {object} nextProps
339
- @param {object} currProps
340
- @returns {bool} true if anything is changed
341
- */
342
- _updateStyleComponents(e, n) {
343
- const r = this._map;
344
- let o = !1;
345
- return r.isStyleLoaded() && ("light" in e && r.setLight && !_(e.light, n.light) && (o = !0, r.setLight(e.light)), "fog" in e && r.setFog && !_(e.fog, n.fog) && (o = !0, r.setFog(e.fog)), "terrain" in e && r.setTerrain && !_(e.terrain, n.terrain) && (!e.terrain || r.getSource(e.terrain.source)) && (o = !0, r.setTerrain(e.terrain))), o;
346
- }
347
- /* Update interaction handlers to match props
348
- @param {object} nextProps
349
- @param {object} currProps
350
- @returns {bool} true if anything is changed
351
- */
352
- _updateHandlers(e, n) {
353
- const r = this._map;
354
- let o = !1;
355
- for (const i of et) {
356
- const s = e[i] ?? !0, c = n[i] ?? !0;
357
- _(s, c) || (o = !0, s ? r[i].enable(s) : r[i].disable());
358
- }
359
- return o;
360
- }
361
- _queryRenderedFeatures(e) {
362
- const n = this._map, r = n.transform, { interactiveLayerIds: o = [] } = this.props;
363
- try {
364
- return n.transform = this._renderTransform, n.queryRenderedFeatures(e, {
365
- layers: o.filter(n.getLayer.bind(n))
366
- });
367
- } catch {
368
- return [];
369
- } finally {
370
- n.transform = r;
371
- }
372
- }
373
- _updateHover(e) {
374
- var o;
375
- const { props: n } = this;
376
- if (n.interactiveLayerIds && (n.onMouseMove || n.onMouseEnter || n.onMouseLeave)) {
377
- const i = e.type, s = ((o = this._hoveredFeatures) == null ? void 0 : o.length) > 0, c = this._queryRenderedFeatures(e.point), a = c.length > 0;
378
- !a && s && (e.type = "mouseleave", this._onPointerEvent(e)), this._hoveredFeatures = c, a && !s && (e.type = "mouseenter", this._onPointerEvent(e)), e.type = i;
379
- } else
380
- this._hoveredFeatures = null;
381
- }
382
- _fireEvent(e, n, r) {
383
- const o = this._map, i = o.transform, s = typeof n == "string" ? n : n.type;
384
- return s === "move" && this._updateViewState(this.props, !1), s in P && (typeof n == "object" && (n.viewState = j(i)), this._map.isMoving()) ? (o.transform = this._renderTransform, e.call(o, n, r), o.transform = i, o) : (e.call(o, n, r), o);
385
- }
386
- // All camera manipulations are complete, ready to repaint
387
- _onBeforeRepaint() {
388
- const e = this._map;
389
- this._internalUpdate = !0;
390
- for (const r in this._deferredEvents)
391
- this._deferredEvents[r] && e.fire(r);
392
- this._internalUpdate = !1;
393
- const n = this._map.transform;
394
- e.transform = this._renderTransform, this._onAfterRepaint = () => {
395
- O(this._renderTransform, n), e.transform = n;
396
- };
397
- }
398
- }
399
- w.savedMaps = [];
400
- function nt() {
401
- let t = null;
402
- if (typeof location < "u") {
403
- const e = /access_token=([^&\/]*)/.exec(location.search);
404
- t = e && e[1];
405
- }
406
- try {
407
- t = t || process.env.MapboxAccessToken;
408
- } catch {
409
- }
410
- try {
411
- t = t || process.env.REACT_APP_MAPBOX_ACCESS_TOKEN;
412
- } catch {
413
- }
414
- return t;
415
- }
416
- const ot = [
417
- "setMaxBounds",
418
- "setMinZoom",
419
- "setMaxZoom",
420
- "setMinPitch",
421
- "setMaxPitch",
422
- "setRenderWorldCopies",
423
- "setProjection",
424
- "setStyle",
425
- "addSource",
426
- "removeSource",
427
- "addLayer",
428
- "removeLayer",
429
- "setLayerZoomRange",
430
- "setFilter",
431
- "setPaintProperty",
432
- "setLayoutProperty",
433
- "setLight",
434
- "setTerrain",
435
- "setFog",
436
- "remove"
437
- ];
438
- function rt(t) {
439
- if (!t)
440
- return null;
441
- const e = t.map, n = {
442
- getMap: () => e,
443
- // Overwrite getters to use our shadow transform
444
- getCenter: () => t.transform.center,
445
- getZoom: () => t.transform.zoom,
446
- getBearing: () => t.transform.bearing,
447
- getPitch: () => t.transform.pitch,
448
- getPadding: () => t.transform.padding,
449
- getBounds: () => t.transform.getBounds(),
450
- project: (r) => {
451
- const o = e.transform;
452
- e.transform = t.transform;
453
- const i = e.project(r);
454
- return e.transform = o, i;
455
- },
456
- unproject: (r) => {
457
- const o = e.transform;
458
- e.transform = t.transform;
459
- const i = e.unproject(r);
460
- return e.transform = o, i;
461
- },
462
- // options diverge between mapbox and maplibre
463
- queryTerrainElevation: (r, o) => {
464
- const i = e.transform;
465
- e.transform = t.transform;
466
- const s = e.queryTerrainElevation(r, o);
467
- return e.transform = i, s;
468
- },
469
- queryRenderedFeatures: (r, o) => {
470
- const i = e.transform;
471
- e.transform = t.transform;
472
- const s = e.queryRenderedFeatures(r, o);
473
- return e.transform = i, s;
474
- }
475
- };
476
- for (const r of it(e))
477
- !(r in n) && !ot.includes(r) && (n[r] = e[r].bind(e));
478
- return n;
479
- }
480
- function it(t) {
481
- const e = /* @__PURE__ */ new Set();
482
- let n = t;
483
- for (; n; ) {
484
- for (const r of Object.getOwnPropertyNames(n))
485
- r[0] !== "_" && typeof t[r] == "function" && r !== "fire" && r !== "setEventedParent" && e.add(r);
486
- n = Object.getPrototypeOf(n);
487
- }
488
- return Array.from(e);
489
- }
490
- const st = typeof document < "u" ? K : m, at = [
491
- "baseApiUrl",
492
- "maxParallelImageRequests",
493
- "workerClass",
494
- "workerCount",
495
- "workerUrl"
496
- ];
497
- function ct(t, e) {
498
- for (const r of at)
499
- r in e && (t[r] = e[r]);
500
- const { RTLTextPlugin: n = "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js" } = e;
501
- n && t.getRTLTextPluginStatus && t.getRTLTextPluginStatus() === "unavailable" && t.setRTLTextPlugin(n, (r) => {
502
- r && console.error(r);
503
- }, !0);
504
- }
505
- const R = E.createContext(null);
506
- function lt(t, e) {
507
- const n = T(I), [r, o] = $(null), i = b(), { current: s } = b({ mapLib: null, map: null });
508
- m(() => {
509
- const l = t.mapLib;
510
- let u = !0, f;
511
- return Promise.resolve(l || import("./mapbox-gl-Coz2msiN.js").then((d) => d.m)).then((d) => {
512
- if (!u)
513
- return;
514
- if (!d)
515
- throw new Error("Invalid mapLib");
516
- const p = "Map" in d ? d : d.default;
517
- if (!p.Map)
518
- throw new Error("Invalid mapLib");
519
- ct(p, t), t.reuseMaps && (f = w.reuse(t, i.current)), f || (f = new w(p.Map, t, i.current)), s.map = rt(f), s.mapLib = p, o(f), n == null || n.onMapMount(s.map, t.id);
520
- }).catch((d) => {
521
- const { onError: p } = t;
522
- p ? p({
523
- type: "error",
524
- target: null,
525
- error: d
526
- }) : console.error(d);
527
- }), () => {
528
- u = !1, f && (n == null || n.onMapUnmount(t.id), t.reuseMaps ? f.recycle() : f.destroy());
529
- };
530
- }, []), st(() => {
531
- r && r.setProps(t);
532
- }), z(e, () => s.map, [r]);
533
- const c = M(() => ({
534
- position: "relative",
535
- width: "100%",
536
- height: "100%",
537
- ...t.style
538
- }), [t.style]), a = {
539
- height: "100%"
540
- };
541
- return E.createElement("div", { id: t.id, ref: i, style: c }, r && E.createElement(
542
- R.Provider,
543
- { value: s },
544
- E.createElement("div", { "mapboxgl-children": "", style: a }, t.children)
545
- ));
546
- }
547
- const vt = E.forwardRef(lt), ut = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
548
- function S(t, e) {
549
- if (!t || !e)
550
- return;
551
- const n = t.style;
552
- for (const r in e) {
553
- const o = e[r];
554
- Number.isFinite(o) && !ut.test(r) ? n[r] = `${o}px` : n[r] = o;
555
- }
556
- }
557
- function V(t, e) {
558
- if (t === e)
559
- return null;
560
- const n = H(t), r = H(e), o = [];
561
- for (const i of r)
562
- n.has(i) || o.push(i);
563
- for (const i of n)
564
- r.has(i) || o.push(i);
565
- return o.length === 0 ? null : o;
566
- }
567
- function H(t) {
568
- return new Set(t ? t.trim().split(/\s+/) : []);
569
- }
570
- const Ct = L(A((t, e) => {
571
- const { map: n, mapLib: r } = T(R), o = b({ props: t }), i = M(() => {
572
- let k = !1;
573
- E.Children.forEach(t.children, (y) => {
574
- y && (k = !0);
575
- });
576
- const Q = {
577
- ...t,
578
- element: k ? document.createElement("div") : null
579
- }, C = new r.Marker(Q);
580
- return C.setLngLat([t.longitude, t.latitude]), C.getElement().addEventListener("click", (y) => {
581
- var h, g;
582
- (g = (h = o.current.props).onClick) == null || g.call(h, {
583
- type: "click",
584
- target: C,
585
- originalEvent: y
586
- });
587
- }), C.on("dragstart", (y) => {
588
- var g, v;
589
- const h = y;
590
- h.lngLat = i.getLngLat(), (v = (g = o.current.props).onDragStart) == null || v.call(g, h);
591
- }), C.on("drag", (y) => {
592
- var g, v;
593
- const h = y;
594
- h.lngLat = i.getLngLat(), (v = (g = o.current.props).onDrag) == null || v.call(g, h);
595
- }), C.on("dragend", (y) => {
596
- var g, v;
597
- const h = y;
598
- h.lngLat = i.getLngLat(), (v = (g = o.current.props).onDragEnd) == null || v.call(g, h);
599
- }), C;
600
- }, []);
601
- m(() => (i.addTo(n.getMap()), () => {
602
- i.remove();
603
- }), []);
604
- const { longitude: s, latitude: c, offset: a, style: l, draggable: u = !1, popup: f = null, rotation: d = 0, rotationAlignment: p = "auto", pitchAlignment: N = "auto" } = t;
605
- m(() => {
606
- S(i.getElement(), l);
607
- }, [l]), z(e, () => i, []);
608
- const G = o.current.props;
609
- (i.getLngLat().lng !== s || i.getLngLat().lat !== c) && i.setLngLat([s, c]), a && !J(i.getOffset(), a) && i.setOffset(a), i.isDraggable() !== u && i.setDraggable(u), i.getRotation() !== d && i.setRotation(d), i.getRotationAlignment() !== p && i.setRotationAlignment(p), i.getPitchAlignment() !== N && i.setPitchAlignment(N), i.getPopup() !== f && i.setPopup(f);
610
- const F = V(G.className, t.className);
611
- if (F)
612
- for (const k of F)
613
- i.toggleClassName(k);
614
- return o.current.props = t, q(t.children, i.getElement());
615
- })), Et = L(A((t, e) => {
616
- const { map: n, mapLib: r } = T(R), o = M(() => document.createElement("div"), []), i = b({ props: t }), s = M(() => {
617
- const c = { ...t }, a = new r.Popup(c);
618
- return a.setLngLat([t.longitude, t.latitude]), a.once("open", (l) => {
619
- var u, f;
620
- (f = (u = i.current.props).onOpen) == null || f.call(u, l);
621
- }), a;
622
- }, []);
623
- if (m(() => {
624
- const c = (a) => {
625
- var l, u;
626
- (u = (l = i.current.props).onClose) == null || u.call(l, a);
627
- };
628
- return s.on("close", c), s.setDOMContent(o).addTo(n.getMap()), () => {
629
- s.off("close", c), s.isOpen() && s.remove();
630
- };
631
- }, []), m(() => {
632
- S(s.getElement(), t.style);
633
- }, [t.style]), z(e, () => s, []), s.isOpen()) {
634
- const c = i.current.props;
635
- (s.getLngLat().lng !== t.longitude || s.getLngLat().lat !== t.latitude) && s.setLngLat([t.longitude, t.latitude]), t.offset && !_(c.offset, t.offset) && (s.options.anchor = t.anchor, s.setOffset(t.offset)), (c.anchor !== t.anchor || c.maxWidth !== t.maxWidth) && s.setMaxWidth(t.maxWidth);
636
- const a = V(c.className, t.className);
637
- if (a)
638
- for (const l of a)
639
- s.toggleClassName(l);
640
- i.current.props = t;
641
- }
642
- return q(t.children, o);
643
- }));
644
- function x(t, e, n, r) {
645
- const o = T(R), i = M(() => t(o), []);
646
- return m(() => {
647
- const s = e, c = null, a = typeof e == "function" ? e : null, { map: l } = o;
648
- return l.hasControl(i) || (l.addControl(i, s == null ? void 0 : s.position), c && c(o)), () => {
649
- a && a(o), l.hasControl(i) && l.removeControl(i);
650
- };
651
- }, []), i;
652
- }
653
- function ft(t) {
654
- const e = x(({ mapLib: n }) => new n.AttributionControl(t), {
655
- position: t.position
656
- });
657
- return m(() => {
658
- S(e._container, t.style);
659
- }, [t.style]), null;
660
- }
661
- L(ft);
662
- function dt(t) {
663
- const e = x(({ mapLib: n }) => new n.FullscreenControl({
664
- container: t.containerId && document.getElementById(t.containerId)
665
- }), { position: t.position });
666
- return m(() => {
667
- S(e._controlContainer, t.style);
668
- }, [t.style]), null;
669
- }
670
- L(dt);
671
- function mt(t, e) {
672
- const n = b({ props: t }), r = x(({ mapLib: o }) => {
673
- const i = new o.GeolocateControl(t), s = i._setupUI.bind(i);
674
- return i._setupUI = (c) => {
675
- i._container.hasChildNodes() || s(c);
676
- }, i.on("geolocate", (c) => {
677
- var a, l;
678
- (l = (a = n.current.props).onGeolocate) == null || l.call(a, c);
679
- }), i.on("error", (c) => {
680
- var a, l;
681
- (l = (a = n.current.props).onError) == null || l.call(a, c);
682
- }), i.on("outofmaxbounds", (c) => {
683
- var a, l;
684
- (l = (a = n.current.props).onOutOfMaxBounds) == null || l.call(a, c);
685
- }), i.on("trackuserlocationstart", (c) => {
686
- var a, l;
687
- (l = (a = n.current.props).onTrackUserLocationStart) == null || l.call(a, c);
688
- }), i.on("trackuserlocationend", (c) => {
689
- var a, l;
690
- (l = (a = n.current.props).onTrackUserLocationEnd) == null || l.call(a, c);
691
- }), i;
692
- }, { position: t.position });
693
- return n.current.props = t, z(e, () => r, []), m(() => {
694
- S(r._container, t.style);
695
- }, [t.style]), null;
696
- }
697
- L(A(mt));
698
- function ht(t) {
699
- const e = x(({ mapLib: n }) => new n.NavigationControl(t), {
700
- position: t.position
701
- });
702
- return m(() => {
703
- S(e._container, t.style);
704
- }, [t.style]), null;
705
- }
706
- const Lt = L(ht);
707
- function gt(t) {
708
- const e = x(({ mapLib: i }) => new i.ScaleControl(t), {
709
- position: t.position
710
- }), n = b(t), r = n.current;
711
- n.current = t;
712
- const { style: o } = t;
713
- return t.maxWidth !== void 0 && t.maxWidth !== r.maxWidth && (e.options.maxWidth = t.maxWidth), t.unit !== void 0 && t.unit !== r.unit && e.setUnit(t.unit), m(() => {
714
- S(e._container, o);
715
- }, [o]), null;
716
- }
717
- L(gt);
718
- export {
719
- vt as M,
720
- Lt as N,
721
- Et as P,
722
- Ct as a,
723
- R as b,
724
- _ as d,
725
- _t as u
726
- };