bbl-mapbox-react 0.0.30 → 0.0.31
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.cjs +3 -3
- package/dist/index.mjs +305 -291
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6041,37 +6041,49 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6041
6041
|
zoom: t ?? r.getZoom(),
|
|
6042
6042
|
...n
|
|
6043
6043
|
});
|
|
6044
|
-
}, []), jt = useCallback((e
|
|
6044
|
+
}, []), jt = useCallback((e) => {
|
|
6045
|
+
if (e.length === 0) return null;
|
|
6046
|
+
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity, a = !1;
|
|
6047
|
+
for (let o of e) {
|
|
6048
|
+
let e = R.current.get(o);
|
|
6049
|
+
if (e) {
|
|
6050
|
+
let [[o, s], [c, l]] = e.getBounds();
|
|
6051
|
+
t = Math.min(t, o), n = Math.max(n, c), r = Math.min(r, s), i = Math.max(i, l), a = !0;
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
6054
|
+
return a ? [(t + n) / 2, (r + i) / 2] : null;
|
|
6055
|
+
}, []), Mt = useCallback((e, t, n) => {
|
|
6045
6056
|
let r = L.current;
|
|
6046
6057
|
if (!r || e.length === 0) return;
|
|
6047
|
-
let i =
|
|
6058
|
+
let i = jt(e);
|
|
6059
|
+
if (!i) return;
|
|
6060
|
+
let a = [];
|
|
6048
6061
|
for (let t of e) {
|
|
6049
6062
|
let e = R.current.get(t);
|
|
6050
|
-
e &&
|
|
6063
|
+
e && a.push(e.getBounds());
|
|
6051
6064
|
}
|
|
6052
|
-
|
|
6053
|
-
let
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
if (i.length === 1 || d) {
|
|
6065
|
+
let o = Infinity, s = -Infinity, c = Infinity, l = -Infinity;
|
|
6066
|
+
for (let [[e, t], [n, r]] of a) o = Math.min(o, e), s = Math.max(s, n), c = Math.min(c, t), l = Math.max(l, r);
|
|
6067
|
+
let u = o === s && c === l;
|
|
6068
|
+
if (a.length === 1 || u) {
|
|
6057
6069
|
let e = {
|
|
6058
|
-
center:
|
|
6070
|
+
center: i,
|
|
6059
6071
|
zoom: t ?? r.getZoom()
|
|
6060
6072
|
};
|
|
6061
6073
|
n?.duration !== void 0 && (e.duration = n.duration), n?.pitch !== void 0 && (e.pitch = n.pitch), n?.bearing !== void 0 && (e.bearing = n.bearing), n?.essential !== void 0 && (e.essential = n.essential), r.flyTo(e);
|
|
6062
6074
|
return;
|
|
6063
6075
|
}
|
|
6064
|
-
let
|
|
6076
|
+
let d = [[o, c], [s, l]], f = {
|
|
6065
6077
|
padding: n?.padding ?? 50,
|
|
6066
6078
|
duration: n?.duration ?? 1e3,
|
|
6067
6079
|
bearing: n?.bearing ?? r.getBearing(),
|
|
6068
6080
|
pitch: n?.pitch ?? r.getPitch()
|
|
6069
6081
|
};
|
|
6070
|
-
t !== void 0 && (
|
|
6071
|
-
}, []),
|
|
6082
|
+
t !== void 0 && (f.maxZoom = t), n?.essential !== void 0 && (f.essential = n.essential), r.fitBounds(d, f);
|
|
6083
|
+
}, [jt]), Nt = useRef(null), Pt = useRef("display"), [Ft, It] = useState({}), J = useMemo(() => ({
|
|
6072
6084
|
...y,
|
|
6073
|
-
...
|
|
6074
|
-
}), [y,
|
|
6085
|
+
...Ft
|
|
6086
|
+
}), [y, Ft]), Lt = useCallback((e) => {
|
|
6075
6087
|
let t = L.current;
|
|
6076
6088
|
if (!t || !t.getContainer()) return;
|
|
6077
6089
|
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = J;
|
|
@@ -6103,9 +6115,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6103
6115
|
anchor: "bottom"
|
|
6104
6116
|
}).setLngLat(e).addTo(t);
|
|
6105
6117
|
}
|
|
6106
|
-
}, [J, O]),
|
|
6118
|
+
}, [J, O]), Rt = useCallback(() => {
|
|
6107
6119
|
it.current &&= (it.current.remove(), null);
|
|
6108
|
-
}, []),
|
|
6120
|
+
}, []), zt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Bt = useCallback((e) => {
|
|
6109
6121
|
let t = L.current;
|
|
6110
6122
|
if (Ve.current) if (_t.current &&= (_t.current.remove(), null), e && t) {
|
|
6111
6123
|
t.getCanvas().style.cursor = "none";
|
|
@@ -6129,7 +6141,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6129
6141
|
}
|
|
6130
6142
|
let e = L.current;
|
|
6131
6143
|
e && (e.getCanvas().style.cursor = "");
|
|
6132
|
-
}, []),
|
|
6144
|
+
}, []), Vt = useCallback((e, t, n) => {
|
|
6133
6145
|
if (!e.getSource(t)) {
|
|
6134
6146
|
if (!e.getStyle().glyphs) {
|
|
6135
6147
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -6165,7 +6177,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6165
6177
|
}
|
|
6166
6178
|
});
|
|
6167
6179
|
}
|
|
6168
|
-
}, []),
|
|
6180
|
+
}, []), Ht = useCallback(() => {
|
|
6169
6181
|
let e = L.current;
|
|
6170
6182
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6171
6183
|
type: "geojson",
|
|
@@ -6190,8 +6202,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6190
6202
|
"line-width": 2,
|
|
6191
6203
|
"line-dasharray": [4, 4]
|
|
6192
6204
|
}
|
|
6193
|
-
}),
|
|
6194
|
-
}, [
|
|
6205
|
+
}), Vt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6206
|
+
}, [Vt]), Ut = useCallback((e, t) => {
|
|
6195
6207
|
let n = L.current;
|
|
6196
6208
|
if (!n) return;
|
|
6197
6209
|
let r = n.getSource("rect-preview-source");
|
|
@@ -6215,7 +6227,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6215
6227
|
n.getLayer("rect-preview-line") && (n.setPaintProperty("rect-preview-line", "line-color", u), n.setPaintProperty("rect-preview-line", "line-width", d)), n.getLayer("rect-preview-fill") && (n.setPaintProperty("rect-preview-fill", "fill-color", f), n.setPaintProperty("rect-preview-fill", "fill-opacity", p));
|
|
6216
6228
|
let m = n.getSource("rect-preview-measure-source");
|
|
6217
6229
|
if (m) {
|
|
6218
|
-
let e =
|
|
6230
|
+
let e = Hn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6219
6231
|
if (e?.showArea) {
|
|
6220
6232
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6221
6233
|
t.push({
|
|
@@ -6252,7 +6264,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6252
6264
|
features: t
|
|
6253
6265
|
});
|
|
6254
6266
|
}
|
|
6255
|
-
}, []),
|
|
6267
|
+
}, []), Wt = useCallback(() => {
|
|
6256
6268
|
let e = L.current;
|
|
6257
6269
|
if (!e) return;
|
|
6258
6270
|
let t = e.getSource("rect-preview-source");
|
|
@@ -6266,8 +6278,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6266
6278
|
features: []
|
|
6267
6279
|
});
|
|
6268
6280
|
}, []), X = useCallback(() => {
|
|
6269
|
-
ct(null),
|
|
6270
|
-
}, [
|
|
6281
|
+
ct(null), Wt();
|
|
6282
|
+
}, [Wt]), Gt = useCallback(() => {
|
|
6271
6283
|
let e = L.current;
|
|
6272
6284
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6273
6285
|
type: "geojson",
|
|
@@ -6292,7 +6304,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6292
6304
|
"line-width": 2,
|
|
6293
6305
|
"line-dasharray": [4, 4]
|
|
6294
6306
|
}
|
|
6295
|
-
}),
|
|
6307
|
+
}), Vt(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
6296
6308
|
type: "geojson",
|
|
6297
6309
|
data: {
|
|
6298
6310
|
type: "FeatureCollection",
|
|
@@ -6309,22 +6321,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6309
6321
|
"line-dasharray": [4, 4]
|
|
6310
6322
|
}
|
|
6311
6323
|
}))));
|
|
6312
|
-
}, [
|
|
6324
|
+
}, [Vt]), Kt = useCallback((e, t, n = 64) => {
|
|
6313
6325
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
6314
6326
|
for (let e = 0; e <= n; e++) {
|
|
6315
6327
|
let t = e / n * 2 * Math.PI, c = o * Math.cos(t), l = o * Math.sin(t) / Math.cos(s), u = i + c * 180 / Math.PI, d = r + l * 180 / Math.PI;
|
|
6316
6328
|
a.push([d, u]);
|
|
6317
6329
|
}
|
|
6318
6330
|
return a;
|
|
6319
|
-
}, []),
|
|
6331
|
+
}, []), qt = useCallback((e, t) => {
|
|
6320
6332
|
let [n, r] = e, [i, a] = t, o = (a - r) * Math.PI / 180, s = (i - n) * Math.PI / 180, c = Math.sin(o / 2) * Math.sin(o / 2) + Math.cos(r * Math.PI / 180) * Math.cos(a * Math.PI / 180) * Math.sin(s / 2) * Math.sin(s / 2);
|
|
6321
6333
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6322
|
-
}, []),
|
|
6334
|
+
}, []), Jt = useCallback((e, t) => {
|
|
6323
6335
|
let n = L.current;
|
|
6324
6336
|
if (!n) return;
|
|
6325
6337
|
let r = n.getSource("circle-preview-source");
|
|
6326
6338
|
if (!r) return;
|
|
6327
|
-
let i =
|
|
6339
|
+
let i = qt(e, t), a = Kt(e, i);
|
|
6328
6340
|
r.setData({
|
|
6329
6341
|
type: "Feature",
|
|
6330
6342
|
geometry: {
|
|
@@ -6335,7 +6347,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6335
6347
|
});
|
|
6336
6348
|
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6337
6349
|
n.getLayer("circle-preview-line") && (n.setPaintProperty("circle-preview-line", "line-color", s), n.setPaintProperty("circle-preview-line", "line-width", c)), n.getLayer("circle-preview-fill") && (n.setPaintProperty("circle-preview-fill", "fill-color", l), n.setPaintProperty("circle-preview-fill", "fill-opacity", u));
|
|
6338
|
-
let d =
|
|
6350
|
+
let d = Hn.current, f = [], p = [];
|
|
6339
6351
|
if (d?.showArea) {
|
|
6340
6352
|
let t = Math.PI * i * i;
|
|
6341
6353
|
f.push({
|
|
@@ -6375,7 +6387,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6375
6387
|
type: "FeatureCollection",
|
|
6376
6388
|
features: p
|
|
6377
6389
|
});
|
|
6378
|
-
}, [
|
|
6390
|
+
}, [qt, Kt]), Yt = useCallback(() => {
|
|
6379
6391
|
let e = L.current;
|
|
6380
6392
|
if (!e) return;
|
|
6381
6393
|
let t = e.getSource("circle-preview-source");
|
|
@@ -6393,9 +6405,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6393
6405
|
type: "FeatureCollection",
|
|
6394
6406
|
features: []
|
|
6395
6407
|
});
|
|
6396
|
-
}, []),
|
|
6397
|
-
dt.current = null,
|
|
6398
|
-
}, [
|
|
6408
|
+
}, []), Xt = useCallback(() => {
|
|
6409
|
+
dt.current = null, Yt();
|
|
6410
|
+
}, [Yt]), Zt = useCallback(() => {
|
|
6399
6411
|
let e = L.current;
|
|
6400
6412
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6401
6413
|
type: "geojson",
|
|
@@ -6436,8 +6448,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6436
6448
|
"circle-stroke-color": "#ffffff",
|
|
6437
6449
|
"circle-stroke-width": 2
|
|
6438
6450
|
}
|
|
6439
|
-
}),
|
|
6440
|
-
}, [
|
|
6451
|
+
}), Vt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6452
|
+
}, [Vt]), Qt = useCallback((e, t) => {
|
|
6441
6453
|
let n = L.current;
|
|
6442
6454
|
if (!n) return;
|
|
6443
6455
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
@@ -6479,7 +6491,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6479
6491
|
n.getLayer("polygon-preview-line") && (n.setPaintProperty("polygon-preview-line", "line-color", s), n.setPaintProperty("polygon-preview-line", "line-width", c)), n.getLayer("polygon-preview-fill") && (n.setPaintProperty("polygon-preview-fill", "fill-color", l), n.setPaintProperty("polygon-preview-fill", "fill-opacity", u)), n.getLayer("polygon-vertices") && n.setPaintProperty("polygon-vertices", "circle-color", s);
|
|
6480
6492
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6481
6493
|
if (d) {
|
|
6482
|
-
let e =
|
|
6494
|
+
let e = Hn.current, t = [];
|
|
6483
6495
|
if (e?.showArea && a.length >= 3) {
|
|
6484
6496
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6485
6497
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6521,7 +6533,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6521
6533
|
features: t
|
|
6522
6534
|
});
|
|
6523
6535
|
}
|
|
6524
|
-
}, []),
|
|
6536
|
+
}, []), $t = useCallback(() => {
|
|
6525
6537
|
let e = L.current;
|
|
6526
6538
|
if (!e) return;
|
|
6527
6539
|
let t = e.getSource("polygon-preview-source");
|
|
@@ -6539,9 +6551,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6539
6551
|
type: "FeatureCollection",
|
|
6540
6552
|
features: []
|
|
6541
6553
|
});
|
|
6542
|
-
}, []),
|
|
6543
|
-
ft.current = [],
|
|
6544
|
-
}, [
|
|
6554
|
+
}, []), en = useCallback(() => {
|
|
6555
|
+
ft.current = [], $t();
|
|
6556
|
+
}, [$t]), tn = useCallback(() => {
|
|
6545
6557
|
let e = L.current;
|
|
6546
6558
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6547
6559
|
type: "geojson",
|
|
@@ -6566,8 +6578,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6566
6578
|
"line-width": 2,
|
|
6567
6579
|
"line-dasharray": [4, 4]
|
|
6568
6580
|
}
|
|
6569
|
-
}),
|
|
6570
|
-
}, [
|
|
6581
|
+
}), Vt(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6582
|
+
}, [Vt]), nn = useCallback((e, t) => {
|
|
6571
6583
|
let [n, r] = e, i = t / 2 / 6371e3, a = r * Math.PI / 180, o = i * 180 / Math.PI, s = i * 180 / Math.PI / Math.cos(a);
|
|
6572
6584
|
return [
|
|
6573
6585
|
[n - s, r + o],
|
|
@@ -6576,12 +6588,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6576
6588
|
[n - s, r - o],
|
|
6577
6589
|
[n - s, r + o]
|
|
6578
6590
|
];
|
|
6579
|
-
}, []),
|
|
6591
|
+
}, []), rn = useCallback((e, t) => {
|
|
6580
6592
|
let n = L.current;
|
|
6581
6593
|
if (!n) return;
|
|
6582
6594
|
let r = n.getSource("square-preview-source");
|
|
6583
6595
|
if (!r) return;
|
|
6584
|
-
let i =
|
|
6596
|
+
let i = qt(e, t) * 2, a = nn(e, i);
|
|
6585
6597
|
r.setData({
|
|
6586
6598
|
type: "Feature",
|
|
6587
6599
|
geometry: {
|
|
@@ -6594,7 +6606,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6594
6606
|
n.getLayer("square-preview-line") && (n.setPaintProperty("square-preview-line", "line-color", s), n.setPaintProperty("square-preview-line", "line-width", c)), n.getLayer("square-preview-fill") && (n.setPaintProperty("square-preview-fill", "fill-color", l), n.setPaintProperty("square-preview-fill", "fill-opacity", u));
|
|
6595
6607
|
let d = n.getSource("square-preview-measure-source");
|
|
6596
6608
|
if (d) {
|
|
6597
|
-
let t =
|
|
6609
|
+
let t = Hn.current, n = [];
|
|
6598
6610
|
if (t?.showArea && n.push({
|
|
6599
6611
|
type: "Feature",
|
|
6600
6612
|
geometry: {
|
|
@@ -6618,7 +6630,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6618
6630
|
features: n
|
|
6619
6631
|
});
|
|
6620
6632
|
}
|
|
6621
|
-
}, [
|
|
6633
|
+
}, [qt, nn]), an = useCallback(() => {
|
|
6622
6634
|
let e = L.current;
|
|
6623
6635
|
if (!e) return;
|
|
6624
6636
|
let t = e.getSource("square-preview-source");
|
|
@@ -6631,9 +6643,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6631
6643
|
type: "FeatureCollection",
|
|
6632
6644
|
features: []
|
|
6633
6645
|
});
|
|
6634
|
-
}, []),
|
|
6635
|
-
mt.current = null,
|
|
6636
|
-
}, [
|
|
6646
|
+
}, []), on = useCallback(() => {
|
|
6647
|
+
mt.current = null, an();
|
|
6648
|
+
}, [an]), sn = useCallback(() => {
|
|
6637
6649
|
let e = L.current;
|
|
6638
6650
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6639
6651
|
type: "geojson",
|
|
@@ -6666,8 +6678,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6666
6678
|
"circle-stroke-color": "#ffffff",
|
|
6667
6679
|
"circle-stroke-width": 2
|
|
6668
6680
|
}
|
|
6669
|
-
}),
|
|
6670
|
-
}, [
|
|
6681
|
+
}), Vt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
6682
|
+
}, [Vt]), cn = useCallback((e, t) => {
|
|
6671
6683
|
let n = L.current;
|
|
6672
6684
|
if (!n) return;
|
|
6673
6685
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
@@ -6698,7 +6710,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6698
6710
|
n.getLayer("polyline-preview-line") && (n.setPaintProperty("polyline-preview-line", "line-color", s), n.setPaintProperty("polyline-preview-line", "line-width", c)), n.getLayer("polyline-vertices") && n.setPaintProperty("polyline-vertices", "circle-color", s);
|
|
6699
6711
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6700
6712
|
if (l) {
|
|
6701
|
-
let e =
|
|
6713
|
+
let e = Hn.current, t = [];
|
|
6702
6714
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6703
6715
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6704
6716
|
t.push({
|
|
@@ -6715,7 +6727,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6715
6727
|
features: t
|
|
6716
6728
|
});
|
|
6717
6729
|
}
|
|
6718
|
-
}, []),
|
|
6730
|
+
}, []), ln = useCallback(() => {
|
|
6719
6731
|
let e = L.current;
|
|
6720
6732
|
if (!e) return;
|
|
6721
6733
|
let t = e.getSource("polyline-preview-source");
|
|
@@ -6734,81 +6746,81 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6734
6746
|
features: []
|
|
6735
6747
|
});
|
|
6736
6748
|
}, []), Z = useCallback(() => {
|
|
6737
|
-
gt.current = [],
|
|
6738
|
-
}, [
|
|
6739
|
-
H(e),
|
|
6749
|
+
gt.current = [], ln();
|
|
6750
|
+
}, [ln]), un = useCallback((e) => {
|
|
6751
|
+
H(e), Bt(e), e ? (U("marker"), X(), Xt(), en(), on(), Z()) : U(null);
|
|
6740
6752
|
}, [
|
|
6741
|
-
|
|
6753
|
+
Bt,
|
|
6742
6754
|
X,
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6755
|
+
Xt,
|
|
6756
|
+
en,
|
|
6757
|
+
on,
|
|
6746
6758
|
Z
|
|
6747
|
-
]),
|
|
6759
|
+
]), dn = useCallback((e) => {
|
|
6748
6760
|
if (U(e), e === "rectangle") {
|
|
6749
|
-
H(null), Y(),
|
|
6761
|
+
H(null), Y(), Xt(), en(), on(), Z();
|
|
6750
6762
|
let e = L.current;
|
|
6751
6763
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6752
6764
|
} else if (e === "circle") {
|
|
6753
|
-
H(null), Y(), X(),
|
|
6765
|
+
H(null), Y(), X(), en(), on(), Z();
|
|
6754
6766
|
let e = L.current;
|
|
6755
6767
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6756
6768
|
} else if (e === "polygon") {
|
|
6757
|
-
H(null), Y(), X(),
|
|
6769
|
+
H(null), Y(), X(), Xt(), on(), Z();
|
|
6758
6770
|
let e = L.current;
|
|
6759
6771
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6760
6772
|
} else if (e === "square") {
|
|
6761
|
-
H(null), Y(), X(),
|
|
6773
|
+
H(null), Y(), X(), Xt(), en(), Z();
|
|
6762
6774
|
let e = L.current;
|
|
6763
6775
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6764
6776
|
} else if (e === "polyline") {
|
|
6765
|
-
H(null), Y(), X(),
|
|
6777
|
+
H(null), Y(), X(), Xt(), en(), on();
|
|
6766
6778
|
let e = L.current;
|
|
6767
6779
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6768
|
-
} else e === "marker" ? (X(),
|
|
6780
|
+
} else e === "marker" ? (X(), Xt(), en(), on(), Z()) : (H(null), Y(), X(), Xt(), en(), on(), Z());
|
|
6769
6781
|
}, [
|
|
6770
6782
|
Y,
|
|
6771
6783
|
X,
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6784
|
+
Xt,
|
|
6785
|
+
en,
|
|
6786
|
+
on,
|
|
6775
6787
|
Z
|
|
6776
|
-
]),
|
|
6788
|
+
]), fn = useCallback((e) => {
|
|
6777
6789
|
if (e !== "picker") {
|
|
6778
6790
|
let e = J.value && isFinite(J.value.lng) && isFinite(J.value.lat), t = J.showMarker !== !1;
|
|
6779
|
-
(!e || !t) &&
|
|
6791
|
+
(!e || !t) && Rt(), rt(null);
|
|
6780
6792
|
}
|
|
6781
6793
|
e !== "edit" && (H(null), U(null), X(), Z(), Y()), tt(e);
|
|
6782
6794
|
}, [
|
|
6783
|
-
|
|
6795
|
+
Rt,
|
|
6784
6796
|
Y,
|
|
6785
6797
|
X,
|
|
6786
6798
|
Z
|
|
6787
|
-
]),
|
|
6788
|
-
|
|
6789
|
-
}, [
|
|
6790
|
-
|
|
6791
|
-
})), [
|
|
6799
|
+
]), pn = useCallback(() => V, [V]), mn = useCallback(() => nt, [nt]), hn = useCallback(() => {
|
|
6800
|
+
Rt(), rt(null);
|
|
6801
|
+
}, [Rt]), gn = useCallback((e = {}) => (Nt.current &&= (Nt.current(null), null), new Promise((t) => {
|
|
6802
|
+
Nt.current = t, Pt.current = Ln.current, It(e), fn("picker");
|
|
6803
|
+
})), [fn]);
|
|
6792
6804
|
useEffect(() => {
|
|
6793
6805
|
if (!$e) return;
|
|
6794
6806
|
let e = J.value;
|
|
6795
6807
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6796
6808
|
let t = [e.lng, e.lat];
|
|
6797
|
-
rt(e),
|
|
6809
|
+
rt(e), Lt(t);
|
|
6798
6810
|
}
|
|
6799
6811
|
}, [
|
|
6800
6812
|
J.value,
|
|
6801
|
-
|
|
6813
|
+
Lt,
|
|
6802
6814
|
$e
|
|
6803
6815
|
]);
|
|
6804
|
-
let
|
|
6805
|
-
if (tt("edit"), t && (
|
|
6806
|
-
if (e.mode === "marker") e.markerStyle ? (ut.current = e.markerStyle, lt.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ?
|
|
6816
|
+
let _n = (e) => "mode" in e, vn = useCallback((e, t = !0) => {
|
|
6817
|
+
if (tt("edit"), t && (Rt(), rt(null)), W.current = !0, _n(e)) {
|
|
6818
|
+
if (e.mode === "marker") e.markerStyle ? (ut.current = e.markerStyle, lt.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? Bt({
|
|
6807
6819
|
id: "custom",
|
|
6808
6820
|
name: e.markerStyle.name || "Marker",
|
|
6809
6821
|
icon: e.markerStyle.src,
|
|
6810
6822
|
width: e.markerStyle.width
|
|
6811
|
-
}) : Y()) : e.template && (ut.current = null, lt.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(e.template), U("marker"),
|
|
6823
|
+
}) : Y()) : e.template && (ut.current = null, lt.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(e.template), U("marker"), Bt(e.template));
|
|
6812
6824
|
else if (e.mode === "rectangle") {
|
|
6813
6825
|
lt.current = e.rectangleStyle || null, ut.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(null), U("rectangle"), Y();
|
|
6814
6826
|
let t = L.current;
|
|
@@ -6830,10 +6842,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6830
6842
|
let t = L.current;
|
|
6831
6843
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6832
6844
|
}
|
|
6833
|
-
} else H(e), U("marker"),
|
|
6845
|
+
} else H(e), U("marker"), Bt(e), lt.current = null, ut.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null;
|
|
6834
6846
|
}, [
|
|
6835
|
-
|
|
6836
|
-
|
|
6847
|
+
Rt,
|
|
6848
|
+
Bt,
|
|
6837
6849
|
Y
|
|
6838
6850
|
]);
|
|
6839
6851
|
useImperativeHandle(c, () => ({
|
|
@@ -6847,12 +6859,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6847
6859
|
isPopupOpen: kt,
|
|
6848
6860
|
toggleUnitTrajectory: Tt,
|
|
6849
6861
|
flyTo: At,
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6862
|
+
getCenterByIds: jt,
|
|
6863
|
+
flyToEntities: Mt,
|
|
6864
|
+
getMode: pn,
|
|
6865
|
+
setMode: fn,
|
|
6866
|
+
getPickedLocation: mn,
|
|
6867
|
+
clearPickedLocation: hn,
|
|
6868
|
+
startDrawing: vn,
|
|
6856
6869
|
getRenderer: (e) => R.current.get(e),
|
|
6857
6870
|
setEditingEntities: (e) => {
|
|
6858
6871
|
for (let t of xt.current) e.map(String).includes(String(t)) || R.current.get(t)?.setEditing?.(!1);
|
|
@@ -6860,7 +6873,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6860
6873
|
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null), bt(e);
|
|
6861
6874
|
},
|
|
6862
6875
|
getEditingEntities: () => xt.current,
|
|
6863
|
-
startPicking:
|
|
6876
|
+
startPicking: gn,
|
|
6864
6877
|
startRoutePlanning: (e) => {
|
|
6865
6878
|
He.current?.startPlanning(e);
|
|
6866
6879
|
},
|
|
@@ -6876,14 +6889,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6876
6889
|
Tt,
|
|
6877
6890
|
At,
|
|
6878
6891
|
jt,
|
|
6879
|
-
|
|
6880
|
-
dn,
|
|
6892
|
+
Mt,
|
|
6881
6893
|
pn,
|
|
6894
|
+
fn,
|
|
6882
6895
|
mn,
|
|
6883
|
-
|
|
6884
|
-
|
|
6896
|
+
hn,
|
|
6897
|
+
vn,
|
|
6898
|
+
gn
|
|
6885
6899
|
]);
|
|
6886
|
-
let
|
|
6900
|
+
let yn = useCallback(() => {
|
|
6887
6901
|
let e = L.current;
|
|
6888
6902
|
if (!e) return;
|
|
6889
6903
|
let t = new Set(T.map((e) => e.id)), n = new Set(R.current.keys());
|
|
@@ -6927,10 +6941,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6927
6941
|
j,
|
|
6928
6942
|
M,
|
|
6929
6943
|
N
|
|
6930
|
-
]),
|
|
6944
|
+
]), bn = useCallback(() => {
|
|
6931
6945
|
for (let e of R.current.values()) e.destroy();
|
|
6932
6946
|
R.current.clear();
|
|
6933
|
-
}, []),
|
|
6947
|
+
}, []), xn = useCallback((e) => {
|
|
6934
6948
|
let t = e.getStyle();
|
|
6935
6949
|
if (!t?.layers) return;
|
|
6936
6950
|
let n = [
|
|
@@ -6945,10 +6959,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6945
6959
|
"marker-"
|
|
6946
6960
|
];
|
|
6947
6961
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6948
|
-
}, []),
|
|
6962
|
+
}, []), Sn = useCallback((e) => {
|
|
6949
6963
|
let t = C, n = { "raster-opacity": e.opacity ?? 1 }, r = e.brightness ?? t?.brightness, i = e.saturation ?? t?.saturation, a = e.contrast ?? t?.contrast, o = e.hueRotate ?? t?.hueRotate;
|
|
6950
6964
|
return r !== void 0 && (n["raster-brightness-min"] = 0, n["raster-brightness-max"] = r), i !== void 0 && (n["raster-saturation"] = i), a !== void 0 && (n["raster-contrast"] = a), o !== void 0 && (n["raster-hue-rotate"] = o), n;
|
|
6951
|
-
}, [C]),
|
|
6965
|
+
}, [C]), Cn = useCallback((e, t) => {
|
|
6952
6966
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6953
6967
|
type: "raster",
|
|
6954
6968
|
tiles: [t.url],
|
|
@@ -6958,19 +6972,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6958
6972
|
scheme: t.scheme ?? "xyz"
|
|
6959
6973
|
};
|
|
6960
6974
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6961
|
-
let a =
|
|
6975
|
+
let a = xn(e);
|
|
6962
6976
|
e.addLayer({
|
|
6963
6977
|
id: r,
|
|
6964
6978
|
type: "raster",
|
|
6965
6979
|
source: n,
|
|
6966
|
-
paint:
|
|
6980
|
+
paint: Sn(t),
|
|
6967
6981
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6968
6982
|
}, a);
|
|
6969
|
-
}, [
|
|
6983
|
+
}, [xn, Sn]), wn = useCallback(async (e, t) => {
|
|
6970
6984
|
try {
|
|
6971
6985
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6972
6986
|
if (!We.current.has(t.id)) return;
|
|
6973
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
6987
|
+
let a = n.format === "pbf" || n.vector_layers, o = xn(e);
|
|
6974
6988
|
if (a) {
|
|
6975
6989
|
let t = {
|
|
6976
6990
|
type: "vector",
|
|
@@ -6991,13 +7005,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6991
7005
|
id: i,
|
|
6992
7006
|
type: "raster",
|
|
6993
7007
|
source: r,
|
|
6994
|
-
paint:
|
|
7008
|
+
paint: Sn(t),
|
|
6995
7009
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6996
7010
|
}, o);
|
|
6997
7011
|
} catch (e) {
|
|
6998
7012
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
6999
7013
|
}
|
|
7000
|
-
}, [
|
|
7014
|
+
}, [xn, Sn]), Tn = useCallback(async (e, t) => {
|
|
7001
7015
|
try {
|
|
7002
7016
|
let n = await (await fetch(t.url)).json();
|
|
7003
7017
|
if (!We.current.has(t.id)) return;
|
|
@@ -7005,7 +7019,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7005
7019
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
7006
7020
|
e.getSource(n) || e.addSource(n, i);
|
|
7007
7021
|
}
|
|
7008
|
-
let r =
|
|
7022
|
+
let r = xn(e);
|
|
7009
7023
|
if (n.layers) for (let i of n.layers) {
|
|
7010
7024
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
7011
7025
|
if (e.getLayer(n)) continue;
|
|
@@ -7016,7 +7030,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7016
7030
|
};
|
|
7017
7031
|
i.type === "raster" && (a.paint = {
|
|
7018
7032
|
...a.paint,
|
|
7019
|
-
...
|
|
7033
|
+
...Sn(t)
|
|
7020
7034
|
}), t.visible === !1 && (a.layout = {
|
|
7021
7035
|
...a.layout,
|
|
7022
7036
|
visibility: "none"
|
|
@@ -7029,50 +7043,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7029
7043
|
} catch (e) {
|
|
7030
7044
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
7031
7045
|
}
|
|
7032
|
-
}, [
|
|
7046
|
+
}, [xn, Sn]), En = useCallback((e, t) => {
|
|
7033
7047
|
let n = e.getStyle();
|
|
7034
7048
|
if (!n) return;
|
|
7035
7049
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
7036
7050
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
7037
7051
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7038
7052
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7039
|
-
}, []),
|
|
7053
|
+
}, []), Dn = useCallback((e) => {
|
|
7040
7054
|
let t = L.current;
|
|
7041
7055
|
if (!t) return;
|
|
7042
7056
|
let n = new Set(e.map((e) => e.id)), r = We.current;
|
|
7043
|
-
for (let e of r) n.has(e) || (
|
|
7057
|
+
for (let e of r) n.has(e) || (En(t, e), r.delete(e));
|
|
7044
7058
|
for (let n of e) if (r.has(n.id)) {
|
|
7045
7059
|
let e = `base-layer-${n.id}`;
|
|
7046
7060
|
if (t.getLayer(e)) {
|
|
7047
|
-
let r =
|
|
7061
|
+
let r = Sn(n);
|
|
7048
7062
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7049
7063
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7050
7064
|
}
|
|
7051
7065
|
} else switch (r.add(n.id), n.type) {
|
|
7052
7066
|
case "raster":
|
|
7053
|
-
|
|
7067
|
+
Cn(t, n);
|
|
7054
7068
|
break;
|
|
7055
7069
|
case "tilejson":
|
|
7056
|
-
|
|
7070
|
+
wn(t, n);
|
|
7057
7071
|
break;
|
|
7058
7072
|
case "style":
|
|
7059
|
-
|
|
7073
|
+
Tn(t, n);
|
|
7060
7074
|
break;
|
|
7061
7075
|
default: {
|
|
7062
7076
|
let e = n;
|
|
7063
|
-
e.url &&
|
|
7077
|
+
e.url && Cn(t, {
|
|
7064
7078
|
...e,
|
|
7065
7079
|
type: "raster"
|
|
7066
7080
|
});
|
|
7067
7081
|
}
|
|
7068
7082
|
}
|
|
7069
7083
|
}, [
|
|
7070
|
-
Sn,
|
|
7071
7084
|
Cn,
|
|
7072
7085
|
wn,
|
|
7073
7086
|
Tn,
|
|
7074
|
-
|
|
7075
|
-
|
|
7087
|
+
En,
|
|
7088
|
+
Sn
|
|
7089
|
+
]), On = useCallback((e) => {
|
|
7076
7090
|
let t = e;
|
|
7077
7091
|
for (; t;) {
|
|
7078
7092
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7080,33 +7094,33 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7080
7094
|
t = t.parentElement;
|
|
7081
7095
|
}
|
|
7082
7096
|
return null;
|
|
7083
|
-
}, []),
|
|
7097
|
+
}, []), kn = useCallback((e) => {
|
|
7084
7098
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7085
7099
|
x: e.point.x,
|
|
7086
7100
|
y: e.point.y
|
|
7087
|
-
}, r =
|
|
7101
|
+
}, r = Ln.current;
|
|
7088
7102
|
if (r === "picker") {
|
|
7089
7103
|
let e = {
|
|
7090
7104
|
lng: t[0],
|
|
7091
7105
|
lat: t[1]
|
|
7092
7106
|
};
|
|
7093
|
-
rt(e),
|
|
7107
|
+
rt(e), Lt(t), Rn.current?.(e), Nt.current && (Nt.current(e), Nt.current = null, It({}), Rt(), rt(null), fn(Pt.current));
|
|
7094
7108
|
return;
|
|
7095
7109
|
}
|
|
7096
7110
|
if (vt.current) return;
|
|
7097
7111
|
if (r === "edit") {
|
|
7098
|
-
let e =
|
|
7112
|
+
let e = Bn.current;
|
|
7099
7113
|
if (e === "rectangle") {
|
|
7100
|
-
let e =
|
|
7114
|
+
let e = Vn.current;
|
|
7101
7115
|
if (!e) ct(t);
|
|
7102
7116
|
else {
|
|
7103
7117
|
let n = lt.current, r = applyEntityConfig({
|
|
7104
7118
|
...n,
|
|
7105
|
-
id: n?.id ??
|
|
7119
|
+
id: n?.id ?? zt(),
|
|
7106
7120
|
type: "rectangle",
|
|
7107
7121
|
bounds: [e, t]
|
|
7108
7122
|
}, D);
|
|
7109
|
-
|
|
7123
|
+
Wt();
|
|
7110
7124
|
let i = L.current;
|
|
7111
7125
|
if (i && !R.current.has(r.id)) {
|
|
7112
7126
|
let e = new RectangleRenderer(i, r, O, k, j, N);
|
|
@@ -7120,14 +7134,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7120
7134
|
let e = dt.current;
|
|
7121
7135
|
if (!e) dt.current = { center: t };
|
|
7122
7136
|
else {
|
|
7123
|
-
let n =
|
|
7137
|
+
let n = qt(e.center, t), r = G.current, i = applyEntityConfig({
|
|
7124
7138
|
...r,
|
|
7125
|
-
id: r?.id ??
|
|
7139
|
+
id: r?.id ?? zt(),
|
|
7126
7140
|
type: "circle",
|
|
7127
7141
|
center: e.center,
|
|
7128
7142
|
radius: n
|
|
7129
7143
|
}, D);
|
|
7130
|
-
|
|
7144
|
+
Yt();
|
|
7131
7145
|
let a = L.current;
|
|
7132
7146
|
if (a && !R.current.has(i.id)) {
|
|
7133
7147
|
let e = new CircleRenderer(a, i, O, k, j, M);
|
|
@@ -7141,14 +7155,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7141
7155
|
let e = ft.current;
|
|
7142
7156
|
if (e.length >= 3) {
|
|
7143
7157
|
let n = e[0];
|
|
7144
|
-
if (
|
|
7158
|
+
if (qt(n, t) < 20) {
|
|
7145
7159
|
let t = K.current, n = applyEntityConfig({
|
|
7146
7160
|
...t,
|
|
7147
|
-
id: t?.id ??
|
|
7161
|
+
id: t?.id ?? zt(),
|
|
7148
7162
|
type: "polygon",
|
|
7149
7163
|
coordinates: [...e]
|
|
7150
7164
|
}, D);
|
|
7151
|
-
|
|
7165
|
+
$t();
|
|
7152
7166
|
let r = L.current;
|
|
7153
7167
|
if (r && !R.current.has(n.id)) {
|
|
7154
7168
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
@@ -7165,14 +7179,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7165
7179
|
let e = mt.current;
|
|
7166
7180
|
if (!e) mt.current = { center: t };
|
|
7167
7181
|
else {
|
|
7168
|
-
let n =
|
|
7182
|
+
let n = qt(e.center, t) * 2, r = pt.current, i = applyEntityConfig({
|
|
7169
7183
|
...r,
|
|
7170
|
-
id: r?.id ??
|
|
7184
|
+
id: r?.id ?? zt(),
|
|
7171
7185
|
type: "square",
|
|
7172
7186
|
center: e.center,
|
|
7173
7187
|
length: n
|
|
7174
7188
|
}, D);
|
|
7175
|
-
|
|
7189
|
+
an();
|
|
7176
7190
|
let a = L.current;
|
|
7177
7191
|
if (a && !R.current.has(i.id)) {
|
|
7178
7192
|
let e = new SquareRenderer(a, i, O, k, j, N);
|
|
@@ -7190,7 +7204,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7190
7204
|
if (n && n.src && n.width) {
|
|
7191
7205
|
let e = {
|
|
7192
7206
|
...n,
|
|
7193
|
-
id: n.id ??
|
|
7207
|
+
id: n.id ?? zt(),
|
|
7194
7208
|
type: "marker",
|
|
7195
7209
|
center: t,
|
|
7196
7210
|
src: n.src,
|
|
@@ -7199,10 +7213,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7199
7213
|
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), ut.current = null, W.current = !1;
|
|
7200
7214
|
return;
|
|
7201
7215
|
}
|
|
7202
|
-
let r =
|
|
7216
|
+
let r = zn.current;
|
|
7203
7217
|
if (r) {
|
|
7204
7218
|
let e = {
|
|
7205
|
-
id:
|
|
7219
|
+
id: zt(),
|
|
7206
7220
|
type: "marker",
|
|
7207
7221
|
name: r.name,
|
|
7208
7222
|
center: t,
|
|
@@ -7247,7 +7261,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7247
7261
|
}
|
|
7248
7262
|
}
|
|
7249
7263
|
}
|
|
7250
|
-
let i =
|
|
7264
|
+
let i = Pn.current, a = Fn.current, o = In.current, s = On(e.originalEvent.target);
|
|
7251
7265
|
if (s) {
|
|
7252
7266
|
let e = i.find((e) => String(e.id) === s);
|
|
7253
7267
|
if (e) {
|
|
@@ -7284,25 +7298,25 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7284
7298
|
}, [
|
|
7285
7299
|
I,
|
|
7286
7300
|
Pe,
|
|
7287
|
-
|
|
7288
|
-
]),
|
|
7301
|
+
On
|
|
7302
|
+
]), An = useCallback((e) => {
|
|
7289
7303
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7290
7304
|
if (q.current) {
|
|
7291
7305
|
let { entityId: e, activeHandle: n } = q.current;
|
|
7292
7306
|
R.current.get(e)?.updateEditPreview?.(n, t);
|
|
7293
7307
|
return;
|
|
7294
7308
|
}
|
|
7295
|
-
let n =
|
|
7296
|
-
n === "rectangle" && r &&
|
|
7309
|
+
let n = Bn.current, r = Vn.current;
|
|
7310
|
+
n === "rectangle" && r && Ut(r, t);
|
|
7297
7311
|
let i = dt.current;
|
|
7298
|
-
n === "circle" && i &&
|
|
7312
|
+
n === "circle" && i && Jt(i.center, t);
|
|
7299
7313
|
let a = ft.current;
|
|
7300
|
-
n === "polygon" && a.length > 0 &&
|
|
7314
|
+
n === "polygon" && a.length > 0 && Qt(a, t);
|
|
7301
7315
|
let o = mt.current;
|
|
7302
|
-
n === "square" && o &&
|
|
7316
|
+
n === "square" && o && rn(o.center, t);
|
|
7303
7317
|
let s = gt.current;
|
|
7304
|
-
n === "polyline" && s.length > 0 &&
|
|
7305
|
-
let c =
|
|
7318
|
+
n === "polyline" && s.length > 0 && cn(s, t);
|
|
7319
|
+
let c = Pn.current, l = In.current;
|
|
7306
7320
|
for (let [e, n] of R.current) if (n.isPointInEntity(t)) {
|
|
7307
7321
|
let t = c.find((t) => t.id === e);
|
|
7308
7322
|
if (!t?.popup) continue;
|
|
@@ -7325,14 +7339,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7325
7339
|
Pe,
|
|
7326
7340
|
B,
|
|
7327
7341
|
Dt,
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
]),
|
|
7334
|
-
if (e.preventDefault(),
|
|
7335
|
-
|
|
7342
|
+
Ut,
|
|
7343
|
+
Jt,
|
|
7344
|
+
Qt,
|
|
7345
|
+
rn,
|
|
7346
|
+
cn
|
|
7347
|
+
]), jn = useCallback((e) => {
|
|
7348
|
+
if (e.preventDefault(), Nt.current) {
|
|
7349
|
+
Nt.current(null), Nt.current = null, It({}), Rt(), rt(null), fn(Pt.current);
|
|
7336
7350
|
return;
|
|
7337
7351
|
}
|
|
7338
7352
|
if (vt.current) return;
|
|
@@ -7354,14 +7368,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7354
7368
|
}
|
|
7355
7369
|
}
|
|
7356
7370
|
}
|
|
7357
|
-
if (
|
|
7358
|
-
if (
|
|
7371
|
+
if (Ln.current !== "edit") return;
|
|
7372
|
+
if (zn.current) {
|
|
7359
7373
|
H(null), U(null), Y();
|
|
7360
7374
|
return;
|
|
7361
7375
|
}
|
|
7362
|
-
let t =
|
|
7376
|
+
let t = Bn.current;
|
|
7363
7377
|
if (t === "rectangle") {
|
|
7364
|
-
if (
|
|
7378
|
+
if (Vn.current) ct(null), Wt();
|
|
7365
7379
|
else {
|
|
7366
7380
|
U(null);
|
|
7367
7381
|
let e = L.current;
|
|
@@ -7370,7 +7384,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7370
7384
|
return;
|
|
7371
7385
|
}
|
|
7372
7386
|
if (t === "circle") {
|
|
7373
|
-
if (dt.current) dt.current = null,
|
|
7387
|
+
if (dt.current) dt.current = null, Yt();
|
|
7374
7388
|
else {
|
|
7375
7389
|
U(null);
|
|
7376
7390
|
let e = L.current;
|
|
@@ -7383,18 +7397,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7383
7397
|
if (e.length >= 3) {
|
|
7384
7398
|
let t = K.current, n = applyEntityConfig({
|
|
7385
7399
|
...t,
|
|
7386
|
-
id: t?.id ??
|
|
7400
|
+
id: t?.id ?? zt(),
|
|
7387
7401
|
type: "polygon",
|
|
7388
7402
|
coordinates: [...e]
|
|
7389
7403
|
}, D);
|
|
7390
|
-
|
|
7404
|
+
$t();
|
|
7391
7405
|
let r = L.current;
|
|
7392
7406
|
if (r && !R.current.has(n.id)) {
|
|
7393
7407
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7394
7408
|
R.current.set(n.id, e);
|
|
7395
7409
|
}
|
|
7396
7410
|
Q.current.onPolygonAdd?.(n), ft.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7397
|
-
} else if (e.length > 0) ft.current = [],
|
|
7411
|
+
} else if (e.length > 0) ft.current = [], $t();
|
|
7398
7412
|
else {
|
|
7399
7413
|
U(null);
|
|
7400
7414
|
let e = L.current;
|
|
@@ -7403,7 +7417,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7403
7417
|
return;
|
|
7404
7418
|
}
|
|
7405
7419
|
if (t === "square") {
|
|
7406
|
-
if (mt.current) mt.current = null,
|
|
7420
|
+
if (mt.current) mt.current = null, an();
|
|
7407
7421
|
else {
|
|
7408
7422
|
U(null);
|
|
7409
7423
|
let e = L.current;
|
|
@@ -7416,18 +7430,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7416
7430
|
if (e.length >= 2) {
|
|
7417
7431
|
let t = ht.current, n = applyEntityConfig({
|
|
7418
7432
|
...t,
|
|
7419
|
-
id: t?.id ??
|
|
7433
|
+
id: t?.id ?? zt(),
|
|
7420
7434
|
type: "polyline",
|
|
7421
7435
|
coordinates: [...e]
|
|
7422
7436
|
}, D);
|
|
7423
|
-
|
|
7437
|
+
ln();
|
|
7424
7438
|
let r = L.current;
|
|
7425
7439
|
if (r && !R.current.has(n.id)) {
|
|
7426
7440
|
let e = new PolylineRenderer(r, n, O, k, N);
|
|
7427
7441
|
R.current.set(n.id, e);
|
|
7428
7442
|
}
|
|
7429
7443
|
Q.current.onPolylineAdd?.(n), gt.current = [], ht.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7430
|
-
} else if (e.length > 0) gt.current = [],
|
|
7444
|
+
} else if (e.length > 0) gt.current = [], ln();
|
|
7431
7445
|
else {
|
|
7432
7446
|
U(null);
|
|
7433
7447
|
let e = L.current;
|
|
@@ -7438,11 +7452,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7438
7452
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7439
7453
|
x: e.point.x,
|
|
7440
7454
|
y: e.point.y
|
|
7441
|
-
}, i =
|
|
7455
|
+
}, i = Pn.current, a = On(e.originalEvent.target);
|
|
7442
7456
|
if (a) {
|
|
7443
7457
|
let e = i.find((e) => String(e.id) === a);
|
|
7444
7458
|
if (e) {
|
|
7445
|
-
|
|
7459
|
+
Mn(e, r, n);
|
|
7446
7460
|
return;
|
|
7447
7461
|
}
|
|
7448
7462
|
}
|
|
@@ -7451,7 +7465,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7451
7465
|
if (o && L.current?.getLayer(o) && L.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7452
7466
|
let e = i.find((e) => e.id === t);
|
|
7453
7467
|
if (e) {
|
|
7454
|
-
|
|
7468
|
+
Mn(e, r, n);
|
|
7455
7469
|
return;
|
|
7456
7470
|
}
|
|
7457
7471
|
}
|
|
@@ -7459,19 +7473,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7459
7473
|
for (let [e, t] of R.current) if (t.isPointInEntity(n)) {
|
|
7460
7474
|
let t = i.find((t) => t.id === e);
|
|
7461
7475
|
if (t) {
|
|
7462
|
-
|
|
7476
|
+
Mn(t, r, n);
|
|
7463
7477
|
return;
|
|
7464
7478
|
}
|
|
7465
7479
|
}
|
|
7466
7480
|
}, [
|
|
7467
|
-
|
|
7481
|
+
On,
|
|
7468
7482
|
Y,
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
]),
|
|
7483
|
+
Wt,
|
|
7484
|
+
Yt,
|
|
7485
|
+
$t,
|
|
7486
|
+
an,
|
|
7487
|
+
ln
|
|
7488
|
+
]), Mn = useCallback((e, t, n) => {
|
|
7475
7489
|
let r = Ve.current?.getBoundingClientRect(), i = r ? {
|
|
7476
7490
|
x: t.x + r.left,
|
|
7477
7491
|
y: t.y + r.top
|
|
@@ -7496,7 +7510,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7496
7510
|
}
|
|
7497
7511
|
}]
|
|
7498
7512
|
});
|
|
7499
|
-
}, []),
|
|
7513
|
+
}, []), Nn = useCallback(() => {
|
|
7500
7514
|
Xe(null);
|
|
7501
7515
|
}, []);
|
|
7502
7516
|
useEffect(() => {
|
|
@@ -7526,57 +7540,57 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7526
7540
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7527
7541
|
};
|
|
7528
7542
|
}, [I?.zIndex]);
|
|
7529
|
-
let
|
|
7530
|
-
|
|
7531
|
-
let
|
|
7532
|
-
|
|
7533
|
-
let
|
|
7534
|
-
|
|
7535
|
-
let
|
|
7536
|
-
|
|
7537
|
-
let
|
|
7538
|
-
|
|
7539
|
-
let
|
|
7540
|
-
|
|
7541
|
-
let
|
|
7542
|
-
|
|
7543
|
-
let
|
|
7544
|
-
|
|
7543
|
+
let Pn = useRef(T);
|
|
7544
|
+
Pn.current = T;
|
|
7545
|
+
let Fn = useRef(Ie);
|
|
7546
|
+
Fn.current = Ie;
|
|
7547
|
+
let In = useRef(Et);
|
|
7548
|
+
In.current = Et;
|
|
7549
|
+
let Ln = useRef(V);
|
|
7550
|
+
Ln.current = V;
|
|
7551
|
+
let Rn = useRef(b);
|
|
7552
|
+
Rn.current = b;
|
|
7553
|
+
let zn = useRef(at);
|
|
7554
|
+
zn.current = at;
|
|
7555
|
+
let Bn = useRef(ot);
|
|
7556
|
+
Bn.current = ot;
|
|
7557
|
+
let Vn = useRef(st);
|
|
7558
|
+
Vn.current = st;
|
|
7545
7559
|
let Q = useRef(v);
|
|
7546
7560
|
Q.current = v;
|
|
7547
|
-
let
|
|
7548
|
-
|
|
7561
|
+
let Hn = useRef(D);
|
|
7562
|
+
Hn.current = D, useEffect(() => {
|
|
7549
7563
|
let e = (e) => {
|
|
7550
7564
|
if (e.key === "Escape" && q.current) {
|
|
7551
7565
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7552
7566
|
return;
|
|
7553
7567
|
}
|
|
7554
7568
|
if (e.key === "Escape" && V === "edit") {
|
|
7555
|
-
if (at && (H(null), U(null), Y()), ot === "rectangle") if (st) ct(null),
|
|
7569
|
+
if (at && (H(null), U(null), Y()), ot === "rectangle") if (st) ct(null), Wt();
|
|
7556
7570
|
else {
|
|
7557
7571
|
U(null);
|
|
7558
7572
|
let e = L.current;
|
|
7559
7573
|
e && (e.getCanvas().style.cursor = "");
|
|
7560
7574
|
}
|
|
7561
|
-
if (ot === "circle") if (dt.current) dt.current = null,
|
|
7575
|
+
if (ot === "circle") if (dt.current) dt.current = null, Yt();
|
|
7562
7576
|
else {
|
|
7563
7577
|
U(null);
|
|
7564
7578
|
let e = L.current;
|
|
7565
7579
|
e && (e.getCanvas().style.cursor = "");
|
|
7566
7580
|
}
|
|
7567
|
-
if (ot === "polygon") if (ft.current.length > 0) ft.current = [],
|
|
7581
|
+
if (ot === "polygon") if (ft.current.length > 0) ft.current = [], $t();
|
|
7568
7582
|
else {
|
|
7569
7583
|
U(null);
|
|
7570
7584
|
let e = L.current;
|
|
7571
7585
|
e && (e.getCanvas().style.cursor = "");
|
|
7572
7586
|
}
|
|
7573
|
-
if (ot === "square") if (mt.current) mt.current = null,
|
|
7587
|
+
if (ot === "square") if (mt.current) mt.current = null, an();
|
|
7574
7588
|
else {
|
|
7575
7589
|
U(null);
|
|
7576
7590
|
let e = L.current;
|
|
7577
7591
|
e && (e.getCanvas().style.cursor = "");
|
|
7578
7592
|
}
|
|
7579
|
-
if (ot === "polyline") if (gt.current.length > 0) gt.current = [],
|
|
7593
|
+
if (ot === "polyline") if (gt.current.length > 0) gt.current = [], ln();
|
|
7580
7594
|
else {
|
|
7581
7595
|
U(null);
|
|
7582
7596
|
let e = L.current;
|
|
@@ -7593,16 +7607,16 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7593
7607
|
ot,
|
|
7594
7608
|
st,
|
|
7595
7609
|
Y,
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7610
|
+
Wt,
|
|
7611
|
+
Yt,
|
|
7612
|
+
$t,
|
|
7613
|
+
an,
|
|
7614
|
+
ln
|
|
7601
7615
|
]), useEffect(() => {
|
|
7602
7616
|
let e = L.current;
|
|
7603
7617
|
if (!e || !B) return;
|
|
7604
7618
|
let t = B.entityId, n = B.config, r = () => {
|
|
7605
|
-
let r =
|
|
7619
|
+
let r = Pn.current.find((e) => e.id === t);
|
|
7606
7620
|
if (!r) {
|
|
7607
7621
|
Ot();
|
|
7608
7622
|
return;
|
|
@@ -7621,7 +7635,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7621
7635
|
let n = Ye.lngLat, r = () => {
|
|
7622
7636
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7623
7637
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7624
|
-
|
|
7638
|
+
Nn();
|
|
7625
7639
|
return;
|
|
7626
7640
|
}
|
|
7627
7641
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
@@ -7630,7 +7644,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7630
7644
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7631
7645
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7632
7646
|
};
|
|
7633
|
-
}, [Ye?.lngLat,
|
|
7647
|
+
}, [Ye?.lngLat, Nn]), useEffect(() => {
|
|
7634
7648
|
if (!Ve.current) return;
|
|
7635
7649
|
let e = {
|
|
7636
7650
|
version: 8,
|
|
@@ -7671,9 +7685,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7671
7685
|
}
|
|
7672
7686
|
z.current.clear(), T.forEach((e) => {
|
|
7673
7687
|
z.current.set(e.id, e);
|
|
7674
|
-
}),
|
|
7675
|
-
}), _.on("click",
|
|
7676
|
-
_.off("click",
|
|
7688
|
+
}), Dn(S), yn(), Ht(), Gt(), Zt(), tn(), sn(), et(_), Fe?.(_);
|
|
7689
|
+
}), _.on("click", kn), _.on("mousemove", An), _.on("contextmenu", jn), () => {
|
|
7690
|
+
_.off("click", kn), _.off("mousemove", An), _.off("contextmenu", jn), bn(), Rt(), Y(), X(), Z(), _.remove(), L.current = null;
|
|
7677
7691
|
};
|
|
7678
7692
|
}, []), useEffect(() => {
|
|
7679
7693
|
if (L.current) {
|
|
@@ -7681,53 +7695,53 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7681
7695
|
L.current.once("load", () => {
|
|
7682
7696
|
z.current.clear(), T.forEach((e) => {
|
|
7683
7697
|
z.current.set(e.id, e);
|
|
7684
|
-
}),
|
|
7698
|
+
}), yn();
|
|
7685
7699
|
});
|
|
7686
7700
|
return;
|
|
7687
7701
|
}
|
|
7688
7702
|
z.current.clear(), T.forEach((e) => {
|
|
7689
7703
|
z.current.set(e.id, e);
|
|
7690
|
-
}),
|
|
7704
|
+
}), yn();
|
|
7691
7705
|
}
|
|
7692
|
-
}, [T,
|
|
7693
|
-
!L.current || !L.current.isStyleLoaded() || (
|
|
7706
|
+
}, [T, yn]), useEffect(() => {
|
|
7707
|
+
!L.current || !L.current.isStyleLoaded() || (bn(), yn());
|
|
7694
7708
|
}, [
|
|
7695
7709
|
O,
|
|
7696
7710
|
k,
|
|
7697
7711
|
j,
|
|
7698
7712
|
M,
|
|
7699
7713
|
N,
|
|
7700
|
-
|
|
7701
|
-
|
|
7714
|
+
bn,
|
|
7715
|
+
yn
|
|
7702
7716
|
]), useEffect(() => {
|
|
7703
7717
|
if (L.current) {
|
|
7704
7718
|
if (!L.current.isStyleLoaded()) {
|
|
7705
7719
|
L.current.once("load", () => {
|
|
7706
|
-
|
|
7720
|
+
Dn(S);
|
|
7707
7721
|
});
|
|
7708
7722
|
return;
|
|
7709
7723
|
}
|
|
7710
|
-
|
|
7711
|
-
}
|
|
7712
|
-
}, [S,
|
|
7713
|
-
let
|
|
7714
|
-
|
|
7715
|
-
let
|
|
7716
|
-
|
|
7717
|
-
let
|
|
7718
|
-
|
|
7719
|
-
let
|
|
7720
|
-
|
|
7721
|
-
let
|
|
7722
|
-
|
|
7723
|
-
let
|
|
7724
|
-
|
|
7725
|
-
let
|
|
7726
|
-
|
|
7727
|
-
let
|
|
7728
|
-
|
|
7729
|
-
let
|
|
7730
|
-
|
|
7724
|
+
Dn(S);
|
|
7725
|
+
}
|
|
7726
|
+
}, [S, Dn]);
|
|
7727
|
+
let Un = useRef(void 0), Wn = useRef(!0), Gn = useRef(S);
|
|
7728
|
+
Gn.current = S;
|
|
7729
|
+
let Kn = useRef(Dn);
|
|
7730
|
+
Kn.current = Dn;
|
|
7731
|
+
let qn = useRef(bn);
|
|
7732
|
+
qn.current = bn;
|
|
7733
|
+
let Jn = useRef(yn);
|
|
7734
|
+
Jn.current = yn;
|
|
7735
|
+
let Yn = useRef(Ht);
|
|
7736
|
+
Yn.current = Ht;
|
|
7737
|
+
let Xn = useRef(Gt);
|
|
7738
|
+
Xn.current = Gt;
|
|
7739
|
+
let Zn = useRef(Zt);
|
|
7740
|
+
Zn.current = Zt;
|
|
7741
|
+
let Qn = useRef(tn);
|
|
7742
|
+
Qn.current = tn;
|
|
7743
|
+
let $n = useRef(sn);
|
|
7744
|
+
$n.current = sn, useEffect(() => {
|
|
7731
7745
|
let e = L.current;
|
|
7732
7746
|
if (!e) return;
|
|
7733
7747
|
let t = p || {
|
|
@@ -7735,27 +7749,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7735
7749
|
sources: {},
|
|
7736
7750
|
layers: []
|
|
7737
7751
|
};
|
|
7738
|
-
if (
|
|
7739
|
-
|
|
7752
|
+
if (Wn.current) {
|
|
7753
|
+
Wn.current = !1, Un.current = p;
|
|
7740
7754
|
return;
|
|
7741
7755
|
}
|
|
7742
|
-
|
|
7756
|
+
Un.current !== p && (Un.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7743
7757
|
if (!e.getStyle().glyphs) {
|
|
7744
7758
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7745
7759
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7746
7760
|
}
|
|
7747
|
-
We.current.clear(),
|
|
7761
|
+
We.current.clear(), Kn.current(Gn.current), qn.current(), Jn.current(), Yn.current(), Xn.current(), Zn.current(), Qn.current(), $n.current();
|
|
7748
7762
|
}));
|
|
7749
7763
|
}, [p]), useEffect(() => {
|
|
7750
7764
|
let e = new Set(E.map(String));
|
|
7751
7765
|
for (let [t, n] of R.current) n.setSelected(e.has(String(t)));
|
|
7752
7766
|
}, [E]);
|
|
7753
|
-
let
|
|
7767
|
+
let er = useRef({});
|
|
7754
7768
|
useEffect(() => {
|
|
7755
7769
|
let e = L.current;
|
|
7756
7770
|
if (!e) return;
|
|
7757
|
-
let t =
|
|
7758
|
-
!n && !r && !i && !a || (
|
|
7771
|
+
let t = er.current, n = l && (t.center?.[0] !== l[0] || t.center?.[1] !== l[1]), r = t.zoom !== u, i = t.pitch !== d, a = t.bearing !== f;
|
|
7772
|
+
!n && !r && !i && !a || (er.current = {
|
|
7759
7773
|
center: l,
|
|
7760
7774
|
zoom: u,
|
|
7761
7775
|
pitch: d,
|
|
@@ -7772,7 +7786,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7772
7786
|
d,
|
|
7773
7787
|
f
|
|
7774
7788
|
]);
|
|
7775
|
-
let
|
|
7789
|
+
let tr = (() => Ce === !1 ? null : Ce === !0 ? { enabled: !0 } : Ce)(), nr = (() => P === !1 ? null : P === !0 ? { enabled: !0 } : P)(), rr = (() => we === !1 ? null : we === !0 ? { enabled: !0 } : we)(), $ = (() => {
|
|
7776
7790
|
if (Te === !1) return null;
|
|
7777
7791
|
let e, t, n;
|
|
7778
7792
|
if (S && S.length > 0) {
|
|
@@ -7797,7 +7811,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7797
7811
|
sourceLayer: Te.sourceLayer || t,
|
|
7798
7812
|
classField: Te.classField || n
|
|
7799
7813
|
};
|
|
7800
|
-
})(),
|
|
7814
|
+
})(), ir = (() => F ? F === !0 ? { enabled: !0 } : F : null)(), ar = (() => De ? De === !0 ? { enabled: !0 } : De : null)(), or = (() => je || null)(), sr = useMemo(() => {
|
|
7801
7815
|
let e = [];
|
|
7802
7816
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7803
7817
|
let n = L.current;
|
|
@@ -7807,7 +7821,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7807
7821
|
}
|
|
7808
7822
|
} else e.push(`base-layer-${t.id}`);
|
|
7809
7823
|
return e;
|
|
7810
|
-
}, [S, $e]),
|
|
7824
|
+
}, [S, $e]), cr = useMemo(() => {
|
|
7811
7825
|
if (V !== "picker") return;
|
|
7812
7826
|
let e = J.cursorImage;
|
|
7813
7827
|
if (!e) return;
|
|
@@ -7842,13 +7856,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7842
7856
|
break;
|
|
7843
7857
|
}
|
|
7844
7858
|
return `url(${e.url}) ${i} ${a}, crosshair`;
|
|
7845
|
-
}, [V, J.cursorImage]),
|
|
7859
|
+
}, [V, J.cursorImage]), lr = useMemo(() => cr ? {
|
|
7846
7860
|
...Be,
|
|
7847
|
-
"--mapbox-picker-cursor":
|
|
7848
|
-
} : Be, [Be,
|
|
7861
|
+
"--mapbox-picker-cursor": cr
|
|
7862
|
+
} : Be, [Be, cr]);
|
|
7849
7863
|
return /* @__PURE__ */ jsxs("div", {
|
|
7850
7864
|
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${ze}`,
|
|
7851
|
-
style:
|
|
7865
|
+
style: lr,
|
|
7852
7866
|
children: [
|
|
7853
7867
|
/* @__PURE__ */ jsx("div", {
|
|
7854
7868
|
ref: Ve,
|
|
@@ -7865,14 +7879,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7865
7879
|
})]
|
|
7866
7880
|
}),
|
|
7867
7881
|
/* @__PURE__ */ jsxs("div", {
|
|
7868
|
-
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ||
|
|
7882
|
+
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || or && or.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
|
|
7869
7883
|
children: [
|
|
7870
7884
|
V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7871
7885
|
markerTemplates: v.markerTemplates || [],
|
|
7872
7886
|
selectedTemplate: at,
|
|
7873
|
-
onTemplateSelect:
|
|
7887
|
+
onTemplateSelect: un,
|
|
7874
7888
|
drawMode: ot,
|
|
7875
|
-
onDrawModeChange:
|
|
7889
|
+
onDrawModeChange: dn,
|
|
7876
7890
|
showRectangleTool: v.showRectangleTool,
|
|
7877
7891
|
showCircleTool: v.showCircleTool,
|
|
7878
7892
|
showPolygonTool: v.showPolygonTool,
|
|
@@ -7892,62 +7906,62 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7892
7906
|
className: $?.className,
|
|
7893
7907
|
style: $?.style
|
|
7894
7908
|
}),
|
|
7895
|
-
|
|
7909
|
+
or && or.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7896
7910
|
ref: He,
|
|
7897
7911
|
map: $e,
|
|
7898
|
-
pointCount:
|
|
7899
|
-
showPointCountInput:
|
|
7900
|
-
visualType:
|
|
7901
|
-
onSelectFinished:
|
|
7912
|
+
pointCount: or.pointCount,
|
|
7913
|
+
showPointCountInput: or.showPointCountInput,
|
|
7914
|
+
visualType: or.visualType,
|
|
7915
|
+
onSelectFinished: or.onSelectFinished
|
|
7902
7916
|
})
|
|
7903
7917
|
]
|
|
7904
7918
|
}),
|
|
7905
|
-
(
|
|
7919
|
+
(tr?.enabled !== !1 || nr?.enabled !== !1 || rr?.enabled !== !1 || ir && ir.enabled !== !1 || ar && ar.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7906
7920
|
className: "comp-mapbox__controls",
|
|
7907
7921
|
children: [
|
|
7908
|
-
|
|
7922
|
+
tr && tr.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7909
7923
|
map: $e,
|
|
7910
|
-
precision:
|
|
7911
|
-
className: er.className,
|
|
7912
|
-
style: er.style
|
|
7913
|
-
}),
|
|
7914
|
-
tr && tr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7915
|
-
map: $e,
|
|
7916
|
-
maxWidth: tr.maxWidth,
|
|
7917
|
-
unit: tr.unit,
|
|
7924
|
+
precision: tr.precision,
|
|
7918
7925
|
className: tr.className,
|
|
7919
7926
|
style: tr.style
|
|
7920
7927
|
}),
|
|
7921
|
-
|
|
7928
|
+
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7929
|
+
map: $e,
|
|
7930
|
+
maxWidth: nr.maxWidth,
|
|
7931
|
+
unit: nr.unit,
|
|
7932
|
+
className: nr.className,
|
|
7933
|
+
style: nr.style
|
|
7934
|
+
}),
|
|
7935
|
+
ir && ir.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7922
7936
|
map: $e,
|
|
7923
7937
|
entityConfig: D,
|
|
7924
7938
|
onDrawModeChange: (e) => {
|
|
7925
7939
|
vt.current = e;
|
|
7926
7940
|
},
|
|
7927
|
-
className:
|
|
7928
|
-
style:
|
|
7941
|
+
className: ir.className,
|
|
7942
|
+
style: ir.style
|
|
7929
7943
|
}),
|
|
7930
|
-
|
|
7944
|
+
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7931
7945
|
map: $e,
|
|
7932
7946
|
value: C,
|
|
7933
7947
|
onChange: Me,
|
|
7934
|
-
rasterPaintLayerIds:
|
|
7935
|
-
className:
|
|
7936
|
-
style:
|
|
7948
|
+
rasterPaintLayerIds: sr,
|
|
7949
|
+
className: ar.className,
|
|
7950
|
+
style: ar.style
|
|
7937
7951
|
}),
|
|
7938
|
-
|
|
7952
|
+
rr && rr.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7939
7953
|
map: $e,
|
|
7940
7954
|
initialCenter: l,
|
|
7941
7955
|
initialZoom: u,
|
|
7942
7956
|
initialPitch: d,
|
|
7943
7957
|
initialBearing: f,
|
|
7944
|
-
duration:
|
|
7945
|
-
className:
|
|
7946
|
-
style:
|
|
7958
|
+
duration: rr.duration,
|
|
7959
|
+
className: rr.className,
|
|
7960
|
+
style: rr.style
|
|
7947
7961
|
})
|
|
7948
7962
|
]
|
|
7949
7963
|
}),
|
|
7950
|
-
!(
|
|
7964
|
+
!(or && or.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7951
7965
|
ref: He,
|
|
7952
7966
|
map: $e,
|
|
7953
7967
|
showButton: !1
|
|
@@ -7960,7 +7974,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7960
7974
|
}),
|
|
7961
7975
|
Ye && Ze.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7962
7976
|
menuState: Ye,
|
|
7963
|
-
onClose:
|
|
7977
|
+
onClose: Nn,
|
|
7964
7978
|
portalContainer: Ze.current,
|
|
7965
7979
|
menuRef: Qe
|
|
7966
7980
|
})
|