bbl-mapbox-react 0.0.25 → 0.0.27
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 +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +235 -227
- package/dist/types.d.ts +21 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5937,11 +5937,11 @@ function adjustPopupForBounds(e, t) {
|
|
|
5937
5937
|
return r.x + t.width + 10 > n.width && (r.x = n.width - t.width - 10), r.x < 10 && (r.x = 10), r.y + t.height + 10 > n.height && (r.y = n.height - t.height - 10), r.y < 10 && (r.y = 10), r;
|
|
5938
5938
|
}
|
|
5939
5939
|
const Mapbox = forwardRef((e, c) => {
|
|
5940
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: M, circleConfig: N, lengthConfig: P, showCoordinates: Se = !0, showScale: F = !0, showResetView: Ce = !0, showRoadHighlight: we = !1, showMeasure: I = !1, showRasterPaint: Ee = !1, showRoutePlanning: Ae, onRasterPaintChange: je, popupDefaults: L, renderPopup: Ne, onMapLoad: Pe, onEntityClick: Fe, onPopupOpen: Ie, onPopupClose: Le, className: Re = "", containerStyle: ze } = e, Be = useRef(null), Ve = useRef(null), He = useRef(null), R = useRef(null), z = useRef(/* @__PURE__ */ new Map()), B = useRef(/* @__PURE__ */ new Map()), Ue = useRef(/* @__PURE__ */ new Set()), [V, We] = useState(null), Ge = useRef(null), Ke = useRef(null), qe = useRef(null), [Je, Ye] = useState(null), Xe = useRef(null), Ze = useRef(null), [
|
|
5940
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: M, circleConfig: N, lengthConfig: P, showCoordinates: Se = !0, showScale: F = !0, showResetView: Ce = !0, showRoadHighlight: we = !1, showMeasure: I = !1, showRasterPaint: Ee = !1, showRoutePlanning: Ae, onRasterPaintChange: je, popupDefaults: L, renderPopup: Ne, onMapLoad: Pe, onEntityClick: Fe, onPopupOpen: Ie, onPopupClose: Le, className: Re = "", containerStyle: ze } = e, Be = useRef(null), Ve = useRef(null), He = useRef(null), R = useRef(null), z = useRef(/* @__PURE__ */ new Map()), B = useRef(/* @__PURE__ */ new Map()), Ue = useRef(/* @__PURE__ */ new Set()), [V, We] = useState(null), Ge = useRef(null), Ke = useRef(null), qe = useRef(null), [Je, Ye] = useState(null), Xe = useRef(null), Ze = useRef(null), [Qe, $e] = useState(null), [et, tt] = useState(_), [nt, rt] = useState(null), it = useRef(null), [at, H] = useState(null), [ot, U] = useState(null), [st, ct] = useState(null), W = useRef(!1), G = useRef(null), lt = useRef(null), K = useRef(null), ut = useRef(null), q = useRef(null), dt = useRef([]), ft = useRef(null), pt = useRef(null), mt = useRef(null), ht = useRef([]), gt = useRef(null), _t = useRef(!1), [vt, yt] = useState([]), bt = useRef([]);
|
|
5941
5941
|
bt.current = vt;
|
|
5942
5942
|
let J = useRef(null);
|
|
5943
5943
|
useEffect(() => {
|
|
5944
|
-
|
|
5944
|
+
tt(_);
|
|
5945
5945
|
}, [_]);
|
|
5946
5946
|
let xt = useCallback((e) => {
|
|
5947
5947
|
let t = z.current.get(e), n = B.current.get(e);
|
|
@@ -6057,12 +6057,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6057
6057
|
if (!t || !t.getContainer()) return;
|
|
6058
6058
|
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = y;
|
|
6059
6059
|
if (!n) {
|
|
6060
|
-
|
|
6060
|
+
it.current &&= (it.current.remove(), null);
|
|
6061
6061
|
return;
|
|
6062
6062
|
}
|
|
6063
|
-
if (
|
|
6064
|
-
|
|
6065
|
-
let t =
|
|
6063
|
+
if (it.current) {
|
|
6064
|
+
it.current.setLngLat(e);
|
|
6065
|
+
let t = it.current.getElement(), n = t.querySelector(".marker-label");
|
|
6066
6066
|
if (i) {
|
|
6067
6067
|
let e = resolveNameConfig(a, O);
|
|
6068
6068
|
if (n) n.textContent = i, n.style.color = e.fillColor, n.style.opacity = String(e.fillOpacity), n.style.webkitTextStrokeColor = e.strokeColor, n.style.webkitTextStrokeWidth = `${e.strokeWidth}px`;
|
|
@@ -6079,13 +6079,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6079
6079
|
let e = resolveNameConfig(a, O), t = document.createElement("div");
|
|
6080
6080
|
t.className = "marker-label", t.textContent = i, t.style.color = e.fillColor, t.style.opacity = String(e.fillOpacity), t.style.webkitTextStrokeColor = e.strokeColor, t.style.webkitTextStrokeWidth = `${e.strokeWidth}px`, n.appendChild(t);
|
|
6081
6081
|
}
|
|
6082
|
-
|
|
6082
|
+
it.current = new mapboxgl.Marker({
|
|
6083
6083
|
element: n,
|
|
6084
6084
|
anchor: "bottom"
|
|
6085
6085
|
}).setLngLat(e).addTo(t);
|
|
6086
6086
|
}
|
|
6087
6087
|
}, [y, O]), Mt = useCallback(() => {
|
|
6088
|
-
|
|
6088
|
+
it.current &&= (it.current.remove(), null);
|
|
6089
6089
|
}, []), Nt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Pt = useCallback((e) => {
|
|
6090
6090
|
let t = R.current;
|
|
6091
6091
|
if (Be.current) if (gt.current &&= (gt.current.remove(), null), e && t) {
|
|
@@ -6192,11 +6192,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6192
6192
|
},
|
|
6193
6193
|
properties: {}
|
|
6194
6194
|
});
|
|
6195
|
-
let l =
|
|
6195
|
+
let l = G.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6196
6196
|
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));
|
|
6197
6197
|
let m = n.getSource("rect-preview-measure-source");
|
|
6198
6198
|
if (m) {
|
|
6199
|
-
let e =
|
|
6199
|
+
let e = zn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6200
6200
|
if (e?.showArea) {
|
|
6201
6201
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6202
6202
|
t.push({
|
|
@@ -6247,7 +6247,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6247
6247
|
features: []
|
|
6248
6248
|
});
|
|
6249
6249
|
}, []), X = useCallback(() => {
|
|
6250
|
-
|
|
6250
|
+
ct(null), Rt();
|
|
6251
6251
|
}, [Rt]), zt = useCallback(() => {
|
|
6252
6252
|
let e = R.current;
|
|
6253
6253
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
@@ -6316,7 +6316,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6316
6316
|
});
|
|
6317
6317
|
let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6318
6318
|
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));
|
|
6319
|
-
let d =
|
|
6319
|
+
let d = zn.current, f = [], p = [];
|
|
6320
6320
|
if (d?.showArea) {
|
|
6321
6321
|
let t = Math.PI * i * i;
|
|
6322
6322
|
f.push({
|
|
@@ -6460,7 +6460,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6460
6460
|
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);
|
|
6461
6461
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6462
6462
|
if (d) {
|
|
6463
|
-
let e =
|
|
6463
|
+
let e = zn.current, t = [];
|
|
6464
6464
|
if (e?.showArea && a.length >= 3) {
|
|
6465
6465
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6466
6466
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6575,7 +6575,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6575
6575
|
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));
|
|
6576
6576
|
let d = n.getSource("square-preview-measure-source");
|
|
6577
6577
|
if (d) {
|
|
6578
|
-
let t =
|
|
6578
|
+
let t = zn.current, n = [];
|
|
6579
6579
|
if (t?.showArea && n.push({
|
|
6580
6580
|
type: "Feature",
|
|
6581
6581
|
geometry: {
|
|
@@ -6679,7 +6679,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6679
6679
|
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);
|
|
6680
6680
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6681
6681
|
if (l) {
|
|
6682
|
-
let e =
|
|
6682
|
+
let e = zn.current, t = [];
|
|
6683
6683
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6684
6684
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6685
6685
|
t.push({
|
|
@@ -6717,7 +6717,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6717
6717
|
}, []), Z = useCallback(() => {
|
|
6718
6718
|
ht.current = [], nn();
|
|
6719
6719
|
}, [nn]), rn = useCallback((e) => {
|
|
6720
|
-
|
|
6720
|
+
H(e), Pt(e), e ? (U("marker"), X(), Wt(), Jt(), $t(), Z()) : U(null);
|
|
6721
6721
|
}, [
|
|
6722
6722
|
Pt,
|
|
6723
6723
|
X,
|
|
@@ -6726,27 +6726,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6726
6726
|
$t,
|
|
6727
6727
|
Z
|
|
6728
6728
|
]), an = useCallback((e) => {
|
|
6729
|
-
if (
|
|
6730
|
-
|
|
6729
|
+
if (U(e), e === "rectangle") {
|
|
6730
|
+
H(null), Y(), Wt(), Jt(), $t(), Z();
|
|
6731
6731
|
let e = R.current;
|
|
6732
6732
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6733
6733
|
} else if (e === "circle") {
|
|
6734
|
-
|
|
6734
|
+
H(null), Y(), X(), Jt(), $t(), Z();
|
|
6735
6735
|
let e = R.current;
|
|
6736
6736
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6737
6737
|
} else if (e === "polygon") {
|
|
6738
|
-
|
|
6738
|
+
H(null), Y(), X(), Wt(), $t(), Z();
|
|
6739
6739
|
let e = R.current;
|
|
6740
6740
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6741
6741
|
} else if (e === "square") {
|
|
6742
|
-
|
|
6742
|
+
H(null), Y(), X(), Wt(), Jt(), Z();
|
|
6743
6743
|
let e = R.current;
|
|
6744
6744
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6745
6745
|
} else if (e === "polyline") {
|
|
6746
|
-
|
|
6746
|
+
H(null), Y(), X(), Wt(), Jt(), $t();
|
|
6747
6747
|
let e = R.current;
|
|
6748
6748
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6749
|
-
} else e === "marker" ? (X(), Wt(), Jt(), $t(), Z()) : (
|
|
6749
|
+
} else e === "marker" ? (X(), Wt(), Jt(), $t(), Z()) : (H(null), Y(), X(), Wt(), Jt(), $t(), Z());
|
|
6750
6750
|
}, [
|
|
6751
6751
|
Y,
|
|
6752
6752
|
X,
|
|
@@ -6757,59 +6757,61 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6757
6757
|
]), on = useCallback((e) => {
|
|
6758
6758
|
if (e !== "picker") {
|
|
6759
6759
|
let e = y.value && isFinite(y.value.lng) && isFinite(y.value.lat), t = y.showMarker !== !1;
|
|
6760
|
-
(!e || !t) && Mt(),
|
|
6760
|
+
(!e || !t) && Mt(), rt(null);
|
|
6761
6761
|
}
|
|
6762
|
-
e !== "edit" && (
|
|
6762
|
+
e !== "edit" && (H(null), U(null), X(), Z(), Y()), tt(e);
|
|
6763
6763
|
}, [
|
|
6764
6764
|
Mt,
|
|
6765
6765
|
Y,
|
|
6766
6766
|
X,
|
|
6767
6767
|
Z
|
|
6768
|
-
]), sn = useCallback(() =>
|
|
6769
|
-
Mt(),
|
|
6770
|
-
}, [Mt])
|
|
6768
|
+
]), sn = useCallback(() => et, [et]), cn = useCallback(() => nt, [nt]), ln = useCallback(() => {
|
|
6769
|
+
Mt(), rt(null);
|
|
6770
|
+
}, [Mt]), un = useRef(null), dn = useRef("display"), fn = useRef({}), pn = useCallback((e = {}) => (un.current &&= (un.current(null), null), new Promise((t) => {
|
|
6771
|
+
un.current = t, dn.current = Pn.current, fn.current = e, on("picker");
|
|
6772
|
+
})), [on]);
|
|
6771
6773
|
useEffect(() => {
|
|
6772
|
-
if (!
|
|
6774
|
+
if (!Qe) return;
|
|
6773
6775
|
let e = y.value;
|
|
6774
6776
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6775
6777
|
let t = [e.lng, e.lat];
|
|
6776
|
-
|
|
6778
|
+
rt(e), jt(t);
|
|
6777
6779
|
}
|
|
6778
6780
|
}, [
|
|
6779
6781
|
y.value,
|
|
6780
6782
|
jt,
|
|
6781
|
-
|
|
6783
|
+
Qe
|
|
6782
6784
|
]);
|
|
6783
|
-
let
|
|
6784
|
-
if (
|
|
6785
|
-
if (e.mode === "marker") e.markerStyle ? (lt.current = e.markerStyle,
|
|
6785
|
+
let mn = (e) => "mode" in e, hn = useCallback((e, t = !0) => {
|
|
6786
|
+
if (tt("edit"), t && (Mt(), rt(null)), W.current = !0, mn(e)) {
|
|
6787
|
+
if (e.mode === "marker") e.markerStyle ? (lt.current = e.markerStyle, G.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? Pt({
|
|
6786
6788
|
id: "custom",
|
|
6787
6789
|
name: e.markerStyle.name || "Marker",
|
|
6788
6790
|
icon: e.markerStyle.src,
|
|
6789
6791
|
width: e.markerStyle.width
|
|
6790
|
-
}) : Y()) : e.template && (lt.current = null,
|
|
6792
|
+
}) : Y()) : e.template && (lt.current = null, G.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, H(e.template), U("marker"), Pt(e.template));
|
|
6791
6793
|
else if (e.mode === "rectangle") {
|
|
6792
|
-
|
|
6794
|
+
G.current = e.rectangleStyle || null, lt.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, H(null), U("rectangle"), Y();
|
|
6793
6795
|
let t = R.current;
|
|
6794
6796
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6795
6797
|
} else if (e.mode === "circle") {
|
|
6796
|
-
K.current = e.circleStyle || null,
|
|
6798
|
+
K.current = e.circleStyle || null, G.current = null, lt.current = null, q.current = null, ft.current = null, mt.current = null, H(null), U("circle"), Y();
|
|
6797
6799
|
let t = R.current;
|
|
6798
6800
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6799
6801
|
} else if (e.mode === "polygon") {
|
|
6800
|
-
q.current = e.polygonStyle || null,
|
|
6802
|
+
q.current = e.polygonStyle || null, G.current = null, lt.current = null, K.current = null, ft.current = null, mt.current = null, H(null), U("polygon"), Y();
|
|
6801
6803
|
let t = R.current;
|
|
6802
6804
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6803
6805
|
} else if (e.mode === "square") {
|
|
6804
|
-
ft.current = e.squareStyle || null,
|
|
6806
|
+
ft.current = e.squareStyle || null, G.current = null, lt.current = null, K.current = null, q.current = null, mt.current = null, H(null), U("square"), Y();
|
|
6805
6807
|
let t = R.current;
|
|
6806
6808
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6807
6809
|
} else if (e.mode === "polyline") {
|
|
6808
|
-
mt.current = e.polylineStyle || null,
|
|
6810
|
+
mt.current = e.polylineStyle || null, G.current = null, lt.current = null, K.current = null, q.current = null, ft.current = null, H(null), U("polyline"), Y();
|
|
6809
6811
|
let t = R.current;
|
|
6810
6812
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6811
6813
|
}
|
|
6812
|
-
} else
|
|
6814
|
+
} else H(e), U("marker"), Pt(e), G.current = null, lt.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null;
|
|
6813
6815
|
}, [
|
|
6814
6816
|
Mt,
|
|
6815
6817
|
Pt,
|
|
@@ -6831,7 +6833,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6831
6833
|
setMode: on,
|
|
6832
6834
|
getPickedLocation: cn,
|
|
6833
6835
|
clearPickedLocation: ln,
|
|
6834
|
-
startDrawing:
|
|
6836
|
+
startDrawing: hn,
|
|
6835
6837
|
getRenderer: (e) => z.current.get(e),
|
|
6836
6838
|
setEditingEntities: (e) => {
|
|
6837
6839
|
for (let t of bt.current) e.map(String).includes(String(t)) || z.current.get(t)?.setEditing?.(!1);
|
|
@@ -6839,6 +6841,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6839
6841
|
J.current &&= (z.current.get(J.current.entityId)?.cancelEditPreview?.(), null), yt(e);
|
|
6840
6842
|
},
|
|
6841
6843
|
getEditingEntities: () => bt.current,
|
|
6844
|
+
startPicking: pn,
|
|
6842
6845
|
startRoutePlanning: (e) => {
|
|
6843
6846
|
Ve.current?.startPlanning(e);
|
|
6844
6847
|
},
|
|
@@ -6858,9 +6861,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6858
6861
|
on,
|
|
6859
6862
|
cn,
|
|
6860
6863
|
ln,
|
|
6861
|
-
|
|
6864
|
+
hn,
|
|
6865
|
+
pn
|
|
6862
6866
|
]);
|
|
6863
|
-
let
|
|
6867
|
+
let gn = useCallback(() => {
|
|
6864
6868
|
let e = R.current;
|
|
6865
6869
|
if (!e) return;
|
|
6866
6870
|
let t = new Set(T.map((e) => e.id)), n = new Set(z.current.keys());
|
|
@@ -6904,10 +6908,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6904
6908
|
M,
|
|
6905
6909
|
N,
|
|
6906
6910
|
P
|
|
6907
|
-
]),
|
|
6911
|
+
]), _n = useCallback(() => {
|
|
6908
6912
|
for (let e of z.current.values()) e.destroy();
|
|
6909
6913
|
z.current.clear();
|
|
6910
|
-
}, []),
|
|
6914
|
+
}, []), vn = useCallback((e) => {
|
|
6911
6915
|
let t = e.getStyle();
|
|
6912
6916
|
if (!t?.layers) return;
|
|
6913
6917
|
let n = [
|
|
@@ -6922,10 +6926,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6922
6926
|
"marker-"
|
|
6923
6927
|
];
|
|
6924
6928
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6925
|
-
}, []),
|
|
6929
|
+
}, []), yn = useCallback((e) => {
|
|
6926
6930
|
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;
|
|
6927
6931
|
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;
|
|
6928
|
-
}, [C]),
|
|
6932
|
+
}, [C]), bn = useCallback((e, t) => {
|
|
6929
6933
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6930
6934
|
type: "raster",
|
|
6931
6935
|
tiles: [t.url],
|
|
@@ -6935,19 +6939,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6935
6939
|
scheme: t.scheme ?? "xyz"
|
|
6936
6940
|
};
|
|
6937
6941
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6938
|
-
let a =
|
|
6942
|
+
let a = vn(e);
|
|
6939
6943
|
e.addLayer({
|
|
6940
6944
|
id: r,
|
|
6941
6945
|
type: "raster",
|
|
6942
6946
|
source: n,
|
|
6943
|
-
paint:
|
|
6947
|
+
paint: yn(t),
|
|
6944
6948
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6945
6949
|
}, a);
|
|
6946
|
-
}, [
|
|
6950
|
+
}, [vn, yn]), xn = useCallback(async (e, t) => {
|
|
6947
6951
|
try {
|
|
6948
6952
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6949
6953
|
if (!Ue.current.has(t.id)) return;
|
|
6950
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
6954
|
+
let a = n.format === "pbf" || n.vector_layers, o = vn(e);
|
|
6951
6955
|
if (a) {
|
|
6952
6956
|
let t = {
|
|
6953
6957
|
type: "vector",
|
|
@@ -6968,13 +6972,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6968
6972
|
id: i,
|
|
6969
6973
|
type: "raster",
|
|
6970
6974
|
source: r,
|
|
6971
|
-
paint:
|
|
6975
|
+
paint: yn(t),
|
|
6972
6976
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6973
6977
|
}, o);
|
|
6974
6978
|
} catch (e) {
|
|
6975
6979
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
6976
6980
|
}
|
|
6977
|
-
}, [
|
|
6981
|
+
}, [vn, yn]), Sn = useCallback(async (e, t) => {
|
|
6978
6982
|
try {
|
|
6979
6983
|
let n = await (await fetch(t.url)).json();
|
|
6980
6984
|
if (!Ue.current.has(t.id)) return;
|
|
@@ -6982,7 +6986,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6982
6986
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
6983
6987
|
e.getSource(n) || e.addSource(n, i);
|
|
6984
6988
|
}
|
|
6985
|
-
let r =
|
|
6989
|
+
let r = vn(e);
|
|
6986
6990
|
if (n.layers) for (let i of n.layers) {
|
|
6987
6991
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
6988
6992
|
if (e.getLayer(n)) continue;
|
|
@@ -6993,7 +6997,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6993
6997
|
};
|
|
6994
6998
|
i.type === "raster" && (a.paint = {
|
|
6995
6999
|
...a.paint,
|
|
6996
|
-
...
|
|
7000
|
+
...yn(t)
|
|
6997
7001
|
}), t.visible === !1 && (a.layout = {
|
|
6998
7002
|
...a.layout,
|
|
6999
7003
|
visibility: "none"
|
|
@@ -7006,50 +7010,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7006
7010
|
} catch (e) {
|
|
7007
7011
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
7008
7012
|
}
|
|
7009
|
-
}, [
|
|
7013
|
+
}, [vn, yn]), Cn = useCallback((e, t) => {
|
|
7010
7014
|
let n = e.getStyle();
|
|
7011
7015
|
if (!n) return;
|
|
7012
7016
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
7013
7017
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
7014
7018
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7015
7019
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7016
|
-
}, []),
|
|
7020
|
+
}, []), wn = useCallback((e) => {
|
|
7017
7021
|
let t = R.current;
|
|
7018
7022
|
if (!t) return;
|
|
7019
7023
|
let n = new Set(e.map((e) => e.id)), r = Ue.current;
|
|
7020
|
-
for (let e of r) n.has(e) || (
|
|
7024
|
+
for (let e of r) n.has(e) || (Cn(t, e), r.delete(e));
|
|
7021
7025
|
for (let n of e) if (r.has(n.id)) {
|
|
7022
7026
|
let e = `base-layer-${n.id}`;
|
|
7023
7027
|
if (t.getLayer(e)) {
|
|
7024
|
-
let r =
|
|
7028
|
+
let r = yn(n);
|
|
7025
7029
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7026
7030
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7027
7031
|
}
|
|
7028
7032
|
} else switch (r.add(n.id), n.type) {
|
|
7029
7033
|
case "raster":
|
|
7030
|
-
|
|
7034
|
+
bn(t, n);
|
|
7031
7035
|
break;
|
|
7032
7036
|
case "tilejson":
|
|
7033
|
-
|
|
7037
|
+
xn(t, n);
|
|
7034
7038
|
break;
|
|
7035
7039
|
case "style":
|
|
7036
|
-
|
|
7040
|
+
Sn(t, n);
|
|
7037
7041
|
break;
|
|
7038
7042
|
default: {
|
|
7039
7043
|
let e = n;
|
|
7040
|
-
e.url &&
|
|
7044
|
+
e.url && bn(t, {
|
|
7041
7045
|
...e,
|
|
7042
7046
|
type: "raster"
|
|
7043
7047
|
});
|
|
7044
7048
|
}
|
|
7045
7049
|
}
|
|
7046
7050
|
}, [
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
]),
|
|
7051
|
+
bn,
|
|
7052
|
+
xn,
|
|
7053
|
+
Sn,
|
|
7054
|
+
Cn,
|
|
7055
|
+
yn
|
|
7056
|
+
]), Tn = useCallback((e) => {
|
|
7053
7057
|
let t = e;
|
|
7054
7058
|
for (; t;) {
|
|
7055
7059
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7057,27 +7061,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7057
7061
|
t = t.parentElement;
|
|
7058
7062
|
}
|
|
7059
7063
|
return null;
|
|
7060
|
-
}, []),
|
|
7064
|
+
}, []), En = useCallback((e) => {
|
|
7061
7065
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7062
7066
|
x: e.point.x,
|
|
7063
7067
|
y: e.point.y
|
|
7064
|
-
}, r =
|
|
7068
|
+
}, r = Pn.current;
|
|
7065
7069
|
if (r === "picker") {
|
|
7066
7070
|
let e = {
|
|
7067
7071
|
lng: t[0],
|
|
7068
7072
|
lat: t[1]
|
|
7069
7073
|
};
|
|
7070
|
-
|
|
7074
|
+
rt(e), jt(t), Fn.current?.(e), un.current && (un.current(e), un.current = null, Mt(), rt(null), on(dn.current));
|
|
7071
7075
|
return;
|
|
7072
7076
|
}
|
|
7073
7077
|
if (_t.current) return;
|
|
7074
7078
|
if (r === "edit") {
|
|
7075
|
-
let e =
|
|
7079
|
+
let e = Ln.current;
|
|
7076
7080
|
if (e === "rectangle") {
|
|
7077
|
-
let e =
|
|
7078
|
-
if (!e)
|
|
7081
|
+
let e = Rn.current;
|
|
7082
|
+
if (!e) ct(t);
|
|
7079
7083
|
else {
|
|
7080
|
-
let n =
|
|
7084
|
+
let n = G.current, r = applyEntityConfig({
|
|
7081
7085
|
...n,
|
|
7082
7086
|
id: n?.id ?? Nt(),
|
|
7083
7087
|
type: "rectangle",
|
|
@@ -7089,7 +7093,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7089
7093
|
let e = new RectangleRenderer(i, r, O, k, M, P);
|
|
7090
7094
|
z.current.set(r.id, e);
|
|
7091
7095
|
}
|
|
7092
|
-
Q.current.onRectangleAdd?.(r),
|
|
7096
|
+
Q.current.onRectangleAdd?.(r), ct(null), G.current = null, W.current && (W.current = !1, U(null), i && (i.getCanvas().style.cursor = ""));
|
|
7093
7097
|
}
|
|
7094
7098
|
return;
|
|
7095
7099
|
}
|
|
@@ -7110,7 +7114,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7110
7114
|
let e = new CircleRenderer(a, i, O, k, M, N);
|
|
7111
7115
|
z.current.set(i.id, e);
|
|
7112
7116
|
}
|
|
7113
|
-
Q.current.onCircleAdd?.(i), ut.current = null, K.current = null,
|
|
7117
|
+
Q.current.onCircleAdd?.(i), ut.current = null, K.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7114
7118
|
}
|
|
7115
7119
|
return;
|
|
7116
7120
|
}
|
|
@@ -7131,7 +7135,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7131
7135
|
let e = new PolygonRenderer(r, n, O, k, M, P);
|
|
7132
7136
|
z.current.set(n.id, e);
|
|
7133
7137
|
}
|
|
7134
|
-
Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null,
|
|
7138
|
+
Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7135
7139
|
return;
|
|
7136
7140
|
}
|
|
7137
7141
|
}
|
|
@@ -7155,7 +7159,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7155
7159
|
let e = new SquareRenderer(a, i, O, k, M, P);
|
|
7156
7160
|
z.current.set(i.id, e);
|
|
7157
7161
|
}
|
|
7158
|
-
Q.current.onSquareAdd?.(i), pt.current = null, ft.current = null,
|
|
7162
|
+
Q.current.onSquareAdd?.(i), pt.current = null, ft.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7159
7163
|
}
|
|
7160
7164
|
return;
|
|
7161
7165
|
}
|
|
@@ -7173,10 +7177,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7173
7177
|
src: n.src,
|
|
7174
7178
|
width: n.width
|
|
7175
7179
|
};
|
|
7176
|
-
Q.current.onMarkerAdd?.(e),
|
|
7180
|
+
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), lt.current = null, W.current = !1;
|
|
7177
7181
|
return;
|
|
7178
7182
|
}
|
|
7179
|
-
let r =
|
|
7183
|
+
let r = In.current;
|
|
7180
7184
|
if (r) {
|
|
7181
7185
|
let e = {
|
|
7182
7186
|
id: Nt(),
|
|
@@ -7186,7 +7190,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7186
7190
|
src: r.icon,
|
|
7187
7191
|
width: r.size || r.width || 32
|
|
7188
7192
|
};
|
|
7189
|
-
r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e),
|
|
7193
|
+
r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), W.current = !1;
|
|
7190
7194
|
return;
|
|
7191
7195
|
}
|
|
7192
7196
|
}
|
|
@@ -7224,7 +7228,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7224
7228
|
}
|
|
7225
7229
|
}
|
|
7226
7230
|
}
|
|
7227
|
-
let i =
|
|
7231
|
+
let i = jn.current, a = Mn.current, o = Nn.current, s = Tn(e.originalEvent.target);
|
|
7228
7232
|
if (s) {
|
|
7229
7233
|
let e = i.find((e) => String(e.id) === s);
|
|
7230
7234
|
if (e) {
|
|
@@ -7261,15 +7265,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7261
7265
|
}, [
|
|
7262
7266
|
L,
|
|
7263
7267
|
Ne,
|
|
7264
|
-
|
|
7265
|
-
]),
|
|
7268
|
+
Tn
|
|
7269
|
+
]), Dn = useCallback((e) => {
|
|
7266
7270
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7267
7271
|
if (J.current) {
|
|
7268
7272
|
let { entityId: e, activeHandle: n } = J.current;
|
|
7269
7273
|
z.current.get(e)?.updateEditPreview?.(n, t);
|
|
7270
7274
|
return;
|
|
7271
7275
|
}
|
|
7272
|
-
let n =
|
|
7276
|
+
let n = Ln.current, r = Rn.current;
|
|
7273
7277
|
n === "rectangle" && r && Lt(r, t);
|
|
7274
7278
|
let i = ut.current;
|
|
7275
7279
|
n === "circle" && i && Ht(i.center, t);
|
|
@@ -7279,7 +7283,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7279
7283
|
n === "square" && o && Zt(o.center, t);
|
|
7280
7284
|
let s = ht.current;
|
|
7281
7285
|
n === "polyline" && s.length > 0 && tn(s, t);
|
|
7282
|
-
let c =
|
|
7286
|
+
let c = jn.current, l = Nn.current;
|
|
7283
7287
|
for (let [e, n] of z.current) if (n.isPointInEntity(t)) {
|
|
7284
7288
|
let t = c.find((t) => t.id === e);
|
|
7285
7289
|
if (!t?.popup) continue;
|
|
@@ -7307,8 +7311,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7307
7311
|
Kt,
|
|
7308
7312
|
Zt,
|
|
7309
7313
|
tn
|
|
7310
|
-
]),
|
|
7311
|
-
if (e.preventDefault(),
|
|
7314
|
+
]), On = useCallback((e) => {
|
|
7315
|
+
if (e.preventDefault(), un.current) {
|
|
7316
|
+
un.current(null), un.current = null, Mt(), rt(null), on(dn.current);
|
|
7317
|
+
return;
|
|
7318
|
+
}
|
|
7319
|
+
if (_t.current) return;
|
|
7312
7320
|
if (bt.current.length > 0) {
|
|
7313
7321
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7314
7322
|
if (J.current) {
|
|
@@ -7327,16 +7335,16 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7327
7335
|
}
|
|
7328
7336
|
}
|
|
7329
7337
|
}
|
|
7330
|
-
if (
|
|
7331
|
-
if (
|
|
7332
|
-
|
|
7338
|
+
if (Pn.current !== "edit") return;
|
|
7339
|
+
if (In.current) {
|
|
7340
|
+
H(null), U(null), Y();
|
|
7333
7341
|
return;
|
|
7334
7342
|
}
|
|
7335
|
-
let t =
|
|
7343
|
+
let t = Ln.current;
|
|
7336
7344
|
if (t === "rectangle") {
|
|
7337
|
-
if (
|
|
7345
|
+
if (Rn.current) ct(null), Rt();
|
|
7338
7346
|
else {
|
|
7339
|
-
|
|
7347
|
+
U(null);
|
|
7340
7348
|
let e = R.current;
|
|
7341
7349
|
e && (e.getCanvas().style.cursor = "");
|
|
7342
7350
|
}
|
|
@@ -7345,7 +7353,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7345
7353
|
if (t === "circle") {
|
|
7346
7354
|
if (ut.current) ut.current = null, Ut();
|
|
7347
7355
|
else {
|
|
7348
|
-
|
|
7356
|
+
U(null);
|
|
7349
7357
|
let e = R.current;
|
|
7350
7358
|
e && (e.getCanvas().style.cursor = "");
|
|
7351
7359
|
}
|
|
@@ -7366,10 +7374,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7366
7374
|
let e = new PolygonRenderer(r, n, O, k, M, P);
|
|
7367
7375
|
z.current.set(n.id, e);
|
|
7368
7376
|
}
|
|
7369
|
-
Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null,
|
|
7377
|
+
Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7370
7378
|
} else if (e.length > 0) dt.current = [], qt();
|
|
7371
7379
|
else {
|
|
7372
|
-
|
|
7380
|
+
U(null);
|
|
7373
7381
|
let e = R.current;
|
|
7374
7382
|
e && (e.getCanvas().style.cursor = "");
|
|
7375
7383
|
}
|
|
@@ -7378,7 +7386,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7378
7386
|
if (t === "square") {
|
|
7379
7387
|
if (pt.current) pt.current = null, Qt();
|
|
7380
7388
|
else {
|
|
7381
|
-
|
|
7389
|
+
U(null);
|
|
7382
7390
|
let e = R.current;
|
|
7383
7391
|
e && (e.getCanvas().style.cursor = "");
|
|
7384
7392
|
}
|
|
@@ -7399,10 +7407,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7399
7407
|
let e = new PolylineRenderer(r, n, O, k, P);
|
|
7400
7408
|
z.current.set(n.id, e);
|
|
7401
7409
|
}
|
|
7402
|
-
Q.current.onPolylineAdd?.(n), ht.current = [], mt.current = null,
|
|
7410
|
+
Q.current.onPolylineAdd?.(n), ht.current = [], mt.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7403
7411
|
} else if (e.length > 0) ht.current = [], nn();
|
|
7404
7412
|
else {
|
|
7405
|
-
|
|
7413
|
+
U(null);
|
|
7406
7414
|
let e = R.current;
|
|
7407
7415
|
e && (e.getCanvas().style.cursor = "");
|
|
7408
7416
|
}
|
|
@@ -7411,11 +7419,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7411
7419
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7412
7420
|
x: e.point.x,
|
|
7413
7421
|
y: e.point.y
|
|
7414
|
-
}, i =
|
|
7422
|
+
}, i = jn.current, a = Tn(e.originalEvent.target);
|
|
7415
7423
|
if (a) {
|
|
7416
7424
|
let e = i.find((e) => String(e.id) === a);
|
|
7417
7425
|
if (e) {
|
|
7418
|
-
|
|
7426
|
+
kn(e, r, n);
|
|
7419
7427
|
return;
|
|
7420
7428
|
}
|
|
7421
7429
|
}
|
|
@@ -7424,7 +7432,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7424
7432
|
if (o && R.current?.getLayer(o) && R.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7425
7433
|
let e = i.find((e) => e.id === t);
|
|
7426
7434
|
if (e) {
|
|
7427
|
-
|
|
7435
|
+
kn(e, r, n);
|
|
7428
7436
|
return;
|
|
7429
7437
|
}
|
|
7430
7438
|
}
|
|
@@ -7432,19 +7440,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7432
7440
|
for (let [e, t] of z.current) if (t.isPointInEntity(n)) {
|
|
7433
7441
|
let t = i.find((t) => t.id === e);
|
|
7434
7442
|
if (t) {
|
|
7435
|
-
|
|
7443
|
+
kn(t, r, n);
|
|
7436
7444
|
return;
|
|
7437
7445
|
}
|
|
7438
7446
|
}
|
|
7439
7447
|
}, [
|
|
7440
|
-
|
|
7448
|
+
Tn,
|
|
7441
7449
|
Y,
|
|
7442
7450
|
Rt,
|
|
7443
7451
|
Ut,
|
|
7444
7452
|
qt,
|
|
7445
7453
|
Qt,
|
|
7446
7454
|
nn
|
|
7447
|
-
]),
|
|
7455
|
+
]), kn = useCallback((e, t, n) => {
|
|
7448
7456
|
let r = Be.current?.getBoundingClientRect(), i = r ? {
|
|
7449
7457
|
x: t.x + r.left,
|
|
7450
7458
|
y: t.y + r.top
|
|
@@ -7469,7 +7477,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7469
7477
|
}
|
|
7470
7478
|
}]
|
|
7471
7479
|
});
|
|
7472
|
-
}, []),
|
|
7480
|
+
}, []), An = useCallback(() => {
|
|
7473
7481
|
Ye(null);
|
|
7474
7482
|
}, []);
|
|
7475
7483
|
useEffect(() => {
|
|
@@ -7499,59 +7507,59 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7499
7507
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7500
7508
|
};
|
|
7501
7509
|
}, [L?.zIndex]);
|
|
7502
|
-
let
|
|
7503
|
-
|
|
7504
|
-
let
|
|
7505
|
-
|
|
7506
|
-
let
|
|
7507
|
-
|
|
7508
|
-
let
|
|
7509
|
-
|
|
7510
|
-
let
|
|
7511
|
-
|
|
7512
|
-
let
|
|
7513
|
-
|
|
7514
|
-
let
|
|
7515
|
-
|
|
7516
|
-
let
|
|
7517
|
-
|
|
7510
|
+
let jn = useRef(T);
|
|
7511
|
+
jn.current = T;
|
|
7512
|
+
let Mn = useRef(Fe);
|
|
7513
|
+
Mn.current = Fe;
|
|
7514
|
+
let Nn = useRef(Tt);
|
|
7515
|
+
Nn.current = Tt;
|
|
7516
|
+
let Pn = useRef(et);
|
|
7517
|
+
Pn.current = et;
|
|
7518
|
+
let Fn = useRef(b);
|
|
7519
|
+
Fn.current = b;
|
|
7520
|
+
let In = useRef(at);
|
|
7521
|
+
In.current = at;
|
|
7522
|
+
let Ln = useRef(ot);
|
|
7523
|
+
Ln.current = ot;
|
|
7524
|
+
let Rn = useRef(st);
|
|
7525
|
+
Rn.current = st;
|
|
7518
7526
|
let Q = useRef(v);
|
|
7519
7527
|
Q.current = v;
|
|
7520
|
-
let
|
|
7521
|
-
|
|
7528
|
+
let zn = useRef(D);
|
|
7529
|
+
zn.current = D, useEffect(() => {
|
|
7522
7530
|
let e = (e) => {
|
|
7523
7531
|
if (e.key === "Escape" && J.current) {
|
|
7524
7532
|
z.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7525
7533
|
return;
|
|
7526
7534
|
}
|
|
7527
|
-
if (e.key === "Escape" &&
|
|
7528
|
-
if (
|
|
7535
|
+
if (e.key === "Escape" && et === "edit") {
|
|
7536
|
+
if (at && (H(null), U(null), Y()), ot === "rectangle") if (st) ct(null), Rt();
|
|
7529
7537
|
else {
|
|
7530
|
-
|
|
7538
|
+
U(null);
|
|
7531
7539
|
let e = R.current;
|
|
7532
7540
|
e && (e.getCanvas().style.cursor = "");
|
|
7533
7541
|
}
|
|
7534
|
-
if (
|
|
7542
|
+
if (ot === "circle") if (ut.current) ut.current = null, Ut();
|
|
7535
7543
|
else {
|
|
7536
|
-
|
|
7544
|
+
U(null);
|
|
7537
7545
|
let e = R.current;
|
|
7538
7546
|
e && (e.getCanvas().style.cursor = "");
|
|
7539
7547
|
}
|
|
7540
|
-
if (
|
|
7548
|
+
if (ot === "polygon") if (dt.current.length > 0) dt.current = [], qt();
|
|
7541
7549
|
else {
|
|
7542
|
-
|
|
7550
|
+
U(null);
|
|
7543
7551
|
let e = R.current;
|
|
7544
7552
|
e && (e.getCanvas().style.cursor = "");
|
|
7545
7553
|
}
|
|
7546
|
-
if (
|
|
7554
|
+
if (ot === "square") if (pt.current) pt.current = null, Qt();
|
|
7547
7555
|
else {
|
|
7548
|
-
|
|
7556
|
+
U(null);
|
|
7549
7557
|
let e = R.current;
|
|
7550
7558
|
e && (e.getCanvas().style.cursor = "");
|
|
7551
7559
|
}
|
|
7552
|
-
if (
|
|
7560
|
+
if (ot === "polyline") if (ht.current.length > 0) ht.current = [], nn();
|
|
7553
7561
|
else {
|
|
7554
|
-
|
|
7562
|
+
U(null);
|
|
7555
7563
|
let e = R.current;
|
|
7556
7564
|
e && (e.getCanvas().style.cursor = "");
|
|
7557
7565
|
}
|
|
@@ -7561,10 +7569,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7561
7569
|
document.removeEventListener("keydown", e);
|
|
7562
7570
|
};
|
|
7563
7571
|
}, [
|
|
7564
|
-
|
|
7565
|
-
it,
|
|
7572
|
+
et,
|
|
7566
7573
|
at,
|
|
7567
7574
|
ot,
|
|
7575
|
+
st,
|
|
7568
7576
|
Y,
|
|
7569
7577
|
Rt,
|
|
7570
7578
|
Ut,
|
|
@@ -7575,7 +7583,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7575
7583
|
let e = R.current;
|
|
7576
7584
|
if (!e || !V) return;
|
|
7577
7585
|
let t = V.entityId, n = V.config, r = () => {
|
|
7578
|
-
let r =
|
|
7586
|
+
let r = jn.current.find((e) => e.id === t);
|
|
7579
7587
|
if (!r) {
|
|
7580
7588
|
Dt();
|
|
7581
7589
|
return;
|
|
@@ -7594,7 +7602,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7594
7602
|
let n = Je.lngLat, r = () => {
|
|
7595
7603
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7596
7604
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7597
|
-
|
|
7605
|
+
An();
|
|
7598
7606
|
return;
|
|
7599
7607
|
}
|
|
7600
7608
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
@@ -7603,7 +7611,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7603
7611
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7604
7612
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7605
7613
|
};
|
|
7606
|
-
}, [Je?.lngLat,
|
|
7614
|
+
}, [Je?.lngLat, An]), useEffect(() => {
|
|
7607
7615
|
if (!Be.current) return;
|
|
7608
7616
|
let e = {
|
|
7609
7617
|
version: 8,
|
|
@@ -7644,9 +7652,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7644
7652
|
}
|
|
7645
7653
|
B.current.clear(), T.forEach((e) => {
|
|
7646
7654
|
B.current.set(e.id, e);
|
|
7647
|
-
}),
|
|
7648
|
-
}), _.on("click",
|
|
7649
|
-
_.off("click",
|
|
7655
|
+
}), wn(S), gn(), It(), zt(), Gt(), Yt(), en(), $e(_), Pe?.(_);
|
|
7656
|
+
}), _.on("click", En), _.on("mousemove", Dn), _.on("contextmenu", On), () => {
|
|
7657
|
+
_.off("click", En), _.off("mousemove", Dn), _.off("contextmenu", On), _n(), Mt(), Y(), X(), Z(), _.remove(), R.current = null;
|
|
7650
7658
|
};
|
|
7651
7659
|
}, []), useEffect(() => {
|
|
7652
7660
|
if (R.current) {
|
|
@@ -7654,53 +7662,53 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7654
7662
|
R.current.once("load", () => {
|
|
7655
7663
|
B.current.clear(), T.forEach((e) => {
|
|
7656
7664
|
B.current.set(e.id, e);
|
|
7657
|
-
}),
|
|
7665
|
+
}), gn();
|
|
7658
7666
|
});
|
|
7659
7667
|
return;
|
|
7660
7668
|
}
|
|
7661
7669
|
B.current.clear(), T.forEach((e) => {
|
|
7662
7670
|
B.current.set(e.id, e);
|
|
7663
|
-
}),
|
|
7671
|
+
}), gn();
|
|
7664
7672
|
}
|
|
7665
|
-
}, [T,
|
|
7666
|
-
!R.current || !R.current.isStyleLoaded() || (
|
|
7673
|
+
}, [T, gn]), useEffect(() => {
|
|
7674
|
+
!R.current || !R.current.isStyleLoaded() || (_n(), gn());
|
|
7667
7675
|
}, [
|
|
7668
7676
|
O,
|
|
7669
7677
|
k,
|
|
7670
7678
|
M,
|
|
7671
7679
|
N,
|
|
7672
7680
|
P,
|
|
7673
|
-
|
|
7674
|
-
|
|
7681
|
+
_n,
|
|
7682
|
+
gn
|
|
7675
7683
|
]), useEffect(() => {
|
|
7676
7684
|
if (R.current) {
|
|
7677
7685
|
if (!R.current.isStyleLoaded()) {
|
|
7678
7686
|
R.current.once("load", () => {
|
|
7679
|
-
|
|
7687
|
+
wn(S);
|
|
7680
7688
|
});
|
|
7681
7689
|
return;
|
|
7682
7690
|
}
|
|
7683
|
-
|
|
7684
|
-
}
|
|
7685
|
-
}, [S,
|
|
7686
|
-
let
|
|
7687
|
-
|
|
7688
|
-
let
|
|
7689
|
-
|
|
7690
|
-
let
|
|
7691
|
-
|
|
7692
|
-
let
|
|
7693
|
-
|
|
7694
|
-
let
|
|
7695
|
-
|
|
7696
|
-
let
|
|
7697
|
-
|
|
7698
|
-
let
|
|
7699
|
-
|
|
7700
|
-
let
|
|
7701
|
-
|
|
7702
|
-
let
|
|
7703
|
-
|
|
7691
|
+
wn(S);
|
|
7692
|
+
}
|
|
7693
|
+
}, [S, wn]);
|
|
7694
|
+
let Bn = useRef(void 0), Vn = useRef(!0), Hn = useRef(S);
|
|
7695
|
+
Hn.current = S;
|
|
7696
|
+
let Un = useRef(wn);
|
|
7697
|
+
Un.current = wn;
|
|
7698
|
+
let Wn = useRef(_n);
|
|
7699
|
+
Wn.current = _n;
|
|
7700
|
+
let Gn = useRef(gn);
|
|
7701
|
+
Gn.current = gn;
|
|
7702
|
+
let Kn = useRef(It);
|
|
7703
|
+
Kn.current = It;
|
|
7704
|
+
let qn = useRef(zt);
|
|
7705
|
+
qn.current = zt;
|
|
7706
|
+
let Jn = useRef(Gt);
|
|
7707
|
+
Jn.current = Gt;
|
|
7708
|
+
let Yn = useRef(Yt);
|
|
7709
|
+
Yn.current = Yt;
|
|
7710
|
+
let Xn = useRef(en);
|
|
7711
|
+
Xn.current = en, useEffect(() => {
|
|
7704
7712
|
let e = R.current;
|
|
7705
7713
|
if (!e) return;
|
|
7706
7714
|
let t = p || {
|
|
@@ -7708,27 +7716,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7708
7716
|
sources: {},
|
|
7709
7717
|
layers: []
|
|
7710
7718
|
};
|
|
7711
|
-
if (
|
|
7712
|
-
|
|
7719
|
+
if (Vn.current) {
|
|
7720
|
+
Vn.current = !1, Bn.current = p;
|
|
7713
7721
|
return;
|
|
7714
7722
|
}
|
|
7715
|
-
|
|
7723
|
+
Bn.current !== p && (Bn.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7716
7724
|
if (!e.getStyle().glyphs) {
|
|
7717
7725
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7718
7726
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7719
7727
|
}
|
|
7720
|
-
Ue.current.clear(),
|
|
7728
|
+
Ue.current.clear(), Un.current(Hn.current), Wn.current(), Gn.current(), Kn.current(), qn.current(), Jn.current(), Yn.current(), Xn.current();
|
|
7721
7729
|
}));
|
|
7722
7730
|
}, [p]), useEffect(() => {
|
|
7723
7731
|
let e = new Set(E.map(String));
|
|
7724
7732
|
for (let [t, n] of z.current) n.setSelected(e.has(String(t)));
|
|
7725
7733
|
}, [E]);
|
|
7726
|
-
let
|
|
7734
|
+
let Zn = useRef({});
|
|
7727
7735
|
useEffect(() => {
|
|
7728
7736
|
let e = R.current;
|
|
7729
7737
|
if (!e) return;
|
|
7730
|
-
let t =
|
|
7731
|
-
!n && !r && !i && !a || (
|
|
7738
|
+
let t = Zn.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;
|
|
7739
|
+
!n && !r && !i && !a || (Zn.current = {
|
|
7732
7740
|
center: l,
|
|
7733
7741
|
zoom: u,
|
|
7734
7742
|
pitch: d,
|
|
@@ -7745,7 +7753,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7745
7753
|
d,
|
|
7746
7754
|
f
|
|
7747
7755
|
]);
|
|
7748
|
-
let
|
|
7756
|
+
let Qn = (() => Se === !1 ? null : Se === !0 ? { enabled: !0 } : Se)(), $n = (() => F === !1 ? null : F === !0 ? { enabled: !0 } : F)(), er = (() => Ce === !1 ? null : Ce === !0 ? { enabled: !0 } : Ce)(), $ = (() => {
|
|
7749
7757
|
if (we === !1) return null;
|
|
7750
7758
|
let e, t, n;
|
|
7751
7759
|
if (S && S.length > 0) {
|
|
@@ -7770,7 +7778,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7770
7778
|
sourceLayer: we.sourceLayer || t,
|
|
7771
7779
|
classField: we.classField || n
|
|
7772
7780
|
};
|
|
7773
|
-
})(),
|
|
7781
|
+
})(), tr = (() => I ? I === !0 ? { enabled: !0 } : I : null)(), nr = (() => Ee ? Ee === !0 ? { enabled: !0 } : Ee : null)(), rr = (() => Ae || null)(), ir = useMemo(() => {
|
|
7774
7782
|
let e = [];
|
|
7775
7783
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7776
7784
|
let n = R.current;
|
|
@@ -7780,16 +7788,16 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7780
7788
|
}
|
|
7781
7789
|
} else e.push(`base-layer-${t.id}`);
|
|
7782
7790
|
return e;
|
|
7783
|
-
}, [S,
|
|
7791
|
+
}, [S, Qe]);
|
|
7784
7792
|
return /* @__PURE__ */ jsxs("div", {
|
|
7785
|
-
className: `comp-mapbox ${
|
|
7793
|
+
className: `comp-mapbox ${et === "picker" ? "comp-mapbox--picker-mode" : ""} ${Re}`,
|
|
7786
7794
|
style: ze,
|
|
7787
7795
|
children: [
|
|
7788
7796
|
/* @__PURE__ */ jsx("div", {
|
|
7789
7797
|
ref: Be,
|
|
7790
7798
|
className: "comp-mapbox__map"
|
|
7791
7799
|
}),
|
|
7792
|
-
|
|
7800
|
+
et === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
7793
7801
|
className: "comp-mapbox__crosshair",
|
|
7794
7802
|
children: [/* @__PURE__ */ jsx("div", {
|
|
7795
7803
|
className: "comp-mapbox__crosshair-h",
|
|
@@ -7800,13 +7808,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7800
7808
|
})]
|
|
7801
7809
|
}),
|
|
7802
7810
|
/* @__PURE__ */ jsxs("div", {
|
|
7803
|
-
className: `comp-mapbox__edit-controls${
|
|
7811
|
+
className: `comp-mapbox__edit-controls${et === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || rr && rr.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
|
|
7804
7812
|
children: [
|
|
7805
|
-
|
|
7813
|
+
et === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7806
7814
|
markerTemplates: v.markerTemplates || [],
|
|
7807
|
-
selectedTemplate:
|
|
7815
|
+
selectedTemplate: at,
|
|
7808
7816
|
onTemplateSelect: rn,
|
|
7809
|
-
drawMode:
|
|
7817
|
+
drawMode: ot,
|
|
7810
7818
|
onDrawModeChange: an,
|
|
7811
7819
|
showRectangleTool: v.showRectangleTool,
|
|
7812
7820
|
showCircleTool: v.showCircleTool,
|
|
@@ -7816,7 +7824,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7816
7824
|
}),
|
|
7817
7825
|
/* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7818
7826
|
ref: He,
|
|
7819
|
-
map:
|
|
7827
|
+
map: Qe,
|
|
7820
7828
|
showButton: !!($ && $.enabled !== !1),
|
|
7821
7829
|
highlightWidth: $?.highlightWidth,
|
|
7822
7830
|
defaultRoadTypes: $?.defaultRoadTypes,
|
|
@@ -7827,64 +7835,64 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7827
7835
|
className: $?.className,
|
|
7828
7836
|
style: $?.style
|
|
7829
7837
|
}),
|
|
7830
|
-
|
|
7838
|
+
rr && rr.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7831
7839
|
ref: Ve,
|
|
7832
|
-
map:
|
|
7833
|
-
pointCount:
|
|
7834
|
-
showPointCountInput:
|
|
7835
|
-
visualType:
|
|
7836
|
-
onSelectFinished:
|
|
7840
|
+
map: Qe,
|
|
7841
|
+
pointCount: rr.pointCount,
|
|
7842
|
+
showPointCountInput: rr.showPointCountInput,
|
|
7843
|
+
visualType: rr.visualType,
|
|
7844
|
+
onSelectFinished: rr.onSelectFinished
|
|
7837
7845
|
})
|
|
7838
7846
|
]
|
|
7839
7847
|
}),
|
|
7840
|
-
(
|
|
7848
|
+
(Qn?.enabled !== !1 || $n?.enabled !== !1 || er?.enabled !== !1 || tr && tr.enabled !== !1 || nr && nr.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7841
7849
|
className: "comp-mapbox__controls",
|
|
7842
7850
|
children: [
|
|
7843
|
-
|
|
7844
|
-
map:
|
|
7845
|
-
precision:
|
|
7846
|
-
className:
|
|
7847
|
-
style:
|
|
7851
|
+
Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7852
|
+
map: Qe,
|
|
7853
|
+
precision: Qn.precision,
|
|
7854
|
+
className: Qn.className,
|
|
7855
|
+
style: Qn.style
|
|
7848
7856
|
}),
|
|
7849
|
-
|
|
7850
|
-
map:
|
|
7851
|
-
maxWidth:
|
|
7852
|
-
unit:
|
|
7853
|
-
className:
|
|
7854
|
-
style:
|
|
7857
|
+
$n && $n.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7858
|
+
map: Qe,
|
|
7859
|
+
maxWidth: $n.maxWidth,
|
|
7860
|
+
unit: $n.unit,
|
|
7861
|
+
className: $n.className,
|
|
7862
|
+
style: $n.style
|
|
7855
7863
|
}),
|
|
7856
|
-
|
|
7857
|
-
map:
|
|
7864
|
+
tr && tr.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7865
|
+
map: Qe,
|
|
7858
7866
|
entityConfig: D,
|
|
7859
7867
|
onDrawModeChange: (e) => {
|
|
7860
7868
|
_t.current = e;
|
|
7861
7869
|
},
|
|
7862
|
-
className:
|
|
7863
|
-
style:
|
|
7870
|
+
className: tr.className,
|
|
7871
|
+
style: tr.style
|
|
7864
7872
|
}),
|
|
7865
|
-
|
|
7866
|
-
map:
|
|
7873
|
+
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7874
|
+
map: Qe,
|
|
7867
7875
|
value: C,
|
|
7868
7876
|
onChange: je,
|
|
7869
|
-
rasterPaintLayerIds:
|
|
7870
|
-
className:
|
|
7871
|
-
style:
|
|
7877
|
+
rasterPaintLayerIds: ir,
|
|
7878
|
+
className: nr.className,
|
|
7879
|
+
style: nr.style
|
|
7872
7880
|
}),
|
|
7873
|
-
|
|
7874
|
-
map:
|
|
7881
|
+
er && er.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7882
|
+
map: Qe,
|
|
7875
7883
|
initialCenter: l,
|
|
7876
7884
|
initialZoom: u,
|
|
7877
7885
|
initialPitch: d,
|
|
7878
7886
|
initialBearing: f,
|
|
7879
|
-
duration:
|
|
7880
|
-
className:
|
|
7881
|
-
style:
|
|
7887
|
+
duration: er.duration,
|
|
7888
|
+
className: er.className,
|
|
7889
|
+
style: er.style
|
|
7882
7890
|
})
|
|
7883
7891
|
]
|
|
7884
7892
|
}),
|
|
7885
|
-
!(
|
|
7893
|
+
!(rr && rr.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7886
7894
|
ref: Ve,
|
|
7887
|
-
map:
|
|
7895
|
+
map: Qe,
|
|
7888
7896
|
showButton: !1
|
|
7889
7897
|
}),
|
|
7890
7898
|
V && Ge.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
@@ -7895,7 +7903,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7895
7903
|
}),
|
|
7896
7904
|
Je && Xe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7897
7905
|
menuState: Je,
|
|
7898
|
-
onClose:
|
|
7906
|
+
onClose: An,
|
|
7899
7907
|
portalContainer: Xe.current,
|
|
7900
7908
|
menuRef: Ze
|
|
7901
7909
|
})
|