@local-logic/maps 0.0.21 → 0.0.22
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/dist/index-B85VZGVP.js +56 -0
- package/dist/index-BRD3rjLE.js +138 -0
- package/dist/index-BpFpg_5A.js +78 -0
- package/dist/index-BrxP9NHZ.js +56 -0
- package/dist/{index-AcZakyxd.js → index-CN_dNOir.js} +168 -172
- package/dist/index-CRdDPWou.js +34 -0
- package/dist/{index-Dz1XJJEv.js → index-CSVsF1EQ.js} +28 -28
- package/dist/index-CceEGv05.js +104 -0
- package/dist/{index-DdYanSGw.js → index-CiWKwaC4.js} +2 -2
- package/dist/{index-6JzOJU8O.js → index-CmajMf1d.js} +21 -21
- package/dist/index-D5kHxP9H.js +43 -0
- package/dist/{index-29Y5fJR0.js → index-DNNz78Rc.js} +2 -2
- package/dist/index-Db33Ugg9.js +34 -0
- package/dist/index-DfhwDiOS.js +155 -0
- package/dist/index-arkRlpaR.js +80 -0
- package/dist/index-ufLC1PLO.js +57 -0
- package/dist/{index-Dxh7aMoG.js → index-vHMPqmOL.js} +2 -2
- package/dist/index.es.js +1 -1
- package/dist/{index.modern-fpUBOYPT.js → index.modern-B-ChKejQ.js} +9 -9
- package/dist/index.umd.js +115 -115
- package/dist/{logo-control-C5ZdRec5.js → logo-control-VgN6MEKI.js} +186 -206
- package/dist/{mapbox-gl-D6JObe4m.js → mapbox-gl-C6frO4Gl.js} +1877 -1877
- package/dist/{maplibre-gl-DDfJU6SR.js → maplibre-gl-DkDrZ6rP.js} +1230 -1228
- package/dist/{scale-control-Cflgzbvb.js → scale-control-jBKptTbw.js} +234 -252
- package/dist/style.css +1 -1
- package/dist/{styles-B8oT_wcC.js → styles-BR85tnqI.js} +16 -17
- package/package.json +2 -2
- package/dist/index-CHSsiFtN.js +0 -139
- package/dist/index-CqUTGwL0.js +0 -34
- package/dist/index-Cwn0dgP_.js +0 -56
- package/dist/index-D--WdzK4.js +0 -79
- package/dist/index-D1Phs0fA.js +0 -57
- package/dist/index-D1vI6Ww_.js +0 -43
- package/dist/index-DHHG0vNa.js +0 -157
- package/dist/index-DKFcZs0A.js +0 -81
- package/dist/index-DZTFM839.js +0 -105
- package/dist/index-_8n5sl1B.js +0 -56
- package/dist/index-_n1FGHXc.js +0 -34
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return x(() => ({ ...t, current: n == null ? void 0 : n.map }), [t, n]);
|
|
1
|
+
import * as C from "react";
|
|
2
|
+
import { useContext as M, useMemo as S, useLayoutEffect as B, useEffect as l, useState as G, useRef as E, useImperativeHandle as R, memo as p, forwardRef as T } from "react";
|
|
3
|
+
import { createPortal as Z } from "react-dom";
|
|
4
|
+
const j = C.createContext(null);
|
|
5
|
+
function ht() {
|
|
6
|
+
const t = M(j)?.maps, n = M(b);
|
|
7
|
+
return S(() => ({ ...t, current: n?.map }), [t, n]);
|
|
9
8
|
}
|
|
10
|
-
function
|
|
9
|
+
function $(t, n) {
|
|
11
10
|
const e = Array.isArray(t) ? t[0] : t ? t.x : 0, i = Array.isArray(t) ? t[1] : t ? t.y : 0, r = Array.isArray(n) ? n[0] : n ? n.x : 0, o = Array.isArray(n) ? n[1] : n ? n.y : 0;
|
|
12
11
|
return e === r && i === o;
|
|
13
12
|
}
|
|
14
|
-
function
|
|
13
|
+
function h(t, n) {
|
|
15
14
|
if (t === n)
|
|
16
15
|
return !0;
|
|
17
16
|
if (!t || !n)
|
|
@@ -20,7 +19,7 @@ function y(t, n) {
|
|
|
20
19
|
if (!Array.isArray(n) || t.length !== n.length)
|
|
21
20
|
return !1;
|
|
22
21
|
for (let e = 0; e < t.length; e++)
|
|
23
|
-
if (!
|
|
22
|
+
if (!h(t[e], n[e]))
|
|
24
23
|
return !1;
|
|
25
24
|
return !0;
|
|
26
25
|
} else if (Array.isArray(n))
|
|
@@ -30,13 +29,13 @@ function y(t, n) {
|
|
|
30
29
|
if (e.length !== i.length)
|
|
31
30
|
return !1;
|
|
32
31
|
for (const r of e)
|
|
33
|
-
if (!n.hasOwnProperty(r) || !
|
|
32
|
+
if (!n.hasOwnProperty(r) || !h(t[r], n[r]))
|
|
34
33
|
return !1;
|
|
35
34
|
return !0;
|
|
36
35
|
}
|
|
37
36
|
return !1;
|
|
38
37
|
}
|
|
39
|
-
function
|
|
38
|
+
function N(t) {
|
|
40
39
|
return {
|
|
41
40
|
longitude: t.center.lng,
|
|
42
41
|
latitude: t.center.lat,
|
|
@@ -46,16 +45,16 @@ function A(t) {
|
|
|
46
45
|
padding: t.padding
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
|
-
function
|
|
48
|
+
function O(t, n) {
|
|
50
49
|
const e = n.viewState || n, i = {};
|
|
51
50
|
if ("longitude" in e && "latitude" in e && (e.longitude !== t.center.lng || e.latitude !== t.center.lat)) {
|
|
52
51
|
const r = t.center.constructor;
|
|
53
52
|
i.center = new r(e.longitude, e.latitude);
|
|
54
53
|
}
|
|
55
|
-
return "zoom" in e && e.zoom !== t.zoom && (i.zoom = e.zoom), "bearing" in e && e.bearing !== t.bearing && (i.bearing = e.bearing), "pitch" in e && e.pitch !== t.pitch && (i.pitch = e.pitch), e.padding && t.padding && !
|
|
54
|
+
return "zoom" in e && e.zoom !== t.zoom && (i.zoom = e.zoom), "bearing" in e && e.bearing !== t.bearing && (i.bearing = e.bearing), "pitch" in e && e.pitch !== t.pitch && (i.pitch = e.pitch), e.padding && t.padding && !h(e.padding, t.padding) && (i.padding = e.padding), i;
|
|
56
55
|
}
|
|
57
|
-
const
|
|
58
|
-
function
|
|
56
|
+
const J = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
|
|
57
|
+
function A(t) {
|
|
59
58
|
if (!t)
|
|
60
59
|
return null;
|
|
61
60
|
if (typeof t == "string" || ("toJS" in t && (t = t.toJS()), !t.layers))
|
|
@@ -69,14 +68,14 @@ function I(t) {
|
|
|
69
68
|
const o = n[i.ref];
|
|
70
69
|
if (o) {
|
|
71
70
|
r = r || Object.assign({}, i), delete r.ref;
|
|
72
|
-
for (const s of
|
|
71
|
+
for (const s of J)
|
|
73
72
|
s in o && (r[s] = o[s]);
|
|
74
73
|
}
|
|
75
74
|
return r || i;
|
|
76
75
|
});
|
|
77
76
|
return { ...t, layers: e };
|
|
78
77
|
}
|
|
79
|
-
const
|
|
78
|
+
const U = { version: 8, sources: {}, layers: [] }, I = {
|
|
80
79
|
mousedown: "onMouseDown",
|
|
81
80
|
mouseup: "onMouseUp",
|
|
82
81
|
mouseover: "onMouseOver",
|
|
@@ -91,7 +90,7 @@ const F = { version: 8, sources: {}, layers: [] }, D = {
|
|
|
91
90
|
touchend: "onTouchEnd",
|
|
92
91
|
touchmove: "onTouchMove",
|
|
93
92
|
touchcancel: "onTouchCancel"
|
|
94
|
-
},
|
|
93
|
+
}, F = {
|
|
95
94
|
movestart: "onMoveStart",
|
|
96
95
|
move: "onMove",
|
|
97
96
|
moveend: "onMoveEnd",
|
|
@@ -107,7 +106,7 @@ const F = { version: 8, sources: {}, layers: [] }, D = {
|
|
|
107
106
|
pitchstart: "onPitchStart",
|
|
108
107
|
pitch: "onPitch",
|
|
109
108
|
pitchend: "onPitchEnd"
|
|
110
|
-
},
|
|
109
|
+
}, D = {
|
|
111
110
|
wheel: "onWheel",
|
|
112
111
|
boxzoomstart: "onBoxZoomStart",
|
|
113
112
|
boxzoomend: "onBoxZoomEnd",
|
|
@@ -121,7 +120,7 @@ const F = { version: 8, sources: {}, layers: [] }, D = {
|
|
|
121
120
|
styledata: "onStyleData",
|
|
122
121
|
sourcedata: "onSourceData",
|
|
123
122
|
error: "onError"
|
|
124
|
-
},
|
|
123
|
+
}, K = [
|
|
125
124
|
"minZoom",
|
|
126
125
|
"maxZoom",
|
|
127
126
|
"minPitch",
|
|
@@ -129,7 +128,7 @@ const F = { version: 8, sources: {}, layers: [] }, D = {
|
|
|
129
128
|
"maxBounds",
|
|
130
129
|
"projection",
|
|
131
130
|
"renderWorldCopies"
|
|
132
|
-
],
|
|
131
|
+
], Y = [
|
|
133
132
|
"scrollZoom",
|
|
134
133
|
"boxZoom",
|
|
135
134
|
"dragRotate",
|
|
@@ -139,20 +138,20 @@ const F = { version: 8, sources: {}, layers: [] }, D = {
|
|
|
139
138
|
"touchZoomRotate",
|
|
140
139
|
"touchPitch"
|
|
141
140
|
];
|
|
142
|
-
class
|
|
141
|
+
class x {
|
|
143
142
|
constructor(n, e, i) {
|
|
144
143
|
this._map = null, this._internalUpdate = !1, this._hoveredFeatures = null, this._propsedCameraUpdate = null, this._styleComponents = {}, this._onEvent = (r) => {
|
|
145
|
-
const o = this.props[
|
|
144
|
+
const o = this.props[D[r.type]];
|
|
146
145
|
o ? o(r) : r.type === "error" && console.error(r.error);
|
|
147
146
|
}, this._onCameraEvent = (r) => {
|
|
148
147
|
if (this._internalUpdate)
|
|
149
148
|
return;
|
|
150
|
-
r.viewState = this._propsedCameraUpdate ||
|
|
151
|
-
const o = this.props[
|
|
149
|
+
r.viewState = this._propsedCameraUpdate || N(this._map.transform);
|
|
150
|
+
const o = this.props[F[r.type]];
|
|
152
151
|
o && o(r);
|
|
153
|
-
}, this._onCameraUpdate = (r) => this._internalUpdate ? r : (this._propsedCameraUpdate =
|
|
152
|
+
}, this._onCameraUpdate = (r) => this._internalUpdate ? r : (this._propsedCameraUpdate = N(r), O(r, this.props)), this._onPointerEvent = (r) => {
|
|
154
153
|
(r.type === "mousemove" || r.type === "mouseout") && this._updateHover(r);
|
|
155
|
-
const o = this.props[
|
|
154
|
+
const o = this.props[I[r.type]];
|
|
156
155
|
o && (this.props.interactiveLayerIds && r.type !== "mouseover" && r.type !== "mouseout" && (r.features = this._hoveredFeatures || this._queryRenderedFeatures(r.point)), o(r), delete r.features);
|
|
157
156
|
}, this._MapClass = n, this.props = e, this._initialize(i);
|
|
158
157
|
}
|
|
@@ -166,7 +165,7 @@ class P {
|
|
|
166
165
|
this._updateStyle(n, e), this._updateStyleComponents(n), this._updateHandlers(n, e), (i || r || o && !this._map.isMoving()) && this.redraw();
|
|
167
166
|
}
|
|
168
167
|
static reuse(n, e) {
|
|
169
|
-
const i =
|
|
168
|
+
const i = x.savedMaps.pop();
|
|
170
169
|
if (!i)
|
|
171
170
|
return null;
|
|
172
171
|
const r = i.map, o = r.getContainer();
|
|
@@ -180,11 +179,11 @@ class P {
|
|
|
180
179
|
}
|
|
181
180
|
/* eslint-disable complexity,max-statements */
|
|
182
181
|
_initialize(n) {
|
|
183
|
-
const { props: e } = this, { mapStyle: i =
|
|
182
|
+
const { props: e } = this, { mapStyle: i = U } = e, r = {
|
|
184
183
|
...e,
|
|
185
184
|
...e.initialViewState,
|
|
186
185
|
container: n,
|
|
187
|
-
style:
|
|
186
|
+
style: A(i)
|
|
188
187
|
}, o = r.initialViewState || r.viewState || r;
|
|
189
188
|
if (Object.assign(r, {
|
|
190
189
|
center: [o.longitude || 0, o.latitude || 0],
|
|
@@ -197,29 +196,27 @@ class P {
|
|
|
197
196
|
}
|
|
198
197
|
const s = new this._MapClass(r);
|
|
199
198
|
o.padding && s.setPadding(o.padding), e.cursor && (s.getCanvas().style.cursor = e.cursor), s.transformCameraUpdate = this._onCameraUpdate, s.on("style.load", () => {
|
|
200
|
-
var a;
|
|
201
199
|
this._styleComponents = {
|
|
202
200
|
light: s.getLight(),
|
|
203
201
|
sky: s.getSky(),
|
|
204
202
|
// @ts-ignore getProjection() does not exist in v4
|
|
205
|
-
projection:
|
|
203
|
+
projection: s.getProjection?.(),
|
|
206
204
|
terrain: s.getTerrain()
|
|
207
205
|
}, this._updateStyleComponents(this.props);
|
|
208
206
|
}), s.on("sourcedata", () => {
|
|
209
207
|
this._updateStyleComponents(this.props);
|
|
210
208
|
});
|
|
211
|
-
for (const a in
|
|
209
|
+
for (const a in I)
|
|
212
210
|
s.on(a, this._onPointerEvent);
|
|
213
|
-
for (const a in
|
|
211
|
+
for (const a in F)
|
|
214
212
|
s.on(a, this._onCameraEvent);
|
|
215
|
-
for (const a in
|
|
213
|
+
for (const a in D)
|
|
216
214
|
s.on(a, this._onEvent);
|
|
217
215
|
this._map = s;
|
|
218
216
|
}
|
|
219
217
|
/* eslint-enable complexity,max-statements */
|
|
220
218
|
recycle() {
|
|
221
|
-
|
|
222
|
-
e == null || e.remove(), P.savedMaps.push(this);
|
|
219
|
+
this.map.getContainer().querySelector("[mapboxgl-children]")?.remove(), x.savedMaps.push(this);
|
|
223
220
|
}
|
|
224
221
|
destroy() {
|
|
225
222
|
this._map.remove();
|
|
@@ -253,7 +250,7 @@ class P {
|
|
|
253
250
|
_updateViewState(n) {
|
|
254
251
|
const e = this._map, i = e.transform;
|
|
255
252
|
if (!e.isMoving()) {
|
|
256
|
-
const o =
|
|
253
|
+
const o = O(i, n);
|
|
257
254
|
if (Object.keys(o).length > 0)
|
|
258
255
|
return this._internalUpdate = !0, e.jumpTo(o), this._internalUpdate = !1, !0;
|
|
259
256
|
}
|
|
@@ -267,21 +264,17 @@ class P {
|
|
|
267
264
|
_updateSettings(n, e) {
|
|
268
265
|
const i = this._map;
|
|
269
266
|
let r = !1;
|
|
270
|
-
for (const o of
|
|
271
|
-
|
|
272
|
-
r = !0;
|
|
273
|
-
const s = i[`set${o[0].toUpperCase()}${o.slice(1)}`];
|
|
274
|
-
s == null || s.call(i, n[o]);
|
|
275
|
-
}
|
|
267
|
+
for (const o of K)
|
|
268
|
+
o in n && !h(n[o], e[o]) && (r = !0, i[`set${o[0].toUpperCase()}${o.slice(1)}`]?.call(i, n[o]));
|
|
276
269
|
return r;
|
|
277
270
|
}
|
|
278
271
|
/* Update map style to match props */
|
|
279
272
|
_updateStyle(n, e) {
|
|
280
273
|
if (n.cursor !== e.cursor && (this._map.getCanvas().style.cursor = n.cursor || ""), n.mapStyle !== e.mapStyle) {
|
|
281
|
-
const { mapStyle: i =
|
|
274
|
+
const { mapStyle: i = U, styleDiffing: r = !0 } = n, o = {
|
|
282
275
|
diff: r
|
|
283
276
|
};
|
|
284
|
-
"localIdeographFontFamily" in n && (o.localIdeographFontFamily = n.localIdeographFontFamily), this._map.setStyle(
|
|
277
|
+
"localIdeographFontFamily" in n && (o.localIdeographFontFamily = n.localIdeographFontFamily), this._map.setStyle(A(i), o);
|
|
285
278
|
}
|
|
286
279
|
}
|
|
287
280
|
/* Update fog, light, projection and terrain to match props
|
|
@@ -290,16 +283,15 @@ class P {
|
|
|
290
283
|
* 2. They can be overwritten by mapStyle
|
|
291
284
|
*/
|
|
292
285
|
_updateStyleComponents({ light: n, projection: e, sky: i, terrain: r }) {
|
|
293
|
-
var a, c;
|
|
294
286
|
const o = this._map, s = this._styleComponents;
|
|
295
|
-
o.style._loaded && (n && !
|
|
287
|
+
o.style._loaded && (n && !h(n, s.light) && (s.light = n, o.setLight(n)), e && !h(e, s.projection) && e !== s.projection?.type && (s.projection = typeof e == "string" ? { type: e } : e, o.setProjection?.(s.projection)), i && !h(i, s.sky) && (s.sky = i, o.setSky(i)), r !== void 0 && !h(r, s.terrain) && (!r || o.getSource(r.source)) && (s.terrain = r, o.setTerrain(r)));
|
|
296
288
|
}
|
|
297
289
|
/* Update interaction handlers to match props */
|
|
298
290
|
_updateHandlers(n, e) {
|
|
299
291
|
const i = this._map;
|
|
300
|
-
for (const r of
|
|
292
|
+
for (const r of Y) {
|
|
301
293
|
const o = n[r] ?? !0, s = e[r] ?? !0;
|
|
302
|
-
|
|
294
|
+
h(o, s) || (o ? i[r].enable(o) : i[r].disable());
|
|
303
295
|
}
|
|
304
296
|
}
|
|
305
297
|
_queryRenderedFeatures(n) {
|
|
@@ -313,17 +305,16 @@ class P {
|
|
|
313
305
|
}
|
|
314
306
|
}
|
|
315
307
|
_updateHover(n) {
|
|
316
|
-
var r;
|
|
317
308
|
const { props: e } = this;
|
|
318
309
|
if (e.interactiveLayerIds && (e.onMouseMove || e.onMouseEnter || e.onMouseLeave)) {
|
|
319
|
-
const
|
|
320
|
-
!
|
|
310
|
+
const r = n.type, o = this._hoveredFeatures?.length > 0, s = this._queryRenderedFeatures(n.point), a = s.length > 0;
|
|
311
|
+
!a && o && (n.type = "mouseleave", this._onPointerEvent(n)), this._hoveredFeatures = s, a && !o && (n.type = "mouseenter", this._onPointerEvent(n)), n.type = r;
|
|
321
312
|
} else
|
|
322
313
|
this._hoveredFeatures = null;
|
|
323
314
|
}
|
|
324
315
|
}
|
|
325
|
-
|
|
326
|
-
const
|
|
316
|
+
x.savedMaps = [];
|
|
317
|
+
const Q = [
|
|
327
318
|
"setMaxBounds",
|
|
328
319
|
"setMinZoom",
|
|
329
320
|
"setMaxZoom",
|
|
@@ -345,17 +336,17 @@ const tt = [
|
|
|
345
336
|
"setFog",
|
|
346
337
|
"remove"
|
|
347
338
|
];
|
|
348
|
-
function
|
|
339
|
+
function X(t) {
|
|
349
340
|
if (!t)
|
|
350
341
|
return null;
|
|
351
342
|
const n = t.map, e = {
|
|
352
343
|
getMap: () => n
|
|
353
344
|
};
|
|
354
|
-
for (const i of
|
|
355
|
-
!(i in e) && !
|
|
345
|
+
for (const i of tt(n))
|
|
346
|
+
!(i in e) && !Q.includes(i) && (e[i] = n[i].bind(n));
|
|
356
347
|
return e;
|
|
357
348
|
}
|
|
358
|
-
function
|
|
349
|
+
function tt(t) {
|
|
359
350
|
const n = /* @__PURE__ */ new Set();
|
|
360
351
|
let e = t;
|
|
361
352
|
for (; e; ) {
|
|
@@ -365,8 +356,8 @@ function nt(t) {
|
|
|
365
356
|
}
|
|
366
357
|
return Array.from(n);
|
|
367
358
|
}
|
|
368
|
-
const
|
|
369
|
-
function
|
|
359
|
+
const et = typeof document < "u" ? B : l;
|
|
360
|
+
function nt(t, n) {
|
|
370
361
|
const { RTLTextPlugin: e, maxParallelImageRequests: i, workerCount: r, workerUrl: o } = n;
|
|
371
362
|
if (e && t.getRTLTextPluginStatus && t.getRTLTextPluginStatus() === "unavailable") {
|
|
372
363
|
const { pluginUrl: s, lazy: a = !0 } = typeof e == "string" ? { pluginUrl: e } : e;
|
|
@@ -376,36 +367,36 @@ function rt(t, n) {
|
|
|
376
367
|
}
|
|
377
368
|
i !== void 0 && t.setMaxParallelImageRequests(i), r !== void 0 && t.setWorkerCount(r), o !== void 0 && t.setWorkerUrl(o);
|
|
378
369
|
}
|
|
379
|
-
const
|
|
380
|
-
function
|
|
381
|
-
const e =
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
let
|
|
385
|
-
return Promise.resolve(
|
|
386
|
-
if (!
|
|
370
|
+
const b = C.createContext(null);
|
|
371
|
+
function ot(t, n) {
|
|
372
|
+
const e = M(j), [i, r] = G(null), o = E(), { current: s } = E({ mapLib: null, map: null });
|
|
373
|
+
l(() => {
|
|
374
|
+
const u = t.mapLib;
|
|
375
|
+
let w = !0, f;
|
|
376
|
+
return Promise.resolve(u || import("./maplibre-gl-DkDrZ6rP.js").then((d) => d.m)).then((d) => {
|
|
377
|
+
if (!w)
|
|
387
378
|
return;
|
|
388
|
-
if (!
|
|
379
|
+
if (!d)
|
|
389
380
|
throw new Error("Invalid mapLib");
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
381
|
+
const m = "Map" in d ? d : d.default;
|
|
382
|
+
if (!m.Map)
|
|
392
383
|
throw new Error("Invalid mapLib");
|
|
393
|
-
|
|
394
|
-
}).catch((
|
|
395
|
-
const { onError:
|
|
396
|
-
|
|
384
|
+
nt(m, t), t.reuseMaps && (f = x.reuse(t, o.current)), f || (f = new x(m.Map, t, o.current)), s.map = X(f), s.mapLib = m, r(f), e?.onMapMount(s.map, t.id);
|
|
385
|
+
}).catch((d) => {
|
|
386
|
+
const { onError: m } = t;
|
|
387
|
+
m ? m({
|
|
397
388
|
type: "error",
|
|
398
389
|
target: null,
|
|
399
390
|
originalEvent: null,
|
|
400
|
-
error:
|
|
401
|
-
}) : console.error(
|
|
391
|
+
error: d
|
|
392
|
+
}) : console.error(d);
|
|
402
393
|
}), () => {
|
|
403
|
-
|
|
394
|
+
w = !1, f && (e?.onMapUnmount(t.id), t.reuseMaps ? f.recycle() : f.destroy());
|
|
404
395
|
};
|
|
405
|
-
}, []),
|
|
396
|
+
}, []), et(() => {
|
|
406
397
|
i && i.setProps(t);
|
|
407
|
-
}),
|
|
408
|
-
const a =
|
|
398
|
+
}), R(n, () => s.map, [i]);
|
|
399
|
+
const a = S(() => ({
|
|
409
400
|
position: "relative",
|
|
410
401
|
width: "100%",
|
|
411
402
|
height: "100%",
|
|
@@ -413,205 +404,194 @@ function it(t, n) {
|
|
|
413
404
|
}), [t.style]), c = {
|
|
414
405
|
height: "100%"
|
|
415
406
|
};
|
|
416
|
-
return
|
|
417
|
-
|
|
407
|
+
return C.createElement("div", { id: t.id, ref: o, style: a }, i && C.createElement(
|
|
408
|
+
b.Provider,
|
|
418
409
|
{ value: s },
|
|
419
|
-
|
|
410
|
+
C.createElement("div", { "mapboxgl-children": "", style: c }, t.children)
|
|
420
411
|
));
|
|
421
412
|
}
|
|
422
|
-
const
|
|
423
|
-
function
|
|
413
|
+
const gt = C.forwardRef(ot), rt = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
|
|
414
|
+
function y(t, n) {
|
|
424
415
|
if (!t || !n)
|
|
425
416
|
return;
|
|
426
417
|
const e = t.style;
|
|
427
418
|
for (const i in n) {
|
|
428
419
|
const r = n[i];
|
|
429
|
-
Number.isFinite(r) && !
|
|
420
|
+
Number.isFinite(r) && !rt.test(i) ? e[i] = `${r}px` : e[i] = r;
|
|
430
421
|
}
|
|
431
422
|
}
|
|
432
|
-
function
|
|
423
|
+
function H(t, n) {
|
|
433
424
|
if (t === n)
|
|
434
425
|
return null;
|
|
435
|
-
const e =
|
|
426
|
+
const e = W(t), i = W(n), r = [];
|
|
436
427
|
for (const o of i)
|
|
437
428
|
e.has(o) || r.push(o);
|
|
438
429
|
for (const o of e)
|
|
439
430
|
i.has(o) || r.push(o);
|
|
440
431
|
return r.length === 0 ? null : r;
|
|
441
432
|
}
|
|
442
|
-
function
|
|
433
|
+
function W(t) {
|
|
443
434
|
return new Set(t ? t.trim().split(/\s+/) : []);
|
|
444
435
|
}
|
|
445
|
-
const
|
|
446
|
-
const { map: e, mapLib: i } =
|
|
447
|
-
let
|
|
448
|
-
|
|
449
|
-
|
|
436
|
+
const pt = p(T((t, n) => {
|
|
437
|
+
const { map: e, mapLib: i } = M(b), r = E({ props: t }), o = S(() => {
|
|
438
|
+
let P = !1;
|
|
439
|
+
C.Children.forEach(t.children, (g) => {
|
|
440
|
+
g && (P = !0);
|
|
450
441
|
});
|
|
451
|
-
const
|
|
442
|
+
const q = {
|
|
452
443
|
...t,
|
|
453
|
-
element:
|
|
454
|
-
},
|
|
455
|
-
return
|
|
456
|
-
|
|
457
|
-
(g = (h = r.current.props).onClick) == null || g.call(h, {
|
|
444
|
+
element: P ? document.createElement("div") : void 0
|
|
445
|
+
}, _ = new i.Marker(q);
|
|
446
|
+
return _.setLngLat([t.longitude, t.latitude]), _.getElement().addEventListener("click", (g) => {
|
|
447
|
+
r.current.props.onClick?.({
|
|
458
448
|
type: "click",
|
|
459
|
-
target:
|
|
460
|
-
originalEvent:
|
|
449
|
+
target: _,
|
|
450
|
+
originalEvent: g
|
|
461
451
|
});
|
|
462
|
-
}),
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
const h = v;
|
|
473
|
-
h.lngLat = o.getLngLat(), (L = (g = r.current.props).onDragEnd) == null || L.call(g, h);
|
|
474
|
-
}), S;
|
|
452
|
+
}), _.on("dragstart", (g) => {
|
|
453
|
+
const v = g;
|
|
454
|
+
v.lngLat = o.getLngLat(), r.current.props.onDragStart?.(v);
|
|
455
|
+
}), _.on("drag", (g) => {
|
|
456
|
+
const v = g;
|
|
457
|
+
v.lngLat = o.getLngLat(), r.current.props.onDrag?.(v);
|
|
458
|
+
}), _.on("dragend", (g) => {
|
|
459
|
+
const v = g;
|
|
460
|
+
v.lngLat = o.getLngLat(), r.current.props.onDragEnd?.(v);
|
|
461
|
+
}), _;
|
|
475
462
|
}, []);
|
|
476
|
-
|
|
463
|
+
l(() => (o.addTo(e.getMap()), () => {
|
|
477
464
|
o.remove();
|
|
478
465
|
}), []);
|
|
479
|
-
const { longitude: s, latitude: a, offset: c, style:
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}, [
|
|
483
|
-
const
|
|
484
|
-
(o.getLngLat().lng !== s || o.getLngLat().lat !== a) && o.setLngLat([s, a]), c &&
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
for (const
|
|
488
|
-
o.toggleClassName(
|
|
489
|
-
return r.current.props = t,
|
|
490
|
-
})),
|
|
491
|
-
const { map: e, mapLib: i } =
|
|
466
|
+
const { longitude: s, latitude: a, offset: c, style: u, draggable: w = !1, popup: f = null, rotation: d = 0, rotationAlignment: m = "auto", pitchAlignment: k = "auto" } = t;
|
|
467
|
+
l(() => {
|
|
468
|
+
y(o.getElement(), u);
|
|
469
|
+
}, [u]), R(n, () => o, []);
|
|
470
|
+
const V = r.current.props;
|
|
471
|
+
(o.getLngLat().lng !== s || o.getLngLat().lat !== a) && o.setLngLat([s, a]), c && !$(o.getOffset(), c) && o.setOffset(c), o.isDraggable() !== w && o.setDraggable(w), o.getRotation() !== d && o.setRotation(d), o.getRotationAlignment() !== m && o.setRotationAlignment(m), o.getPitchAlignment() !== k && o.setPitchAlignment(k), o.getPopup() !== f && o.setPopup(f);
|
|
472
|
+
const z = H(V.className, t.className);
|
|
473
|
+
if (z)
|
|
474
|
+
for (const P of z)
|
|
475
|
+
o.toggleClassName(P);
|
|
476
|
+
return r.current.props = t, Z(t.children, o.getElement());
|
|
477
|
+
})), yt = p(T((t, n) => {
|
|
478
|
+
const { map: e, mapLib: i } = M(b), r = S(() => document.createElement("div"), []), o = E({ props: t }), s = S(() => {
|
|
492
479
|
const a = { ...t }, c = new i.Popup(a);
|
|
493
|
-
return c.setLngLat([t.longitude, t.latitude]), c.once("open", (
|
|
494
|
-
|
|
495
|
-
(u = (m = o.current.props).onOpen) == null || u.call(m, l);
|
|
480
|
+
return c.setLngLat([t.longitude, t.latitude]), c.once("open", (u) => {
|
|
481
|
+
o.current.props.onOpen?.(u);
|
|
496
482
|
}), c;
|
|
497
483
|
}, []);
|
|
498
|
-
if (
|
|
484
|
+
if (l(() => {
|
|
499
485
|
const a = (c) => {
|
|
500
|
-
|
|
501
|
-
(m = (l = o.current.props).onClose) == null || m.call(l, c);
|
|
486
|
+
o.current.props.onClose?.(c);
|
|
502
487
|
};
|
|
503
488
|
return s.on("close", a), s.setDOMContent(r).addTo(e.getMap()), () => {
|
|
504
489
|
s.off("close", a), s.isOpen() && s.remove();
|
|
505
490
|
};
|
|
506
|
-
}, []),
|
|
507
|
-
|
|
508
|
-
}, [t.style]),
|
|
491
|
+
}, []), l(() => {
|
|
492
|
+
y(s.getElement(), t.style);
|
|
493
|
+
}, [t.style]), R(n, () => s, []), s.isOpen()) {
|
|
509
494
|
const a = o.current.props;
|
|
510
|
-
(s.getLngLat().lng !== t.longitude || s.getLngLat().lat !== t.latitude) && s.setLngLat([t.longitude, t.latitude]), t.offset && !
|
|
511
|
-
const c =
|
|
495
|
+
(s.getLngLat().lng !== t.longitude || s.getLngLat().lat !== t.latitude) && s.setLngLat([t.longitude, t.latitude]), t.offset && !h(a.offset, t.offset) && s.setOffset(t.offset), (a.anchor !== t.anchor || a.maxWidth !== t.maxWidth) && (s.options.anchor = t.anchor, s.setMaxWidth(t.maxWidth));
|
|
496
|
+
const c = H(a.className, t.className);
|
|
512
497
|
if (c)
|
|
513
|
-
for (const
|
|
514
|
-
s.toggleClassName(
|
|
498
|
+
for (const u of c)
|
|
499
|
+
s.toggleClassName(u);
|
|
515
500
|
o.current.props = t;
|
|
516
501
|
}
|
|
517
|
-
return
|
|
502
|
+
return Z(t.children, r);
|
|
518
503
|
}));
|
|
519
|
-
function
|
|
520
|
-
const r =
|
|
521
|
-
return
|
|
522
|
-
const s = n, a = null, c = typeof n == "function" ? n : null, { map:
|
|
523
|
-
return
|
|
524
|
-
c && c(r),
|
|
504
|
+
function L(t, n, e, i) {
|
|
505
|
+
const r = M(b), o = S(() => t(r), []);
|
|
506
|
+
return l(() => {
|
|
507
|
+
const s = n, a = null, c = typeof n == "function" ? n : null, { map: u } = r;
|
|
508
|
+
return u.hasControl(o) || (u.addControl(o, s?.position), a && a(r)), () => {
|
|
509
|
+
c && c(r), u.hasControl(o) && u.removeControl(o);
|
|
525
510
|
};
|
|
526
511
|
}, []), o;
|
|
527
512
|
}
|
|
528
|
-
function
|
|
529
|
-
const n =
|
|
513
|
+
function it(t) {
|
|
514
|
+
const n = L(({ mapLib: e }) => new e.AttributionControl(t), {
|
|
530
515
|
position: t.position
|
|
531
516
|
});
|
|
532
|
-
return
|
|
533
|
-
|
|
517
|
+
return l(() => {
|
|
518
|
+
y(n._container, t.style);
|
|
534
519
|
}, [t.style]), null;
|
|
535
520
|
}
|
|
536
|
-
|
|
537
|
-
function
|
|
538
|
-
const n =
|
|
521
|
+
p(it);
|
|
522
|
+
function st(t) {
|
|
523
|
+
const n = L(({ mapLib: e }) => new e.FullscreenControl({
|
|
539
524
|
container: t.containerId && document.getElementById(t.containerId)
|
|
540
525
|
}), { position: t.position });
|
|
541
|
-
return
|
|
542
|
-
|
|
526
|
+
return l(() => {
|
|
527
|
+
y(n._controlContainer, t.style);
|
|
543
528
|
}, [t.style]), null;
|
|
544
529
|
}
|
|
545
|
-
|
|
546
|
-
function
|
|
547
|
-
const e =
|
|
530
|
+
p(st);
|
|
531
|
+
function at(t, n) {
|
|
532
|
+
const e = E({ props: t }), i = L(({ mapLib: r }) => {
|
|
548
533
|
const o = new r.GeolocateControl(t), s = o._setupUI;
|
|
549
534
|
return o._setupUI = () => {
|
|
550
535
|
o._container.hasChildNodes() || s();
|
|
551
536
|
}, o.on("geolocate", (a) => {
|
|
552
|
-
|
|
553
|
-
(l = (c = e.current.props).onGeolocate) == null || l.call(c, a);
|
|
537
|
+
e.current.props.onGeolocate?.(a);
|
|
554
538
|
}), o.on("error", (a) => {
|
|
555
|
-
|
|
556
|
-
(l = (c = e.current.props).onError) == null || l.call(c, a);
|
|
539
|
+
e.current.props.onError?.(a);
|
|
557
540
|
}), o.on("outofmaxbounds", (a) => {
|
|
558
|
-
|
|
559
|
-
(l = (c = e.current.props).onOutOfMaxBounds) == null || l.call(c, a);
|
|
541
|
+
e.current.props.onOutOfMaxBounds?.(a);
|
|
560
542
|
}), o.on("trackuserlocationstart", (a) => {
|
|
561
|
-
|
|
562
|
-
(l = (c = e.current.props).onTrackUserLocationStart) == null || l.call(c, a);
|
|
543
|
+
e.current.props.onTrackUserLocationStart?.(a);
|
|
563
544
|
}), o.on("trackuserlocationend", (a) => {
|
|
564
|
-
|
|
565
|
-
(l = (c = e.current.props).onTrackUserLocationEnd) == null || l.call(c, a);
|
|
545
|
+
e.current.props.onTrackUserLocationEnd?.(a);
|
|
566
546
|
}), o;
|
|
567
547
|
}, { position: t.position });
|
|
568
|
-
return e.current.props = t,
|
|
569
|
-
|
|
548
|
+
return e.current.props = t, R(n, () => i, []), l(() => {
|
|
549
|
+
y(i._container, t.style);
|
|
570
550
|
}, [t.style]), null;
|
|
571
551
|
}
|
|
572
|
-
|
|
573
|
-
function
|
|
574
|
-
const n =
|
|
552
|
+
p(T(at));
|
|
553
|
+
function ct(t) {
|
|
554
|
+
const n = L(({ mapLib: e }) => new e.NavigationControl(t), {
|
|
575
555
|
position: t.position
|
|
576
556
|
});
|
|
577
|
-
return
|
|
578
|
-
|
|
557
|
+
return l(() => {
|
|
558
|
+
y(n._container, t.style);
|
|
579
559
|
}, [t.style]), null;
|
|
580
560
|
}
|
|
581
|
-
const
|
|
582
|
-
function
|
|
583
|
-
const n =
|
|
561
|
+
const vt = p(ct);
|
|
562
|
+
function lt(t) {
|
|
563
|
+
const n = L(({ mapLib: o }) => new o.ScaleControl(t), {
|
|
584
564
|
position: t.position
|
|
585
|
-
}), e =
|
|
565
|
+
}), e = E(t), i = e.current;
|
|
586
566
|
e.current = t;
|
|
587
567
|
const { style: r } = t;
|
|
588
|
-
return t.maxWidth !== void 0 && t.maxWidth !== i.maxWidth && (n.options.maxWidth = t.maxWidth), t.unit !== void 0 && t.unit !== i.unit && n.setUnit(t.unit),
|
|
589
|
-
|
|
568
|
+
return t.maxWidth !== void 0 && t.maxWidth !== i.maxWidth && (n.options.maxWidth = t.maxWidth), t.unit !== void 0 && t.unit !== i.unit && n.setUnit(t.unit), l(() => {
|
|
569
|
+
y(n._container, r);
|
|
590
570
|
}, [r]), null;
|
|
591
571
|
}
|
|
592
|
-
|
|
593
|
-
function
|
|
594
|
-
const n =
|
|
572
|
+
p(lt);
|
|
573
|
+
function ut(t) {
|
|
574
|
+
const n = L(({ mapLib: e }) => new e.TerrainControl(t), {
|
|
595
575
|
position: t.position
|
|
596
576
|
});
|
|
597
|
-
return
|
|
598
|
-
|
|
577
|
+
return l(() => {
|
|
578
|
+
y(n._container, t.style);
|
|
599
579
|
}, [t.style]), null;
|
|
600
580
|
}
|
|
601
|
-
|
|
602
|
-
function
|
|
603
|
-
const n =
|
|
604
|
-
return
|
|
605
|
-
|
|
581
|
+
p(ut);
|
|
582
|
+
function dt(t) {
|
|
583
|
+
const n = L(({ mapLib: e }) => new e.LogoControl(t), { position: t.position });
|
|
584
|
+
return l(() => {
|
|
585
|
+
y(n._container, t.style);
|
|
606
586
|
}, [t.style]), null;
|
|
607
587
|
}
|
|
608
|
-
|
|
588
|
+
p(dt);
|
|
609
589
|
export {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
590
|
+
gt as M,
|
|
591
|
+
vt as N,
|
|
592
|
+
yt as P,
|
|
593
|
+
pt as a,
|
|
594
|
+
b,
|
|
595
|
+
h as d,
|
|
596
|
+
ht as u
|
|
617
597
|
};
|