bbl-mapbox-react 0.0.16 → 0.0.17
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 +8 -8
- package/dist/index.css +1 -1
- package/dist/index.mjs +577 -559
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3516,19 +3516,19 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3516
3516
|
showRadius: r.showRadius ?? !0
|
|
3517
3517
|
} : g, [b, x] = useState([]), S = useRef(/* @__PURE__ */ new Map()), C = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), A = useRef([]), j = useRef([]), M = useRef(y);
|
|
3518
3518
|
M.current = y;
|
|
3519
|
-
let
|
|
3520
|
-
|
|
3521
|
-
let
|
|
3522
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
3519
|
+
let N = useRef(d);
|
|
3520
|
+
N.current = d;
|
|
3521
|
+
let be = useCallback(() => `measure-${++C.current}`, []), xe = useRef(!1), Se = useCallback(() => {
|
|
3522
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), xe.current = !0);
|
|
3523
3523
|
}, [e]);
|
|
3524
3524
|
useEffect(() => {
|
|
3525
3525
|
if (!e) return;
|
|
3526
3526
|
let t = () => {
|
|
3527
|
-
initAllPreviewLayers(e),
|
|
3527
|
+
initAllPreviewLayers(e), xe.current = !0;
|
|
3528
3528
|
};
|
|
3529
3529
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
3530
3530
|
let n = () => {
|
|
3531
|
-
|
|
3531
|
+
xe.current = !1;
|
|
3532
3532
|
};
|
|
3533
3533
|
return e.on("style.load", n), () => {
|
|
3534
3534
|
e.off("style.load", n);
|
|
@@ -3539,7 +3539,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3539
3539
|
};
|
|
3540
3540
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
3541
3541
|
}, []);
|
|
3542
|
-
let
|
|
3542
|
+
let Ce = useCallback((t) => {
|
|
3543
3543
|
if (!e) return;
|
|
3544
3544
|
let n = applyEntityConfig(t, M.current), r = null;
|
|
3545
3545
|
if (n.type === "circle" ? r = new CircleRenderer(e, n) : n.type === "square" ? r = new SquareRenderer(e, n) : n.type === "rectangle" ? r = new RectangleRenderer(e, n) : n.type === "polygon" ? r = new PolygonRenderer(e, n) : n.type === "polyline" && (r = new PolylineRenderer(e, n)), r) {
|
|
@@ -3552,12 +3552,12 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3552
3552
|
};
|
|
3553
3553
|
x((t) => [...t, e]);
|
|
3554
3554
|
}
|
|
3555
|
-
}, [e]),
|
|
3555
|
+
}, [e]), we = useCallback((e) => {
|
|
3556
3556
|
let t = S.current.get(e);
|
|
3557
3557
|
t && (t.destroy(), S.current.delete(e)), x((t) => t.filter((t) => t.entity.id !== e));
|
|
3558
|
-
}, []),
|
|
3558
|
+
}, []), Te = useCallback(() => {
|
|
3559
3559
|
S.current.forEach((e) => e.destroy()), S.current.clear(), x([]);
|
|
3560
|
-
}, []),
|
|
3560
|
+
}, []), Ee = useCallback((t) => {
|
|
3561
3561
|
if (!e) return;
|
|
3562
3562
|
let n = S.current.get(t);
|
|
3563
3563
|
if (!n) return;
|
|
@@ -3567,7 +3567,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3567
3567
|
maxZoom: 18,
|
|
3568
3568
|
duration: 1e3
|
|
3569
3569
|
});
|
|
3570
|
-
}, [e]),
|
|
3570
|
+
}, [e]), De = useCallback((e, t) => {
|
|
3571
3571
|
let n = {
|
|
3572
3572
|
...M.current,
|
|
3573
3573
|
[e]: t
|
|
@@ -3581,7 +3581,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3581
3581
|
entity: i
|
|
3582
3582
|
};
|
|
3583
3583
|
}));
|
|
3584
|
-
}, [v, i]),
|
|
3584
|
+
}, [v, i]), Oe = useCallback((t, n) => {
|
|
3585
3585
|
if (!e) return;
|
|
3586
3586
|
let [r, i] = t, [a, o] = n, s = [
|
|
3587
3587
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -3631,7 +3631,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3631
3631
|
features: t
|
|
3632
3632
|
});
|
|
3633
3633
|
}
|
|
3634
|
-
}, [e]),
|
|
3634
|
+
}, [e]), ke = useCallback((t, n) => {
|
|
3635
3635
|
if (!e) return;
|
|
3636
3636
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
3637
3637
|
a && a.setData({
|
|
@@ -3678,7 +3678,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3678
3678
|
type: "FeatureCollection",
|
|
3679
3679
|
features: c
|
|
3680
3680
|
});
|
|
3681
|
-
}, [e]),
|
|
3681
|
+
}, [e]), Ae = useCallback((t, n) => {
|
|
3682
3682
|
if (!e) return;
|
|
3683
3683
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
3684
3684
|
a && a.setData({
|
|
@@ -3715,7 +3715,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3715
3715
|
features: n
|
|
3716
3716
|
});
|
|
3717
3717
|
}
|
|
3718
|
-
}, [e]),
|
|
3718
|
+
}, [e]), je = useCallback((t, n) => {
|
|
3719
3719
|
if (!e) return;
|
|
3720
3720
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
3721
3721
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -3792,7 +3792,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3792
3792
|
features: t
|
|
3793
3793
|
});
|
|
3794
3794
|
}
|
|
3795
|
-
}, [e]),
|
|
3795
|
+
}, [e]), Me = useCallback((t, n) => {
|
|
3796
3796
|
if (!e) return;
|
|
3797
3797
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
3798
3798
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -3840,117 +3840,117 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3840
3840
|
}, [e]);
|
|
3841
3841
|
useEffect(() => {
|
|
3842
3842
|
if (!e || !d) return;
|
|
3843
|
-
|
|
3843
|
+
Se(), e.getCanvas().style.cursor = "crosshair";
|
|
3844
3844
|
let t = (t) => {
|
|
3845
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
3845
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = N.current;
|
|
3846
3846
|
if (r === "rectangle") {
|
|
3847
3847
|
let t = D.current;
|
|
3848
3848
|
if (!t) D.current = n;
|
|
3849
3849
|
else {
|
|
3850
3850
|
let r = {
|
|
3851
|
-
id:
|
|
3851
|
+
id: be(),
|
|
3852
3852
|
type: "rectangle",
|
|
3853
3853
|
bounds: [t, n]
|
|
3854
3854
|
};
|
|
3855
|
-
|
|
3855
|
+
Ce(r), D.current = null, clearAllPreviewSources(e), f(null);
|
|
3856
3856
|
}
|
|
3857
3857
|
} else if (r === "circle") {
|
|
3858
3858
|
let t = O.current;
|
|
3859
3859
|
if (!t) O.current = { center: n };
|
|
3860
3860
|
else {
|
|
3861
3861
|
let r = calculateDistance(t.center, n), i = {
|
|
3862
|
-
id:
|
|
3862
|
+
id: be(),
|
|
3863
3863
|
type: "circle",
|
|
3864
3864
|
center: t.center,
|
|
3865
3865
|
radius: r
|
|
3866
3866
|
};
|
|
3867
|
-
|
|
3867
|
+
Ce(i), O.current = null, clearAllPreviewSources(e), f(null);
|
|
3868
3868
|
}
|
|
3869
3869
|
} else if (r === "square") {
|
|
3870
3870
|
let t = k.current;
|
|
3871
3871
|
if (!t) k.current = { center: n };
|
|
3872
3872
|
else {
|
|
3873
3873
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
3874
|
-
id:
|
|
3874
|
+
id: be(),
|
|
3875
3875
|
type: "square",
|
|
3876
3876
|
center: t.center,
|
|
3877
3877
|
length: r
|
|
3878
3878
|
};
|
|
3879
|
-
|
|
3879
|
+
Ce(i), k.current = null, clearAllPreviewSources(e), f(null);
|
|
3880
3880
|
}
|
|
3881
3881
|
} else if (r === "polygon") {
|
|
3882
3882
|
let t = A.current;
|
|
3883
3883
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
3884
3884
|
let n = {
|
|
3885
|
-
id:
|
|
3885
|
+
id: be(),
|
|
3886
3886
|
type: "polygon",
|
|
3887
3887
|
coordinates: [...t]
|
|
3888
3888
|
};
|
|
3889
|
-
|
|
3889
|
+
Ce(n), A.current = [], clearAllPreviewSources(e), f(null);
|
|
3890
3890
|
return;
|
|
3891
3891
|
}
|
|
3892
3892
|
A.current = [...t, n];
|
|
3893
3893
|
} else r === "polyline" && (j.current = [...j.current, n]);
|
|
3894
3894
|
}, n = (e) => {
|
|
3895
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
3896
|
-
if (n === "rectangle" && D.current)
|
|
3897
|
-
else if (n === "circle" && O.current)
|
|
3898
|
-
else if (n === "square" && k.current)
|
|
3895
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = N.current;
|
|
3896
|
+
if (n === "rectangle" && D.current) Oe(D.current, t);
|
|
3897
|
+
else if (n === "circle" && O.current) ke(O.current.center, t);
|
|
3898
|
+
else if (n === "square" && k.current) Ae(k.current.center, t);
|
|
3899
3899
|
else if (n === "polygon") {
|
|
3900
3900
|
let e = A.current;
|
|
3901
|
-
e.length > 0 &&
|
|
3901
|
+
e.length > 0 && je(e, t);
|
|
3902
3902
|
} else if (n === "polyline") {
|
|
3903
3903
|
let e = j.current;
|
|
3904
|
-
e.length > 0 &&
|
|
3904
|
+
e.length > 0 && Me(e, t);
|
|
3905
3905
|
}
|
|
3906
3906
|
}, r = (t) => {
|
|
3907
3907
|
t.preventDefault();
|
|
3908
|
-
let n =
|
|
3908
|
+
let n = N.current;
|
|
3909
3909
|
if (n === "polygon") {
|
|
3910
3910
|
let t = A.current;
|
|
3911
3911
|
if (t.length >= 3) {
|
|
3912
3912
|
let n = {
|
|
3913
|
-
id:
|
|
3913
|
+
id: be(),
|
|
3914
3914
|
type: "polygon",
|
|
3915
3915
|
coordinates: [...t]
|
|
3916
3916
|
};
|
|
3917
|
-
|
|
3917
|
+
Ce(n), A.current = [], clearAllPreviewSources(e), f(null);
|
|
3918
3918
|
} else A.current = [], clearAllPreviewSources(e);
|
|
3919
3919
|
} else if (n === "polyline") {
|
|
3920
3920
|
let t = j.current;
|
|
3921
3921
|
if (t.length >= 2) {
|
|
3922
3922
|
let n = {
|
|
3923
|
-
id:
|
|
3923
|
+
id: be(),
|
|
3924
3924
|
type: "polyline",
|
|
3925
3925
|
coordinates: [...t]
|
|
3926
3926
|
};
|
|
3927
|
-
|
|
3927
|
+
Ce(n), j.current = [], clearAllPreviewSources(e), f(null);
|
|
3928
3928
|
} else j.current = [], clearAllPreviewSources(e);
|
|
3929
3929
|
}
|
|
3930
3930
|
}, i = (t) => {
|
|
3931
3931
|
t.key === "Escape" && (D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], clearAllPreviewSources(e), f(null));
|
|
3932
3932
|
}, a = (t) => {
|
|
3933
3933
|
t.preventDefault();
|
|
3934
|
-
let n =
|
|
3934
|
+
let n = N.current;
|
|
3935
3935
|
if (n === "polygon") {
|
|
3936
3936
|
let t = A.current;
|
|
3937
3937
|
if (t.length >= 3) {
|
|
3938
3938
|
let n = {
|
|
3939
|
-
id:
|
|
3939
|
+
id: be(),
|
|
3940
3940
|
type: "polygon",
|
|
3941
3941
|
coordinates: [...t]
|
|
3942
3942
|
};
|
|
3943
|
-
|
|
3943
|
+
Ce(n), A.current = [], clearAllPreviewSources(e), f(null);
|
|
3944
3944
|
}
|
|
3945
3945
|
} else if (n === "polyline") {
|
|
3946
3946
|
let t = j.current;
|
|
3947
3947
|
if (t.length >= 2) {
|
|
3948
3948
|
let n = {
|
|
3949
|
-
id:
|
|
3949
|
+
id: be(),
|
|
3950
3950
|
type: "polyline",
|
|
3951
3951
|
coordinates: [...t]
|
|
3952
3952
|
};
|
|
3953
|
-
|
|
3953
|
+
Ce(n), j.current = [], clearAllPreviewSources(e), f(null);
|
|
3954
3954
|
}
|
|
3955
3955
|
}
|
|
3956
3956
|
};
|
|
@@ -3960,14 +3960,14 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3960
3960
|
}, [
|
|
3961
3961
|
e,
|
|
3962
3962
|
d,
|
|
3963
|
-
|
|
3964
|
-
we,
|
|
3963
|
+
be,
|
|
3965
3964
|
Ce,
|
|
3965
|
+
Se,
|
|
3966
|
+
Oe,
|
|
3966
3967
|
ke,
|
|
3967
3968
|
Ae,
|
|
3968
3969
|
je,
|
|
3969
|
-
Me
|
|
3970
|
-
N
|
|
3970
|
+
Me
|
|
3971
3971
|
]), useEffect(() => () => {
|
|
3972
3972
|
S.current.forEach((e) => e.destroy()), S.current.clear();
|
|
3973
3973
|
}, []);
|
|
@@ -4008,17 +4008,17 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4008
4008
|
children: [
|
|
4009
4009
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4010
4010
|
checked: y.showArea,
|
|
4011
|
-
onChange: (e) =>
|
|
4011
|
+
onChange: (e) => De("showArea", e),
|
|
4012
4012
|
children: "面积"
|
|
4013
4013
|
}),
|
|
4014
4014
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4015
4015
|
checked: y.showLength,
|
|
4016
|
-
onChange: (e) =>
|
|
4016
|
+
onChange: (e) => De("showLength", e),
|
|
4017
4017
|
children: "长度"
|
|
4018
4018
|
}),
|
|
4019
4019
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4020
4020
|
checked: y.showRadius,
|
|
4021
|
-
onChange: (e) =>
|
|
4021
|
+
onChange: (e) => De("showRadius", e),
|
|
4022
4022
|
children: "半径"
|
|
4023
4023
|
})
|
|
4024
4024
|
]
|
|
@@ -4039,7 +4039,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4039
4039
|
})
|
|
4040
4040
|
}, e.mode)), b.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
4041
4041
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
4042
|
-
onClick:
|
|
4042
|
+
onClick: Te,
|
|
4043
4043
|
title: "清除全部",
|
|
4044
4044
|
children: /* @__PURE__ */ jsx("img", {
|
|
4045
4045
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e",
|
|
@@ -4059,7 +4059,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4059
4059
|
/* @__PURE__ */ jsx("th", {})
|
|
4060
4060
|
] }) }), /* @__PURE__ */ jsx("tbody", { children: b.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
4061
4061
|
className: "mapbox-measure-control__table-row",
|
|
4062
|
-
onClick: () =>
|
|
4062
|
+
onClick: () => Ee(e.entity.id),
|
|
4063
4063
|
children: [
|
|
4064
4064
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
4065
4065
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -4068,7 +4068,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4068
4068
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
4069
4069
|
className: "mapbox-measure-control__delete-btn",
|
|
4070
4070
|
onClick: (t) => {
|
|
4071
|
-
t.stopPropagation(),
|
|
4071
|
+
t.stopPropagation(), we(e.entity.id);
|
|
4072
4072
|
},
|
|
4073
4073
|
title: "删除",
|
|
4074
4074
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -4550,51 +4550,51 @@ function adjustPopupForBounds(e, t) {
|
|
|
4550
4550
|
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;
|
|
4551
4551
|
}
|
|
4552
4552
|
const Mapbox = forwardRef((e, c) => {
|
|
4553
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: h = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint:
|
|
4553
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: h = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: T, entities: E = [], selectedIds: D = [], entityConfig: O, nameConfig: k, selectNameConfig: A, areaConfig: j, circleConfig: M, lengthConfig: N, showCoordinates: xe = !0, showScale: Te = !0, showResetView: Ee = !0, showRoadHighlight: De = !1, showMeasure: ke = !1, showRasterPaint: Ae = !1, onRasterPaintChange: Me, popupDefaults: P, renderPopup: Pe, onMapLoad: Fe, onEntityClick: Ie, onPopupOpen: Le, onPopupClose: Re, className: ze = "", containerStyle: Be } = e, Ve = useRef(null), F = useRef(null), I = useRef(/* @__PURE__ */ new Map()), L = useRef(/* @__PURE__ */ new Map()), He = useRef(/* @__PURE__ */ new Set()), [R, Ue] = useState(null), We = useRef(null), Ge = useRef(null), Ke = useRef(null), [qe, Je] = useState(null), Ye = useRef(null), Xe = useRef(null), [Ze, Qe] = useState(null), [z, $e] = useState(_), [et, tt] = useState(null), nt = useRef(null), [rt, B] = useState(null), [it, V] = useState(null), [at, ot] = useState(null), H = useRef(!1), U = useRef(null), W = useRef(null), G = useRef(null), st = useRef(null), K = useRef(null), ct = useRef([]), q = useRef(null), lt = useRef(null), J = useRef(null), ut = useRef([]), dt = useRef(null);
|
|
4554
4554
|
useEffect(() => {
|
|
4555
4555
|
$e(_);
|
|
4556
4556
|
}, [_]);
|
|
4557
|
-
let
|
|
4558
|
-
let t =
|
|
4557
|
+
let ft = useCallback((e) => {
|
|
4558
|
+
let t = I.current.get(e), n = L.current.get(e);
|
|
4559
4559
|
if (t && n) {
|
|
4560
4560
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
4561
4561
|
let r = {
|
|
4562
4562
|
...n,
|
|
4563
4563
|
isAnimating: !0
|
|
4564
4564
|
};
|
|
4565
|
-
|
|
4565
|
+
L.current.set(e, r), t.startAnimation();
|
|
4566
4566
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
4567
4567
|
let r = {
|
|
4568
4568
|
...n,
|
|
4569
4569
|
isAnimating: !0
|
|
4570
4570
|
};
|
|
4571
|
-
|
|
4571
|
+
L.current.set(e, r), t.startAnimation();
|
|
4572
4572
|
}
|
|
4573
4573
|
}
|
|
4574
|
-
}, []),
|
|
4575
|
-
let t =
|
|
4574
|
+
}, []), pt = useCallback((e) => {
|
|
4575
|
+
let t = I.current.get(e), n = L.current.get(e);
|
|
4576
4576
|
if (t && n) {
|
|
4577
4577
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
4578
4578
|
let r = {
|
|
4579
4579
|
...n,
|
|
4580
4580
|
isAnimating: !1
|
|
4581
4581
|
};
|
|
4582
|
-
|
|
4582
|
+
L.current.set(e, r), t.stopAnimation();
|
|
4583
4583
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
4584
4584
|
let r = {
|
|
4585
4585
|
...n,
|
|
4586
4586
|
isAnimating: !1
|
|
4587
4587
|
};
|
|
4588
|
-
|
|
4588
|
+
L.current.set(e, r), t.stopAnimation();
|
|
4589
4589
|
}
|
|
4590
4590
|
}
|
|
4591
|
-
}, []),
|
|
4592
|
-
let t =
|
|
4593
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
4594
|
-
}, [
|
|
4591
|
+
}, []), mt = useCallback((e) => {
|
|
4592
|
+
let t = L.current.get(e);
|
|
4593
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? pt(e) : ft(e));
|
|
4594
|
+
}, [ft, pt]), ht = useCallback((e) => {
|
|
4595
4595
|
if (e === void 0) {
|
|
4596
4596
|
let e = !1;
|
|
4597
|
-
for (let [, t] of
|
|
4597
|
+
for (let [, t] of I.current) if (t instanceof UnitRenderer) {
|
|
4598
4598
|
let n = t.getShowTrajectory();
|
|
4599
4599
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
4600
4600
|
e = !0;
|
|
@@ -4602,17 +4602,17 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4602
4602
|
}
|
|
4603
4603
|
}
|
|
4604
4604
|
let t = e ? 0 : "all";
|
|
4605
|
-
for (let [, e] of
|
|
4605
|
+
for (let [, e] of I.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
4606
4606
|
} else {
|
|
4607
4607
|
let t = new Set(e.map(String));
|
|
4608
|
-
for (let [e, n] of
|
|
4608
|
+
for (let [e, n] of I.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
4609
4609
|
}
|
|
4610
|
-
}, []),
|
|
4611
|
-
let r =
|
|
4612
|
-
if (!r?.popup || !
|
|
4610
|
+
}, []), gt = useCallback((e, t, n) => {
|
|
4611
|
+
let r = E.find((t) => String(t.id) === String(e));
|
|
4612
|
+
if (!r?.popup || !F.current) return;
|
|
4613
4613
|
let i = r.popup.content ?? Pe?.(r);
|
|
4614
4614
|
if (!i) return;
|
|
4615
|
-
let a = mergePopupConfig(r.popup,
|
|
4615
|
+
let a = mergePopupConfig(r.popup, P, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, F.current, n);
|
|
4616
4616
|
Ue({
|
|
4617
4617
|
entityId: e,
|
|
4618
4618
|
position: o,
|
|
@@ -4621,27 +4621,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4621
4621
|
actualPosition: s
|
|
4622
4622
|
}), Le?.(e);
|
|
4623
4623
|
}, [
|
|
4624
|
-
|
|
4625
|
-
|
|
4624
|
+
E,
|
|
4625
|
+
P,
|
|
4626
4626
|
Pe,
|
|
4627
4627
|
Le
|
|
4628
|
-
]),
|
|
4629
|
-
|
|
4630
|
-
}, [
|
|
4628
|
+
]), _t = useCallback((e) => {
|
|
4629
|
+
R?.entityId === e && (Ue(null), Re?.(e));
|
|
4630
|
+
}, [R, Re]), vt = useCallback(() => {
|
|
4631
4631
|
Ue((e) => (e && Re?.(e.entityId), null));
|
|
4632
|
-
}, [Re]),
|
|
4633
|
-
let r =
|
|
4632
|
+
}, [Re]), yt = useCallback((e) => R?.entityId === e, [R]), bt = useCallback((e, t, n) => {
|
|
4633
|
+
let r = F.current;
|
|
4634
4634
|
r && r.flyTo({
|
|
4635
4635
|
center: e,
|
|
4636
4636
|
zoom: t ?? r.getZoom(),
|
|
4637
4637
|
...n
|
|
4638
4638
|
});
|
|
4639
|
-
}, []),
|
|
4640
|
-
let r =
|
|
4639
|
+
}, []), xt = useCallback((e, t, n) => {
|
|
4640
|
+
let r = F.current;
|
|
4641
4641
|
if (!r || e.length === 0) return;
|
|
4642
4642
|
let i = [];
|
|
4643
4643
|
for (let t of e) {
|
|
4644
|
-
let e =
|
|
4644
|
+
let e = I.current.get(t);
|
|
4645
4645
|
e && i.push(e.getBounds());
|
|
4646
4646
|
}
|
|
4647
4647
|
if (i.length === 0) return;
|
|
@@ -4663,51 +4663,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4663
4663
|
pitch: n?.pitch ?? r.getPitch()
|
|
4664
4664
|
};
|
|
4665
4665
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
4666
|
-
}, []),
|
|
4667
|
-
let t =
|
|
4666
|
+
}, []), St = useCallback((e) => {
|
|
4667
|
+
let t = F.current;
|
|
4668
4668
|
if (!t || !t.getContainer()) return;
|
|
4669
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff" } = y;
|
|
4669
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = y;
|
|
4670
4670
|
if (!n) {
|
|
4671
4671
|
nt.current &&= (nt.current.remove(), null);
|
|
4672
4672
|
return;
|
|
4673
4673
|
}
|
|
4674
|
-
if (nt.current)
|
|
4675
|
-
|
|
4674
|
+
if (nt.current) {
|
|
4675
|
+
nt.current.setLngLat(e);
|
|
4676
|
+
let t = nt.current.getElement(), n = t.querySelector(".marker-label");
|
|
4677
|
+
if (i) {
|
|
4678
|
+
let e = resolveNameConfig(a, k);
|
|
4679
|
+
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`;
|
|
4680
|
+
else {
|
|
4681
|
+
let n = document.createElement("div");
|
|
4682
|
+
n.className = "marker-label", 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`, t.appendChild(n);
|
|
4683
|
+
}
|
|
4684
|
+
} else n && n.remove();
|
|
4685
|
+
} else {
|
|
4676
4686
|
let n = document.createElement("div");
|
|
4677
4687
|
n.className = "mapbox-picker-marker";
|
|
4678
|
-
let
|
|
4679
|
-
|
|
4688
|
+
let o = document.createElement("div");
|
|
4689
|
+
if (o.className = "marker-inner", o.style.background = r, n.appendChild(o), i) {
|
|
4690
|
+
let e = resolveNameConfig(a, k), t = document.createElement("div");
|
|
4691
|
+
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);
|
|
4692
|
+
}
|
|
4693
|
+
nt.current = new mapboxgl.Marker({
|
|
4680
4694
|
element: n,
|
|
4681
4695
|
anchor: "bottom"
|
|
4682
4696
|
}).setLngLat(e).addTo(t);
|
|
4683
4697
|
}
|
|
4684
|
-
}, [y]),
|
|
4698
|
+
}, [y, k]), Ct = useCallback(() => {
|
|
4685
4699
|
nt.current &&= (nt.current.remove(), null);
|
|
4686
|
-
}, []),
|
|
4687
|
-
let t =
|
|
4688
|
-
if (Ve.current) if (
|
|
4700
|
+
}, []), wt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Tt = useCallback((e) => {
|
|
4701
|
+
let t = F.current;
|
|
4702
|
+
if (Ve.current) if (dt.current &&= (dt.current.remove(), null), e && t) {
|
|
4689
4703
|
t.getCanvas().style.cursor = "none";
|
|
4690
4704
|
let n = document.createElement("div");
|
|
4691
4705
|
n.className = "mapbox-custom-cursor";
|
|
4692
4706
|
let r = e.size || e.width || 32;
|
|
4693
4707
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
4694
4708
|
let i = document.createElement("img");
|
|
4695
|
-
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n),
|
|
4709
|
+
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n), dt.current = n;
|
|
4696
4710
|
let a = (e) => {
|
|
4697
|
-
|
|
4711
|
+
dt.current && (dt.current.style.left = `${e.clientX}px`, dt.current.style.top = `${e.clientY}px`);
|
|
4698
4712
|
};
|
|
4699
4713
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
4700
4714
|
document.removeEventListener("mousemove", a);
|
|
4701
4715
|
};
|
|
4702
4716
|
} else t && (t.getCanvas().style.cursor = "");
|
|
4703
4717
|
}, []), Y = useCallback(() => {
|
|
4704
|
-
if (
|
|
4705
|
-
let e =
|
|
4706
|
-
e && e(),
|
|
4718
|
+
if (dt.current) {
|
|
4719
|
+
let e = dt.current._cleanup;
|
|
4720
|
+
e && e(), dt.current.remove(), dt.current = null;
|
|
4707
4721
|
}
|
|
4708
|
-
let e =
|
|
4722
|
+
let e = F.current;
|
|
4709
4723
|
e && (e.getCanvas().style.cursor = "");
|
|
4710
|
-
}, []),
|
|
4724
|
+
}, []), Et = useCallback((e, t, n) => {
|
|
4711
4725
|
if (!e.getSource(t)) {
|
|
4712
4726
|
if (!e.getStyle().glyphs) {
|
|
4713
4727
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -4743,8 +4757,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4743
4757
|
}
|
|
4744
4758
|
});
|
|
4745
4759
|
}
|
|
4746
|
-
}, []),
|
|
4747
|
-
let e =
|
|
4760
|
+
}, []), Dt = useCallback(() => {
|
|
4761
|
+
let e = F.current;
|
|
4748
4762
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
4749
4763
|
type: "geojson",
|
|
4750
4764
|
data: {
|
|
@@ -4768,9 +4782,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4768
4782
|
"line-width": 2,
|
|
4769
4783
|
"line-dasharray": [4, 4]
|
|
4770
4784
|
}
|
|
4771
|
-
}),
|
|
4772
|
-
}, [
|
|
4773
|
-
let n =
|
|
4785
|
+
}), Et(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
4786
|
+
}, [Et]), Ot = useCallback((e, t) => {
|
|
4787
|
+
let n = F.current;
|
|
4774
4788
|
if (!n) return;
|
|
4775
4789
|
let r = n.getSource("rect-preview-source");
|
|
4776
4790
|
if (!r) return;
|
|
@@ -4789,11 +4803,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4789
4803
|
},
|
|
4790
4804
|
properties: {}
|
|
4791
4805
|
});
|
|
4792
|
-
let l =
|
|
4806
|
+
let l = U.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
4793
4807
|
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));
|
|
4794
4808
|
let m = n.getSource("rect-preview-measure-source");
|
|
4795
4809
|
if (m) {
|
|
4796
|
-
let e =
|
|
4810
|
+
let e = En.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
4797
4811
|
if (e?.showArea) {
|
|
4798
4812
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
4799
4813
|
t.push({
|
|
@@ -4830,8 +4844,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4830
4844
|
features: t
|
|
4831
4845
|
});
|
|
4832
4846
|
}
|
|
4833
|
-
}, []),
|
|
4834
|
-
let e =
|
|
4847
|
+
}, []), kt = useCallback(() => {
|
|
4848
|
+
let e = F.current;
|
|
4835
4849
|
if (!e) return;
|
|
4836
4850
|
let t = e.getSource("rect-preview-source");
|
|
4837
4851
|
t && t.setData({
|
|
@@ -4843,10 +4857,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4843
4857
|
type: "FeatureCollection",
|
|
4844
4858
|
features: []
|
|
4845
4859
|
});
|
|
4846
|
-
}, []),
|
|
4847
|
-
ot(null),
|
|
4848
|
-
}, [
|
|
4849
|
-
let e =
|
|
4860
|
+
}, []), X = useCallback(() => {
|
|
4861
|
+
ot(null), kt();
|
|
4862
|
+
}, [kt]), At = useCallback(() => {
|
|
4863
|
+
let e = F.current;
|
|
4850
4864
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
4851
4865
|
type: "geojson",
|
|
4852
4866
|
data: {
|
|
@@ -4870,7 +4884,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4870
4884
|
"line-width": 2,
|
|
4871
4885
|
"line-dasharray": [4, 4]
|
|
4872
4886
|
}
|
|
4873
|
-
}),
|
|
4887
|
+
}), Et(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
4874
4888
|
type: "geojson",
|
|
4875
4889
|
data: {
|
|
4876
4890
|
type: "FeatureCollection",
|
|
@@ -4887,22 +4901,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4887
4901
|
"line-dasharray": [4, 4]
|
|
4888
4902
|
}
|
|
4889
4903
|
}))));
|
|
4890
|
-
}, [
|
|
4904
|
+
}, [Et]), jt = useCallback((e, t, n = 64) => {
|
|
4891
4905
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
4892
4906
|
for (let e = 0; e <= n; e++) {
|
|
4893
4907
|
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;
|
|
4894
4908
|
a.push([d, u]);
|
|
4895
4909
|
}
|
|
4896
4910
|
return a;
|
|
4897
|
-
}, []),
|
|
4911
|
+
}, []), Mt = useCallback((e, t) => {
|
|
4898
4912
|
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);
|
|
4899
4913
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
4900
|
-
}, []),
|
|
4901
|
-
let n =
|
|
4914
|
+
}, []), Nt = useCallback((e, t) => {
|
|
4915
|
+
let n = F.current;
|
|
4902
4916
|
if (!n) return;
|
|
4903
4917
|
let r = n.getSource("circle-preview-source");
|
|
4904
4918
|
if (!r) return;
|
|
4905
|
-
let i =
|
|
4919
|
+
let i = Mt(e, t), a = jt(e, i);
|
|
4906
4920
|
r.setData({
|
|
4907
4921
|
type: "Feature",
|
|
4908
4922
|
geometry: {
|
|
@@ -4911,9 +4925,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4911
4925
|
},
|
|
4912
4926
|
properties: {}
|
|
4913
4927
|
});
|
|
4914
|
-
let o =
|
|
4928
|
+
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
4915
4929
|
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));
|
|
4916
|
-
let d =
|
|
4930
|
+
let d = En.current, f = [], p = [];
|
|
4917
4931
|
if (d?.showArea) {
|
|
4918
4932
|
let t = Math.PI * i * i;
|
|
4919
4933
|
f.push({
|
|
@@ -4926,7 +4940,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4926
4940
|
});
|
|
4927
4941
|
}
|
|
4928
4942
|
if (d?.showRadius) {
|
|
4929
|
-
let t =
|
|
4943
|
+
let t = G.current?.radiusAngle ?? 90, n = destinationPoint(e, i, t), r = [(e[0] + n[0]) / 2, (e[1] + n[1]) / 2];
|
|
4930
4944
|
p.push({
|
|
4931
4945
|
type: "Feature",
|
|
4932
4946
|
geometry: {
|
|
@@ -4953,8 +4967,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4953
4967
|
type: "FeatureCollection",
|
|
4954
4968
|
features: p
|
|
4955
4969
|
});
|
|
4956
|
-
}, [
|
|
4957
|
-
let e =
|
|
4970
|
+
}, [Mt, jt]), Pt = useCallback(() => {
|
|
4971
|
+
let e = F.current;
|
|
4958
4972
|
if (!e) return;
|
|
4959
4973
|
let t = e.getSource("circle-preview-source");
|
|
4960
4974
|
t && t.setData({
|
|
@@ -4971,10 +4985,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4971
4985
|
type: "FeatureCollection",
|
|
4972
4986
|
features: []
|
|
4973
4987
|
});
|
|
4974
|
-
}, []),
|
|
4975
|
-
st.current = null,
|
|
4976
|
-
}, [
|
|
4977
|
-
let e =
|
|
4988
|
+
}, []), Ft = useCallback(() => {
|
|
4989
|
+
st.current = null, Pt();
|
|
4990
|
+
}, [Pt]), It = useCallback(() => {
|
|
4991
|
+
let e = F.current;
|
|
4978
4992
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
4979
4993
|
type: "geojson",
|
|
4980
4994
|
data: {
|
|
@@ -5014,9 +5028,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5014
5028
|
"circle-stroke-color": "#ffffff",
|
|
5015
5029
|
"circle-stroke-width": 2
|
|
5016
5030
|
}
|
|
5017
|
-
}),
|
|
5018
|
-
}, [
|
|
5019
|
-
let n =
|
|
5031
|
+
}), Et(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
5032
|
+
}, [Et]), Lt = useCallback((e, t) => {
|
|
5033
|
+
let n = F.current;
|
|
5020
5034
|
if (!n) return;
|
|
5021
5035
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
5022
5036
|
if (!r || !i) return;
|
|
@@ -5053,11 +5067,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5053
5067
|
properties: {}
|
|
5054
5068
|
}))
|
|
5055
5069
|
});
|
|
5056
|
-
let o =
|
|
5070
|
+
let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
5057
5071
|
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);
|
|
5058
5072
|
let d = n.getSource("polygon-preview-measure-source");
|
|
5059
5073
|
if (d) {
|
|
5060
|
-
let e =
|
|
5074
|
+
let e = En.current, t = [];
|
|
5061
5075
|
if (e?.showArea && a.length >= 3) {
|
|
5062
5076
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
5063
5077
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -5099,8 +5113,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5099
5113
|
features: t
|
|
5100
5114
|
});
|
|
5101
5115
|
}
|
|
5102
|
-
}, []),
|
|
5103
|
-
let e =
|
|
5116
|
+
}, []), Rt = useCallback(() => {
|
|
5117
|
+
let e = F.current;
|
|
5104
5118
|
if (!e) return;
|
|
5105
5119
|
let t = e.getSource("polygon-preview-source");
|
|
5106
5120
|
t && t.setData({
|
|
@@ -5117,10 +5131,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5117
5131
|
type: "FeatureCollection",
|
|
5118
5132
|
features: []
|
|
5119
5133
|
});
|
|
5120
|
-
}, []),
|
|
5121
|
-
ct.current = [],
|
|
5122
|
-
}, [
|
|
5123
|
-
let e =
|
|
5134
|
+
}, []), zt = useCallback(() => {
|
|
5135
|
+
ct.current = [], Rt();
|
|
5136
|
+
}, [Rt]), Bt = useCallback(() => {
|
|
5137
|
+
let e = F.current;
|
|
5124
5138
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
5125
5139
|
type: "geojson",
|
|
5126
5140
|
data: {
|
|
@@ -5144,8 +5158,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5144
5158
|
"line-width": 2,
|
|
5145
5159
|
"line-dasharray": [4, 4]
|
|
5146
5160
|
}
|
|
5147
|
-
}),
|
|
5148
|
-
}, [
|
|
5161
|
+
}), Et(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
5162
|
+
}, [Et]), Vt = useCallback((e, t) => {
|
|
5149
5163
|
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);
|
|
5150
5164
|
return [
|
|
5151
5165
|
[n - s, r + o],
|
|
@@ -5154,12 +5168,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5154
5168
|
[n - s, r - o],
|
|
5155
5169
|
[n - s, r + o]
|
|
5156
5170
|
];
|
|
5157
|
-
}, []),
|
|
5158
|
-
let n =
|
|
5171
|
+
}, []), Ht = useCallback((e, t) => {
|
|
5172
|
+
let n = F.current;
|
|
5159
5173
|
if (!n) return;
|
|
5160
5174
|
let r = n.getSource("square-preview-source");
|
|
5161
5175
|
if (!r) return;
|
|
5162
|
-
let i =
|
|
5176
|
+
let i = Mt(e, t) * 2, a = Vt(e, i);
|
|
5163
5177
|
r.setData({
|
|
5164
5178
|
type: "Feature",
|
|
5165
5179
|
geometry: {
|
|
@@ -5168,11 +5182,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5168
5182
|
},
|
|
5169
5183
|
properties: {}
|
|
5170
5184
|
});
|
|
5171
|
-
let o =
|
|
5185
|
+
let o = q.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
5172
5186
|
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));
|
|
5173
5187
|
let d = n.getSource("square-preview-measure-source");
|
|
5174
5188
|
if (d) {
|
|
5175
|
-
let t =
|
|
5189
|
+
let t = En.current, n = [];
|
|
5176
5190
|
if (t?.showArea && n.push({
|
|
5177
5191
|
type: "Feature",
|
|
5178
5192
|
geometry: {
|
|
@@ -5196,8 +5210,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5196
5210
|
features: n
|
|
5197
5211
|
});
|
|
5198
5212
|
}
|
|
5199
|
-
}, [
|
|
5200
|
-
let e =
|
|
5213
|
+
}, [Mt, Vt]), Ut = useCallback(() => {
|
|
5214
|
+
let e = F.current;
|
|
5201
5215
|
if (!e) return;
|
|
5202
5216
|
let t = e.getSource("square-preview-source");
|
|
5203
5217
|
t && t.setData({
|
|
@@ -5209,10 +5223,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5209
5223
|
type: "FeatureCollection",
|
|
5210
5224
|
features: []
|
|
5211
5225
|
});
|
|
5212
|
-
}, []),
|
|
5213
|
-
lt.current = null,
|
|
5214
|
-
}, [
|
|
5215
|
-
let e =
|
|
5226
|
+
}, []), Wt = useCallback(() => {
|
|
5227
|
+
lt.current = null, Ut();
|
|
5228
|
+
}, [Ut]), Gt = useCallback(() => {
|
|
5229
|
+
let e = F.current;
|
|
5216
5230
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
5217
5231
|
type: "geojson",
|
|
5218
5232
|
data: {
|
|
@@ -5244,9 +5258,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5244
5258
|
"circle-stroke-color": "#ffffff",
|
|
5245
5259
|
"circle-stroke-width": 2
|
|
5246
5260
|
}
|
|
5247
|
-
}),
|
|
5248
|
-
}, [
|
|
5249
|
-
let n =
|
|
5261
|
+
}), Et(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
5262
|
+
}, [Et]), Kt = useCallback((e, t) => {
|
|
5263
|
+
let n = F.current;
|
|
5250
5264
|
if (!n) return;
|
|
5251
5265
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
5252
5266
|
if (!r || !i) return;
|
|
@@ -5272,11 +5286,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5272
5286
|
properties: {}
|
|
5273
5287
|
}))
|
|
5274
5288
|
});
|
|
5275
|
-
let o =
|
|
5289
|
+
let o = J.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
5276
5290
|
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);
|
|
5277
5291
|
let l = n.getSource("polyline-preview-measure-source");
|
|
5278
5292
|
if (l) {
|
|
5279
|
-
let e =
|
|
5293
|
+
let e = En.current, t = [];
|
|
5280
5294
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
5281
5295
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
5282
5296
|
t.push({
|
|
@@ -5293,8 +5307,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5293
5307
|
features: t
|
|
5294
5308
|
});
|
|
5295
5309
|
}
|
|
5296
|
-
}, []),
|
|
5297
|
-
let e =
|
|
5310
|
+
}, []), qt = useCallback(() => {
|
|
5311
|
+
let e = F.current;
|
|
5298
5312
|
if (!e) return;
|
|
5299
5313
|
let t = e.getSource("polyline-preview-source");
|
|
5300
5314
|
t && t.setData({
|
|
@@ -5311,146 +5325,150 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5311
5325
|
type: "FeatureCollection",
|
|
5312
5326
|
features: []
|
|
5313
5327
|
});
|
|
5314
|
-
}, []),
|
|
5315
|
-
ut.current = [],
|
|
5316
|
-
}, [
|
|
5317
|
-
|
|
5328
|
+
}, []), Z = useCallback(() => {
|
|
5329
|
+
ut.current = [], qt();
|
|
5330
|
+
}, [qt]), Jt = useCallback((e) => {
|
|
5331
|
+
B(e), Tt(e), e ? (V("marker"), X(), Ft(), zt(), Wt(), Z()) : V(null);
|
|
5318
5332
|
}, [
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
]),
|
|
5326
|
-
if (
|
|
5327
|
-
|
|
5328
|
-
let e =
|
|
5333
|
+
Tt,
|
|
5334
|
+
X,
|
|
5335
|
+
Ft,
|
|
5336
|
+
zt,
|
|
5337
|
+
Wt,
|
|
5338
|
+
Z
|
|
5339
|
+
]), Yt = useCallback((e) => {
|
|
5340
|
+
if (V(e), e === "rectangle") {
|
|
5341
|
+
B(null), Y(), Ft(), zt(), Wt(), Z();
|
|
5342
|
+
let e = F.current;
|
|
5329
5343
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5330
5344
|
} else if (e === "circle") {
|
|
5331
|
-
|
|
5332
|
-
let e =
|
|
5345
|
+
B(null), Y(), X(), zt(), Wt(), Z();
|
|
5346
|
+
let e = F.current;
|
|
5333
5347
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5334
5348
|
} else if (e === "polygon") {
|
|
5335
|
-
|
|
5336
|
-
let e =
|
|
5349
|
+
B(null), Y(), X(), Ft(), Wt(), Z();
|
|
5350
|
+
let e = F.current;
|
|
5337
5351
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5338
5352
|
} else if (e === "square") {
|
|
5339
|
-
|
|
5340
|
-
let e =
|
|
5353
|
+
B(null), Y(), X(), Ft(), zt(), Z();
|
|
5354
|
+
let e = F.current;
|
|
5341
5355
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5342
5356
|
} else if (e === "polyline") {
|
|
5343
|
-
|
|
5344
|
-
let e =
|
|
5357
|
+
B(null), Y(), X(), Ft(), zt(), Wt();
|
|
5358
|
+
let e = F.current;
|
|
5345
5359
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5346
|
-
} else e === "marker" ? (
|
|
5360
|
+
} else e === "marker" ? (X(), Ft(), zt(), Wt(), Z()) : (B(null), Y(), X(), Ft(), zt(), Wt(), Z());
|
|
5347
5361
|
}, [
|
|
5348
5362
|
Y,
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
]),
|
|
5355
|
-
|
|
5363
|
+
X,
|
|
5364
|
+
Ft,
|
|
5365
|
+
zt,
|
|
5366
|
+
Wt,
|
|
5367
|
+
Z
|
|
5368
|
+
]), Xt = useCallback((e) => {
|
|
5369
|
+
if (e !== "picker") {
|
|
5370
|
+
let e = y.value && isFinite(y.value.lng) && isFinite(y.value.lat), t = y.showMarker !== !1;
|
|
5371
|
+
(!e || !t) && Ct(), tt(null);
|
|
5372
|
+
}
|
|
5373
|
+
e !== "edit" && (B(null), V(null), X(), Z(), Y()), $e(e);
|
|
5356
5374
|
}, [
|
|
5357
|
-
|
|
5375
|
+
Ct,
|
|
5358
5376
|
Y,
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
]),
|
|
5362
|
-
|
|
5363
|
-
}, [
|
|
5377
|
+
X,
|
|
5378
|
+
Z
|
|
5379
|
+
]), Zt = useCallback(() => z, [z]), Qt = useCallback(() => et, [et]), $t = useCallback(() => {
|
|
5380
|
+
Ct(), tt(null);
|
|
5381
|
+
}, [Ct]);
|
|
5364
5382
|
useEffect(() => {
|
|
5365
5383
|
if (!Ze) return;
|
|
5366
5384
|
let e = y.value;
|
|
5367
5385
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
5368
5386
|
let t = [e.lng, e.lat];
|
|
5369
|
-
tt(e),
|
|
5387
|
+
tt(e), St(t);
|
|
5370
5388
|
}
|
|
5371
5389
|
}, [
|
|
5372
5390
|
y.value,
|
|
5373
|
-
|
|
5391
|
+
St,
|
|
5374
5392
|
Ze
|
|
5375
5393
|
]);
|
|
5376
|
-
let
|
|
5377
|
-
if ($e("edit"),
|
|
5378
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
5394
|
+
let en = (e) => "mode" in e, tn = useCallback((e) => {
|
|
5395
|
+
if ($e("edit"), Ct(), tt(null), H.current = !0, en(e)) {
|
|
5396
|
+
if (e.mode === "marker") e.markerStyle ? (W.current = e.markerStyle, U.current = null, G.current = null, K.current = null, q.current = null, J.current = null, B(null), V("marker"), e.markerStyle.src && e.markerStyle.width ? Tt({
|
|
5379
5397
|
id: "custom",
|
|
5380
5398
|
name: e.markerStyle.name || "Marker",
|
|
5381
5399
|
icon: e.markerStyle.src,
|
|
5382
5400
|
width: e.markerStyle.width
|
|
5383
|
-
}) : Y()) : e.template && (
|
|
5401
|
+
}) : Y()) : e.template && (W.current = null, U.current = null, G.current = null, K.current = null, q.current = null, J.current = null, B(e.template), V("marker"), Tt(e.template));
|
|
5384
5402
|
else if (e.mode === "rectangle") {
|
|
5385
|
-
|
|
5386
|
-
let t =
|
|
5403
|
+
U.current = e.rectangleStyle || null, W.current = null, G.current = null, K.current = null, q.current = null, J.current = null, B(null), V("rectangle"), Y();
|
|
5404
|
+
let t = F.current;
|
|
5387
5405
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5388
5406
|
} else if (e.mode === "circle") {
|
|
5389
|
-
|
|
5390
|
-
let t =
|
|
5407
|
+
G.current = e.circleStyle || null, U.current = null, W.current = null, K.current = null, q.current = null, J.current = null, B(null), V("circle"), Y();
|
|
5408
|
+
let t = F.current;
|
|
5391
5409
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5392
5410
|
} else if (e.mode === "polygon") {
|
|
5393
|
-
|
|
5394
|
-
let t =
|
|
5411
|
+
K.current = e.polygonStyle || null, U.current = null, W.current = null, G.current = null, q.current = null, J.current = null, B(null), V("polygon"), Y();
|
|
5412
|
+
let t = F.current;
|
|
5395
5413
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5396
5414
|
} else if (e.mode === "square") {
|
|
5397
|
-
|
|
5398
|
-
let t =
|
|
5415
|
+
q.current = e.squareStyle || null, U.current = null, W.current = null, G.current = null, K.current = null, J.current = null, B(null), V("square"), Y();
|
|
5416
|
+
let t = F.current;
|
|
5399
5417
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5400
5418
|
} else if (e.mode === "polyline") {
|
|
5401
|
-
|
|
5402
|
-
let t =
|
|
5419
|
+
J.current = e.polylineStyle || null, U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, B(null), V("polyline"), Y();
|
|
5420
|
+
let t = F.current;
|
|
5403
5421
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5404
5422
|
}
|
|
5405
|
-
} else
|
|
5423
|
+
} else B(e), V("marker"), Tt(e), U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, J.current = null;
|
|
5406
5424
|
}, [
|
|
5407
|
-
|
|
5408
|
-
|
|
5425
|
+
Ct,
|
|
5426
|
+
Tt,
|
|
5409
5427
|
Y
|
|
5410
5428
|
]);
|
|
5411
5429
|
useImperativeHandle(c, () => ({
|
|
5412
|
-
startAnimation:
|
|
5413
|
-
stopAnimation:
|
|
5414
|
-
toggleAnimation:
|
|
5415
|
-
getMap: () =>
|
|
5416
|
-
openPopup: (e) =>
|
|
5417
|
-
closePopup:
|
|
5418
|
-
closeAllPopups:
|
|
5419
|
-
isPopupOpen:
|
|
5420
|
-
toggleUnitTrajectory:
|
|
5421
|
-
flyTo:
|
|
5422
|
-
flyToEntities:
|
|
5423
|
-
getMode:
|
|
5424
|
-
setMode:
|
|
5425
|
-
getPickedLocation:
|
|
5426
|
-
clearPickedLocation:
|
|
5427
|
-
startDrawing:
|
|
5428
|
-
getRenderer: (e) =>
|
|
5430
|
+
startAnimation: ft,
|
|
5431
|
+
stopAnimation: pt,
|
|
5432
|
+
toggleAnimation: mt,
|
|
5433
|
+
getMap: () => F.current,
|
|
5434
|
+
openPopup: (e) => gt(e, "programmatic"),
|
|
5435
|
+
closePopup: _t,
|
|
5436
|
+
closeAllPopups: vt,
|
|
5437
|
+
isPopupOpen: yt,
|
|
5438
|
+
toggleUnitTrajectory: ht,
|
|
5439
|
+
flyTo: bt,
|
|
5440
|
+
flyToEntities: xt,
|
|
5441
|
+
getMode: Zt,
|
|
5442
|
+
setMode: Xt,
|
|
5443
|
+
getPickedLocation: Qt,
|
|
5444
|
+
clearPickedLocation: $t,
|
|
5445
|
+
startDrawing: tn,
|
|
5446
|
+
getRenderer: (e) => I.current.get(e)
|
|
5429
5447
|
}), [
|
|
5430
|
-
dt,
|
|
5431
5448
|
ft,
|
|
5432
5449
|
pt,
|
|
5433
|
-
|
|
5450
|
+
mt,
|
|
5434
5451
|
gt,
|
|
5435
5452
|
_t,
|
|
5436
5453
|
vt,
|
|
5437
|
-
mt,
|
|
5438
5454
|
yt,
|
|
5455
|
+
ht,
|
|
5439
5456
|
bt,
|
|
5440
|
-
|
|
5441
|
-
Jt,
|
|
5442
|
-
Xt,
|
|
5457
|
+
xt,
|
|
5443
5458
|
Zt,
|
|
5444
|
-
|
|
5459
|
+
Xt,
|
|
5460
|
+
Qt,
|
|
5461
|
+
$t,
|
|
5462
|
+
tn
|
|
5445
5463
|
]);
|
|
5446
|
-
let
|
|
5447
|
-
let e =
|
|
5464
|
+
let nn = useCallback(() => {
|
|
5465
|
+
let e = F.current;
|
|
5448
5466
|
if (!e) return;
|
|
5449
|
-
let t = new Set(
|
|
5450
|
-
for (let e of n) t.has(e) || (
|
|
5451
|
-
let r = new Set(
|
|
5452
|
-
for (let t of
|
|
5453
|
-
let n = applyEntityConfig(t,
|
|
5467
|
+
let t = new Set(E.map((e) => e.id)), n = new Set(I.current.keys());
|
|
5468
|
+
for (let e of n) t.has(e) || (I.current.get(e)?.destroy(), I.current.delete(e));
|
|
5469
|
+
let r = new Set(D.map(String));
|
|
5470
|
+
for (let t of E) {
|
|
5471
|
+
let n = applyEntityConfig(t, O), i = I.current.get(n.id);
|
|
5454
5472
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
5455
5473
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
5456
5474
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -5459,34 +5477,34 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5459
5477
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
5460
5478
|
else {
|
|
5461
5479
|
i.destroy();
|
|
5462
|
-
let t = new CanvasCircleRenderer(e, n,
|
|
5463
|
-
|
|
5480
|
+
let t = new CanvasCircleRenderer(e, n, k, A, j, M);
|
|
5481
|
+
I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
5464
5482
|
}
|
|
5465
5483
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
5466
5484
|
else {
|
|
5467
5485
|
i.destroy();
|
|
5468
|
-
let t = new CircleRenderer(e, n,
|
|
5469
|
-
|
|
5486
|
+
let t = new CircleRenderer(e, n, k, A, j, M);
|
|
5487
|
+
I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
5470
5488
|
}
|
|
5471
5489
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
5472
5490
|
else {
|
|
5473
5491
|
let t = null;
|
|
5474
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n,
|
|
5492
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, k, A) : n.type === "image" ? t = new CanvasImageRenderer(e, n, k, A) : n.type === "marker" ? t = new MarkerRenderer(e, n, k, A) : n.type === "unit" ? t = new UnitRenderer(e, n, k, A) : n.type === "polygon" ? t = new PolygonRenderer(e, n, k, A, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, k, A, j, M) : new CircleRenderer(e, n, k, A, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, k, A, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, k, A, j, N) : n.type === "polyline" && (t = new PolylineRenderer(e, n, k, A, N)), t && (I.current.set(n.id, t), t.setSelected(r.has(String(n.id))));
|
|
5475
5493
|
}
|
|
5476
5494
|
}
|
|
5477
5495
|
}, [
|
|
5478
|
-
T,
|
|
5479
5496
|
E,
|
|
5480
5497
|
D,
|
|
5481
5498
|
O,
|
|
5482
5499
|
k,
|
|
5483
5500
|
A,
|
|
5484
5501
|
j,
|
|
5485
|
-
M
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5502
|
+
M,
|
|
5503
|
+
N
|
|
5504
|
+
]), rn = useCallback(() => {
|
|
5505
|
+
for (let e of I.current.values()) e.destroy();
|
|
5506
|
+
I.current.clear();
|
|
5507
|
+
}, []), an = useCallback((e) => {
|
|
5490
5508
|
let t = e.getStyle();
|
|
5491
5509
|
if (!t?.layers) return;
|
|
5492
5510
|
let n = [
|
|
@@ -5501,10 +5519,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5501
5519
|
"marker-"
|
|
5502
5520
|
];
|
|
5503
5521
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
5504
|
-
}, []),
|
|
5505
|
-
let t =
|
|
5522
|
+
}, []), on = useCallback((e) => {
|
|
5523
|
+
let t = T, 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;
|
|
5506
5524
|
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;
|
|
5507
|
-
}, [
|
|
5525
|
+
}, [T]), sn = useCallback((e, t) => {
|
|
5508
5526
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
5509
5527
|
type: "raster",
|
|
5510
5528
|
tiles: [t.url],
|
|
@@ -5514,19 +5532,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5514
5532
|
scheme: t.scheme ?? "xyz"
|
|
5515
5533
|
};
|
|
5516
5534
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
5517
|
-
let a =
|
|
5535
|
+
let a = an(e);
|
|
5518
5536
|
e.addLayer({
|
|
5519
5537
|
id: r,
|
|
5520
5538
|
type: "raster",
|
|
5521
5539
|
source: n,
|
|
5522
|
-
paint:
|
|
5540
|
+
paint: on(t),
|
|
5523
5541
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
5524
5542
|
}, a);
|
|
5525
|
-
}, [
|
|
5543
|
+
}, [an, on]), cn = useCallback(async (e, t) => {
|
|
5526
5544
|
try {
|
|
5527
5545
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
5528
5546
|
if (!He.current.has(t.id)) return;
|
|
5529
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
5547
|
+
let a = n.format === "pbf" || n.vector_layers, o = an(e);
|
|
5530
5548
|
a ? (e.addSource(r, {
|
|
5531
5549
|
type: "vector",
|
|
5532
5550
|
tiles: n.tiles,
|
|
@@ -5546,13 +5564,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5546
5564
|
id: i,
|
|
5547
5565
|
type: "raster",
|
|
5548
5566
|
source: r,
|
|
5549
|
-
paint:
|
|
5567
|
+
paint: on(t),
|
|
5550
5568
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
5551
5569
|
}, o));
|
|
5552
5570
|
} catch (e) {
|
|
5553
5571
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
5554
5572
|
}
|
|
5555
|
-
}, [
|
|
5573
|
+
}, [an, on]), ln = useCallback(async (e, t) => {
|
|
5556
5574
|
try {
|
|
5557
5575
|
let n = await (await fetch(t.url)).json();
|
|
5558
5576
|
if (!He.current.has(t.id)) return;
|
|
@@ -5560,7 +5578,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5560
5578
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
5561
5579
|
e.getSource(n) || e.addSource(n, i);
|
|
5562
5580
|
}
|
|
5563
|
-
let r =
|
|
5581
|
+
let r = an(e);
|
|
5564
5582
|
if (n.layers) for (let i of n.layers) {
|
|
5565
5583
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
5566
5584
|
if (e.getLayer(n)) continue;
|
|
@@ -5571,7 +5589,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5571
5589
|
};
|
|
5572
5590
|
i.type === "raster" && (a.paint = {
|
|
5573
5591
|
...a.paint,
|
|
5574
|
-
...
|
|
5592
|
+
...on(t)
|
|
5575
5593
|
}), t.visible === !1 && (a.layout = {
|
|
5576
5594
|
...a.layout,
|
|
5577
5595
|
visibility: "none"
|
|
@@ -5584,50 +5602,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5584
5602
|
} catch (e) {
|
|
5585
5603
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
5586
5604
|
}
|
|
5587
|
-
}, [
|
|
5605
|
+
}, [an, on]), un = useCallback((e, t) => {
|
|
5588
5606
|
let n = e.getStyle();
|
|
5589
5607
|
if (!n) return;
|
|
5590
5608
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
5591
5609
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
5592
5610
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
5593
5611
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
5594
|
-
}, []),
|
|
5595
|
-
let t =
|
|
5612
|
+
}, []), dn = useCallback((e) => {
|
|
5613
|
+
let t = F.current;
|
|
5596
5614
|
if (!t) return;
|
|
5597
5615
|
let n = new Set(e.map((e) => e.id)), r = He.current;
|
|
5598
|
-
for (let e of r) n.has(e) || (
|
|
5616
|
+
for (let e of r) n.has(e) || (un(t, e), r.delete(e));
|
|
5599
5617
|
for (let n of e) if (r.has(n.id)) {
|
|
5600
5618
|
let e = `base-layer-${n.id}`;
|
|
5601
5619
|
if (t.getLayer(e)) {
|
|
5602
|
-
let r =
|
|
5620
|
+
let r = on(n);
|
|
5603
5621
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
5604
5622
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
5605
5623
|
}
|
|
5606
5624
|
} else switch (r.add(n.id), n.type) {
|
|
5607
5625
|
case "raster":
|
|
5608
|
-
|
|
5626
|
+
sn(t, n);
|
|
5609
5627
|
break;
|
|
5610
5628
|
case "tilejson":
|
|
5611
|
-
|
|
5629
|
+
cn(t, n);
|
|
5612
5630
|
break;
|
|
5613
5631
|
case "style":
|
|
5614
|
-
|
|
5632
|
+
ln(t, n);
|
|
5615
5633
|
break;
|
|
5616
5634
|
default: {
|
|
5617
5635
|
let e = n;
|
|
5618
|
-
e.url &&
|
|
5636
|
+
e.url && sn(t, {
|
|
5619
5637
|
...e,
|
|
5620
5638
|
type: "raster"
|
|
5621
5639
|
});
|
|
5622
5640
|
}
|
|
5623
5641
|
}
|
|
5624
5642
|
}, [
|
|
5625
|
-
an,
|
|
5626
|
-
on,
|
|
5627
5643
|
sn,
|
|
5628
5644
|
cn,
|
|
5629
|
-
|
|
5630
|
-
|
|
5645
|
+
ln,
|
|
5646
|
+
un,
|
|
5647
|
+
on
|
|
5648
|
+
]), fn = useCallback((e) => {
|
|
5631
5649
|
let t = e;
|
|
5632
5650
|
for (; t;) {
|
|
5633
5651
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -5635,38 +5653,38 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5635
5653
|
t = t.parentElement;
|
|
5636
5654
|
}
|
|
5637
5655
|
return null;
|
|
5638
|
-
}, []),
|
|
5656
|
+
}, []), pn = useCallback((e) => {
|
|
5639
5657
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
5640
5658
|
x: e.point.x,
|
|
5641
5659
|
y: e.point.y
|
|
5642
|
-
}, r =
|
|
5660
|
+
}, r = xn.current;
|
|
5643
5661
|
if (r === "picker") {
|
|
5644
5662
|
let e = {
|
|
5645
5663
|
lng: t[0],
|
|
5646
5664
|
lat: t[1]
|
|
5647
5665
|
};
|
|
5648
|
-
tt(e),
|
|
5666
|
+
tt(e), St(t), Sn.current?.(e);
|
|
5649
5667
|
return;
|
|
5650
5668
|
}
|
|
5651
5669
|
if (r === "edit") {
|
|
5652
|
-
let e =
|
|
5670
|
+
let e = wn.current;
|
|
5653
5671
|
if (e === "rectangle") {
|
|
5654
|
-
let e =
|
|
5672
|
+
let e = Tn.current;
|
|
5655
5673
|
if (!e) ot(t);
|
|
5656
5674
|
else {
|
|
5657
|
-
let n =
|
|
5675
|
+
let n = U.current, r = applyEntityConfig({
|
|
5658
5676
|
...n,
|
|
5659
|
-
id: n?.id ??
|
|
5677
|
+
id: n?.id ?? wt(),
|
|
5660
5678
|
type: "rectangle",
|
|
5661
5679
|
bounds: [e, t]
|
|
5662
|
-
},
|
|
5663
|
-
|
|
5664
|
-
let i =
|
|
5665
|
-
if (i && !
|
|
5666
|
-
let e = new RectangleRenderer(i, r,
|
|
5667
|
-
|
|
5680
|
+
}, O);
|
|
5681
|
+
kt();
|
|
5682
|
+
let i = F.current;
|
|
5683
|
+
if (i && !I.current.has(r.id)) {
|
|
5684
|
+
let e = new RectangleRenderer(i, r, k, A, j, N);
|
|
5685
|
+
I.current.set(r.id, e);
|
|
5668
5686
|
}
|
|
5669
|
-
|
|
5687
|
+
Q.current.onRectangleAdd?.(r), ot(null), U.current = null, H.current && (H.current = !1, V(null), i && (i.getCanvas().style.cursor = ""));
|
|
5670
5688
|
}
|
|
5671
5689
|
return;
|
|
5672
5690
|
}
|
|
@@ -5674,20 +5692,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5674
5692
|
let e = st.current;
|
|
5675
5693
|
if (!e) st.current = { center: t };
|
|
5676
5694
|
else {
|
|
5677
|
-
let n =
|
|
5695
|
+
let n = Mt(e.center, t), r = G.current, i = applyEntityConfig({
|
|
5678
5696
|
...r,
|
|
5679
|
-
id: r?.id ??
|
|
5697
|
+
id: r?.id ?? wt(),
|
|
5680
5698
|
type: "circle",
|
|
5681
5699
|
center: e.center,
|
|
5682
5700
|
radius: n
|
|
5683
|
-
},
|
|
5684
|
-
|
|
5685
|
-
let a =
|
|
5686
|
-
if (a && !
|
|
5687
|
-
let e = new CircleRenderer(a, i,
|
|
5688
|
-
|
|
5701
|
+
}, O);
|
|
5702
|
+
Pt();
|
|
5703
|
+
let a = F.current;
|
|
5704
|
+
if (a && !I.current.has(i.id)) {
|
|
5705
|
+
let e = new CircleRenderer(a, i, k, A, j, M);
|
|
5706
|
+
I.current.set(i.id, e);
|
|
5689
5707
|
}
|
|
5690
|
-
|
|
5708
|
+
Q.current.onCircleAdd?.(i), st.current = null, G.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
5691
5709
|
}
|
|
5692
5710
|
return;
|
|
5693
5711
|
}
|
|
@@ -5695,20 +5713,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5695
5713
|
let e = ct.current;
|
|
5696
5714
|
if (e.length >= 3) {
|
|
5697
5715
|
let n = e[0];
|
|
5698
|
-
if (
|
|
5699
|
-
let t =
|
|
5716
|
+
if (Mt(n, t) < 20) {
|
|
5717
|
+
let t = K.current, n = applyEntityConfig({
|
|
5700
5718
|
...t,
|
|
5701
|
-
id: t?.id ??
|
|
5719
|
+
id: t?.id ?? wt(),
|
|
5702
5720
|
type: "polygon",
|
|
5703
5721
|
coordinates: [...e]
|
|
5704
|
-
},
|
|
5705
|
-
|
|
5706
|
-
let r =
|
|
5707
|
-
if (r && !
|
|
5708
|
-
let e = new PolygonRenderer(r, n,
|
|
5709
|
-
|
|
5722
|
+
}, O);
|
|
5723
|
+
Rt();
|
|
5724
|
+
let r = F.current;
|
|
5725
|
+
if (r && !I.current.has(n.id)) {
|
|
5726
|
+
let e = new PolygonRenderer(r, n, k, A, j, N);
|
|
5727
|
+
I.current.set(n.id, e);
|
|
5710
5728
|
}
|
|
5711
|
-
|
|
5729
|
+
Q.current.onPolygonAdd?.(n), ct.current = [], K.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
5712
5730
|
return;
|
|
5713
5731
|
}
|
|
5714
5732
|
}
|
|
@@ -5719,20 +5737,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5719
5737
|
let e = lt.current;
|
|
5720
5738
|
if (!e) lt.current = { center: t };
|
|
5721
5739
|
else {
|
|
5722
|
-
let n =
|
|
5740
|
+
let n = Mt(e.center, t) * 2, r = q.current, i = applyEntityConfig({
|
|
5723
5741
|
...r,
|
|
5724
|
-
id: r?.id ??
|
|
5742
|
+
id: r?.id ?? wt(),
|
|
5725
5743
|
type: "square",
|
|
5726
5744
|
center: e.center,
|
|
5727
5745
|
length: n
|
|
5728
|
-
},
|
|
5729
|
-
|
|
5730
|
-
let a =
|
|
5731
|
-
if (a && !
|
|
5732
|
-
let e = new SquareRenderer(a, i,
|
|
5733
|
-
|
|
5746
|
+
}, O);
|
|
5747
|
+
Ut();
|
|
5748
|
+
let a = F.current;
|
|
5749
|
+
if (a && !I.current.has(i.id)) {
|
|
5750
|
+
let e = new SquareRenderer(a, i, k, A, j, N);
|
|
5751
|
+
I.current.set(i.id, e);
|
|
5734
5752
|
}
|
|
5735
|
-
|
|
5753
|
+
Q.current.onSquareAdd?.(i), lt.current = null, q.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
5736
5754
|
}
|
|
5737
5755
|
return;
|
|
5738
5756
|
}
|
|
@@ -5740,89 +5758,89 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5740
5758
|
ut.current = [...ut.current, t];
|
|
5741
5759
|
return;
|
|
5742
5760
|
}
|
|
5743
|
-
let n =
|
|
5761
|
+
let n = W.current;
|
|
5744
5762
|
if (n && n.src && n.width) {
|
|
5745
5763
|
let e = {
|
|
5746
5764
|
...n,
|
|
5747
|
-
id: n.id ??
|
|
5765
|
+
id: n.id ?? wt(),
|
|
5748
5766
|
type: "marker",
|
|
5749
5767
|
center: t,
|
|
5750
5768
|
src: n.src,
|
|
5751
5769
|
width: n.width
|
|
5752
5770
|
};
|
|
5753
|
-
|
|
5771
|
+
Q.current.onMarkerAdd?.(e), B(null), V(null), Y(), W.current = null, H.current = !1;
|
|
5754
5772
|
return;
|
|
5755
5773
|
}
|
|
5756
|
-
let r =
|
|
5774
|
+
let r = Cn.current;
|
|
5757
5775
|
if (r) {
|
|
5758
5776
|
let e = {
|
|
5759
|
-
id:
|
|
5777
|
+
id: wt(),
|
|
5760
5778
|
type: "marker",
|
|
5761
5779
|
name: r.name,
|
|
5762
5780
|
center: t,
|
|
5763
5781
|
src: r.icon,
|
|
5764
5782
|
width: r.size || r.width || 32
|
|
5765
5783
|
};
|
|
5766
|
-
r.customData !== void 0 && (e.customData = r.customData),
|
|
5784
|
+
r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), B(null), V(null), Y(), H.current = !1;
|
|
5767
5785
|
return;
|
|
5768
5786
|
}
|
|
5769
5787
|
}
|
|
5770
|
-
let i =
|
|
5788
|
+
let i = vn.current, a = yn.current, o = bn.current, s = fn(e.originalEvent.target);
|
|
5771
5789
|
if (s) {
|
|
5772
5790
|
let e = i.find((e) => String(e.id) === s);
|
|
5773
5791
|
if (e) {
|
|
5774
5792
|
if (a?.(e), e.popup) {
|
|
5775
5793
|
let t = e.popup.content ?? Pe?.(e);
|
|
5776
|
-
t && mergePopupConfig(e.popup,
|
|
5794
|
+
t && mergePopupConfig(e.popup, P, t).trigger === "click" && o(s, "click", n);
|
|
5777
5795
|
}
|
|
5778
5796
|
return;
|
|
5779
5797
|
}
|
|
5780
5798
|
}
|
|
5781
|
-
for (let [t, r] of
|
|
5799
|
+
for (let [t, r] of I.current) {
|
|
5782
5800
|
let s = r.getLabelLayerId();
|
|
5783
|
-
if (s &&
|
|
5801
|
+
if (s && F.current?.getLayer(s) && F.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
5784
5802
|
let e = i.find((e) => e.id === t);
|
|
5785
5803
|
if (e) {
|
|
5786
5804
|
if (a?.(e), e.popup) {
|
|
5787
5805
|
let r = e.popup.content ?? Pe?.(e);
|
|
5788
|
-
r && mergePopupConfig(e.popup,
|
|
5806
|
+
r && mergePopupConfig(e.popup, P, r).trigger === "click" && o(t, "click", n);
|
|
5789
5807
|
}
|
|
5790
5808
|
return;
|
|
5791
5809
|
}
|
|
5792
5810
|
}
|
|
5793
5811
|
}
|
|
5794
|
-
for (let [e, r] of
|
|
5812
|
+
for (let [e, r] of I.current) if (r.isPointInEntity(t)) {
|
|
5795
5813
|
let t = i.find((t) => t.id === e);
|
|
5796
5814
|
if (t) {
|
|
5797
5815
|
if (a?.(t), t.popup) {
|
|
5798
5816
|
let r = t.popup.content ?? Pe?.(t);
|
|
5799
|
-
r && mergePopupConfig(t.popup,
|
|
5817
|
+
r && mergePopupConfig(t.popup, P, r).trigger === "click" && o(e, "click", n);
|
|
5800
5818
|
}
|
|
5801
5819
|
return;
|
|
5802
5820
|
}
|
|
5803
5821
|
}
|
|
5804
5822
|
}, [
|
|
5805
|
-
|
|
5823
|
+
P,
|
|
5806
5824
|
Pe,
|
|
5807
|
-
|
|
5808
|
-
]),
|
|
5809
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5810
|
-
n === "rectangle" && r &&
|
|
5825
|
+
fn
|
|
5826
|
+
]), mn = useCallback((e) => {
|
|
5827
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = wn.current, r = Tn.current;
|
|
5828
|
+
n === "rectangle" && r && Ot(r, t);
|
|
5811
5829
|
let i = st.current;
|
|
5812
|
-
n === "circle" && i &&
|
|
5830
|
+
n === "circle" && i && Nt(i.center, t);
|
|
5813
5831
|
let a = ct.current;
|
|
5814
|
-
n === "polygon" && a.length > 0 &&
|
|
5832
|
+
n === "polygon" && a.length > 0 && Lt(a, t);
|
|
5815
5833
|
let o = lt.current;
|
|
5816
|
-
n === "square" && o &&
|
|
5834
|
+
n === "square" && o && Ht(o.center, t);
|
|
5817
5835
|
let s = ut.current;
|
|
5818
|
-
n === "polyline" && s.length > 0 &&
|
|
5819
|
-
let c =
|
|
5820
|
-
for (let [e, n] of
|
|
5836
|
+
n === "polyline" && s.length > 0 && Kt(s, t);
|
|
5837
|
+
let c = vn.current, l = bn.current;
|
|
5838
|
+
for (let [e, n] of I.current) if (n.isPointInEntity(t)) {
|
|
5821
5839
|
let t = c.find((t) => t.id === e);
|
|
5822
5840
|
if (!t?.popup) continue;
|
|
5823
5841
|
let n = t.popup.content ?? Pe?.(t);
|
|
5824
5842
|
if (!n) continue;
|
|
5825
|
-
let r = mergePopupConfig(t.popup,
|
|
5843
|
+
let r = mergePopupConfig(t.popup, P, n);
|
|
5826
5844
|
if (r.trigger === "hover") {
|
|
5827
5845
|
Ke.current && clearTimeout(Ke.current), Ke.current = window.setTimeout(() => {
|
|
5828
5846
|
l(e, "hover");
|
|
@@ -5830,41 +5848,41 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5830
5848
|
return;
|
|
5831
5849
|
}
|
|
5832
5850
|
}
|
|
5833
|
-
if (Ke.current &&= (clearTimeout(Ke.current), null),
|
|
5834
|
-
let e =
|
|
5835
|
-
e && !e.isPointInEntity(t) &&
|
|
5851
|
+
if (Ke.current &&= (clearTimeout(Ke.current), null), R?.openedBy === "hover") {
|
|
5852
|
+
let e = I.current.get(R.entityId);
|
|
5853
|
+
e && !e.isPointInEntity(t) && _t(R.entityId);
|
|
5836
5854
|
}
|
|
5837
5855
|
}, [
|
|
5838
|
-
|
|
5856
|
+
P,
|
|
5839
5857
|
Pe,
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
]),
|
|
5848
|
-
if (e.preventDefault(),
|
|
5849
|
-
if (
|
|
5850
|
-
|
|
5858
|
+
R,
|
|
5859
|
+
_t,
|
|
5860
|
+
Ot,
|
|
5861
|
+
Nt,
|
|
5862
|
+
Lt,
|
|
5863
|
+
Ht,
|
|
5864
|
+
Kt
|
|
5865
|
+
]), hn = useCallback((e) => {
|
|
5866
|
+
if (e.preventDefault(), xn.current !== "edit") return;
|
|
5867
|
+
if (Cn.current) {
|
|
5868
|
+
B(null), V(null), Y();
|
|
5851
5869
|
return;
|
|
5852
5870
|
}
|
|
5853
|
-
let t =
|
|
5871
|
+
let t = wn.current;
|
|
5854
5872
|
if (t === "rectangle") {
|
|
5855
|
-
if (
|
|
5873
|
+
if (Tn.current) ot(null), kt();
|
|
5856
5874
|
else {
|
|
5857
|
-
|
|
5858
|
-
let e =
|
|
5875
|
+
V(null);
|
|
5876
|
+
let e = F.current;
|
|
5859
5877
|
e && (e.getCanvas().style.cursor = "");
|
|
5860
5878
|
}
|
|
5861
5879
|
return;
|
|
5862
5880
|
}
|
|
5863
5881
|
if (t === "circle") {
|
|
5864
|
-
if (st.current) st.current = null,
|
|
5882
|
+
if (st.current) st.current = null, Pt();
|
|
5865
5883
|
else {
|
|
5866
|
-
|
|
5867
|
-
let e =
|
|
5884
|
+
V(null);
|
|
5885
|
+
let e = F.current;
|
|
5868
5886
|
e && (e.getCanvas().style.cursor = "");
|
|
5869
5887
|
}
|
|
5870
5888
|
return;
|
|
@@ -5872,32 +5890,32 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5872
5890
|
if (t === "polygon") {
|
|
5873
5891
|
let e = ct.current;
|
|
5874
5892
|
if (e.length >= 3) {
|
|
5875
|
-
let t =
|
|
5893
|
+
let t = K.current, n = applyEntityConfig({
|
|
5876
5894
|
...t,
|
|
5877
|
-
id: t?.id ??
|
|
5895
|
+
id: t?.id ?? wt(),
|
|
5878
5896
|
type: "polygon",
|
|
5879
5897
|
coordinates: [...e]
|
|
5880
|
-
},
|
|
5881
|
-
|
|
5882
|
-
let r =
|
|
5883
|
-
if (r && !
|
|
5884
|
-
let e = new PolygonRenderer(r, n,
|
|
5885
|
-
|
|
5898
|
+
}, O);
|
|
5899
|
+
Rt();
|
|
5900
|
+
let r = F.current;
|
|
5901
|
+
if (r && !I.current.has(n.id)) {
|
|
5902
|
+
let e = new PolygonRenderer(r, n, k, A, j, N);
|
|
5903
|
+
I.current.set(n.id, e);
|
|
5886
5904
|
}
|
|
5887
|
-
|
|
5888
|
-
} else if (e.length > 0) ct.current = [],
|
|
5905
|
+
Q.current.onPolygonAdd?.(n), ct.current = [], K.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
5906
|
+
} else if (e.length > 0) ct.current = [], Rt();
|
|
5889
5907
|
else {
|
|
5890
|
-
|
|
5891
|
-
let e =
|
|
5908
|
+
V(null);
|
|
5909
|
+
let e = F.current;
|
|
5892
5910
|
e && (e.getCanvas().style.cursor = "");
|
|
5893
5911
|
}
|
|
5894
5912
|
return;
|
|
5895
5913
|
}
|
|
5896
5914
|
if (t === "square") {
|
|
5897
|
-
if (lt.current) lt.current = null,
|
|
5915
|
+
if (lt.current) lt.current = null, Ut();
|
|
5898
5916
|
else {
|
|
5899
|
-
|
|
5900
|
-
let e =
|
|
5917
|
+
V(null);
|
|
5918
|
+
let e = F.current;
|
|
5901
5919
|
e && (e.getCanvas().style.cursor = "");
|
|
5902
5920
|
}
|
|
5903
5921
|
return;
|
|
@@ -5905,23 +5923,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5905
5923
|
if (t === "polyline") {
|
|
5906
5924
|
let e = ut.current;
|
|
5907
5925
|
if (e.length >= 2) {
|
|
5908
|
-
let t =
|
|
5926
|
+
let t = J.current, n = applyEntityConfig({
|
|
5909
5927
|
...t,
|
|
5910
|
-
id: t?.id ??
|
|
5928
|
+
id: t?.id ?? wt(),
|
|
5911
5929
|
type: "polyline",
|
|
5912
5930
|
coordinates: [...e]
|
|
5913
|
-
},
|
|
5914
|
-
|
|
5915
|
-
let r =
|
|
5916
|
-
if (r && !
|
|
5917
|
-
let e = new PolylineRenderer(r, n,
|
|
5918
|
-
|
|
5931
|
+
}, O);
|
|
5932
|
+
qt();
|
|
5933
|
+
let r = F.current;
|
|
5934
|
+
if (r && !I.current.has(n.id)) {
|
|
5935
|
+
let e = new PolylineRenderer(r, n, k, A, N);
|
|
5936
|
+
I.current.set(n.id, e);
|
|
5919
5937
|
}
|
|
5920
|
-
|
|
5921
|
-
} else if (e.length > 0) ut.current = [],
|
|
5938
|
+
Q.current.onPolylineAdd?.(n), ut.current = [], J.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
5939
|
+
} else if (e.length > 0) ut.current = [], qt();
|
|
5922
5940
|
else {
|
|
5923
|
-
|
|
5924
|
-
let e =
|
|
5941
|
+
V(null);
|
|
5942
|
+
let e = F.current;
|
|
5925
5943
|
e && (e.getCanvas().style.cursor = "");
|
|
5926
5944
|
}
|
|
5927
5945
|
return;
|
|
@@ -5929,40 +5947,40 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5929
5947
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
5930
5948
|
x: e.point.x,
|
|
5931
5949
|
y: e.point.y
|
|
5932
|
-
}, i =
|
|
5950
|
+
}, i = vn.current, a = fn(e.originalEvent.target);
|
|
5933
5951
|
if (a) {
|
|
5934
5952
|
let e = i.find((e) => String(e.id) === a);
|
|
5935
5953
|
if (e) {
|
|
5936
|
-
|
|
5954
|
+
gn(e, r, n);
|
|
5937
5955
|
return;
|
|
5938
5956
|
}
|
|
5939
5957
|
}
|
|
5940
|
-
for (let [t, a] of
|
|
5958
|
+
for (let [t, a] of I.current) {
|
|
5941
5959
|
let o = a.getLabelLayerId();
|
|
5942
|
-
if (o &&
|
|
5960
|
+
if (o && F.current?.getLayer(o) && F.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
5943
5961
|
let e = i.find((e) => e.id === t);
|
|
5944
5962
|
if (e) {
|
|
5945
|
-
|
|
5963
|
+
gn(e, r, n);
|
|
5946
5964
|
return;
|
|
5947
5965
|
}
|
|
5948
5966
|
}
|
|
5949
5967
|
}
|
|
5950
|
-
for (let [e, t] of
|
|
5968
|
+
for (let [e, t] of I.current) if (t.isPointInEntity(n)) {
|
|
5951
5969
|
let t = i.find((t) => t.id === e);
|
|
5952
5970
|
if (t) {
|
|
5953
|
-
|
|
5971
|
+
gn(t, r, n);
|
|
5954
5972
|
return;
|
|
5955
5973
|
}
|
|
5956
5974
|
}
|
|
5957
5975
|
}, [
|
|
5958
|
-
|
|
5976
|
+
fn,
|
|
5959
5977
|
Y,
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
]),
|
|
5978
|
+
kt,
|
|
5979
|
+
Pt,
|
|
5980
|
+
Rt,
|
|
5981
|
+
Ut,
|
|
5982
|
+
qt
|
|
5983
|
+
]), gn = useCallback((e, t, n) => {
|
|
5966
5984
|
let r = Ve.current?.getBoundingClientRect(), i = r ? {
|
|
5967
5985
|
x: t.x + r.left,
|
|
5968
5986
|
y: t.y + r.top
|
|
@@ -5983,11 +6001,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5983
6001
|
}),
|
|
5984
6002
|
danger: !0,
|
|
5985
6003
|
onClick: () => {
|
|
5986
|
-
|
|
6004
|
+
Q.current.onEntityDelete?.(e);
|
|
5987
6005
|
}
|
|
5988
6006
|
}]
|
|
5989
6007
|
});
|
|
5990
|
-
}, []),
|
|
6008
|
+
}, []), _n = useCallback(() => {
|
|
5991
6009
|
Je(null);
|
|
5992
6010
|
}, []);
|
|
5993
6011
|
useEffect(() => {
|
|
@@ -5999,11 +6017,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5999
6017
|
width: 100%;
|
|
6000
6018
|
pointer-events: none;
|
|
6001
6019
|
height: 100%;
|
|
6002
|
-
z-index: ${
|
|
6020
|
+
z-index: ${P?.zIndex ?? 1e3};
|
|
6003
6021
|
`, document.body.appendChild(e), We.current = e, () => {
|
|
6004
6022
|
document.body.contains(e) && document.body.removeChild(e);
|
|
6005
6023
|
};
|
|
6006
|
-
}, [
|
|
6024
|
+
}, [P?.zIndex]), useEffect(() => {
|
|
6007
6025
|
let e = document.createElement("div");
|
|
6008
6026
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
6009
6027
|
position: fixed;
|
|
@@ -6012,61 +6030,61 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6012
6030
|
width: 100%;
|
|
6013
6031
|
pointer-events: none;
|
|
6014
6032
|
height: 100%;
|
|
6015
|
-
z-index: ${(
|
|
6033
|
+
z-index: ${(P?.zIndex ?? 1e3) + 100};
|
|
6016
6034
|
`, document.body.appendChild(e), Ye.current = e, () => {
|
|
6017
6035
|
document.body.contains(e) && document.body.removeChild(e);
|
|
6018
6036
|
};
|
|
6019
|
-
}, [
|
|
6020
|
-
let
|
|
6021
|
-
|
|
6022
|
-
let
|
|
6023
|
-
|
|
6024
|
-
let
|
|
6025
|
-
|
|
6026
|
-
let
|
|
6027
|
-
|
|
6028
|
-
let
|
|
6029
|
-
|
|
6030
|
-
let
|
|
6031
|
-
|
|
6032
|
-
let
|
|
6033
|
-
|
|
6034
|
-
let
|
|
6035
|
-
|
|
6036
|
-
let
|
|
6037
|
-
|
|
6038
|
-
let
|
|
6039
|
-
|
|
6037
|
+
}, [P?.zIndex]);
|
|
6038
|
+
let vn = useRef(E);
|
|
6039
|
+
vn.current = E;
|
|
6040
|
+
let yn = useRef(Ie);
|
|
6041
|
+
yn.current = Ie;
|
|
6042
|
+
let bn = useRef(gt);
|
|
6043
|
+
bn.current = gt;
|
|
6044
|
+
let xn = useRef(z);
|
|
6045
|
+
xn.current = z;
|
|
6046
|
+
let Sn = useRef(b);
|
|
6047
|
+
Sn.current = b;
|
|
6048
|
+
let Cn = useRef(rt);
|
|
6049
|
+
Cn.current = rt;
|
|
6050
|
+
let wn = useRef(it);
|
|
6051
|
+
wn.current = it;
|
|
6052
|
+
let Tn = useRef(at);
|
|
6053
|
+
Tn.current = at;
|
|
6054
|
+
let Q = useRef(v);
|
|
6055
|
+
Q.current = v;
|
|
6056
|
+
let En = useRef(O);
|
|
6057
|
+
En.current = O, useEffect(() => {
|
|
6040
6058
|
let e = (e) => {
|
|
6041
|
-
if (e.key === "Escape" &&
|
|
6042
|
-
if (rt && (
|
|
6059
|
+
if (e.key === "Escape" && z === "edit") {
|
|
6060
|
+
if (rt && (B(null), V(null), Y()), it === "rectangle") if (at) ot(null), kt();
|
|
6043
6061
|
else {
|
|
6044
|
-
|
|
6045
|
-
let e =
|
|
6062
|
+
V(null);
|
|
6063
|
+
let e = F.current;
|
|
6046
6064
|
e && (e.getCanvas().style.cursor = "");
|
|
6047
6065
|
}
|
|
6048
|
-
if (it === "circle") if (st.current) st.current = null,
|
|
6066
|
+
if (it === "circle") if (st.current) st.current = null, Pt();
|
|
6049
6067
|
else {
|
|
6050
|
-
|
|
6051
|
-
let e =
|
|
6068
|
+
V(null);
|
|
6069
|
+
let e = F.current;
|
|
6052
6070
|
e && (e.getCanvas().style.cursor = "");
|
|
6053
6071
|
}
|
|
6054
|
-
if (it === "polygon") if (ct.current.length > 0) ct.current = [],
|
|
6072
|
+
if (it === "polygon") if (ct.current.length > 0) ct.current = [], Rt();
|
|
6055
6073
|
else {
|
|
6056
|
-
|
|
6057
|
-
let e =
|
|
6074
|
+
V(null);
|
|
6075
|
+
let e = F.current;
|
|
6058
6076
|
e && (e.getCanvas().style.cursor = "");
|
|
6059
6077
|
}
|
|
6060
|
-
if (it === "square") if (lt.current) lt.current = null,
|
|
6078
|
+
if (it === "square") if (lt.current) lt.current = null, Ut();
|
|
6061
6079
|
else {
|
|
6062
|
-
|
|
6063
|
-
let e =
|
|
6080
|
+
V(null);
|
|
6081
|
+
let e = F.current;
|
|
6064
6082
|
e && (e.getCanvas().style.cursor = "");
|
|
6065
6083
|
}
|
|
6066
|
-
if (it === "polyline") if (ut.current.length > 0) ut.current = [],
|
|
6084
|
+
if (it === "polyline") if (ut.current.length > 0) ut.current = [], qt();
|
|
6067
6085
|
else {
|
|
6068
|
-
|
|
6069
|
-
let e =
|
|
6086
|
+
V(null);
|
|
6087
|
+
let e = F.current;
|
|
6070
6088
|
e && (e.getCanvas().style.cursor = "");
|
|
6071
6089
|
}
|
|
6072
6090
|
}
|
|
@@ -6075,23 +6093,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6075
6093
|
document.removeEventListener("keydown", e);
|
|
6076
6094
|
};
|
|
6077
6095
|
}, [
|
|
6078
|
-
|
|
6096
|
+
z,
|
|
6079
6097
|
rt,
|
|
6080
6098
|
it,
|
|
6081
6099
|
at,
|
|
6082
6100
|
Y,
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6101
|
+
kt,
|
|
6102
|
+
Pt,
|
|
6103
|
+
Rt,
|
|
6104
|
+
Ut,
|
|
6105
|
+
qt
|
|
6088
6106
|
]), useEffect(() => {
|
|
6089
|
-
let e =
|
|
6090
|
-
if (!e || !
|
|
6091
|
-
let t =
|
|
6092
|
-
let r =
|
|
6107
|
+
let e = F.current;
|
|
6108
|
+
if (!e || !R) return;
|
|
6109
|
+
let t = R.entityId, n = R.config, r = () => {
|
|
6110
|
+
let r = vn.current.find((e) => e.id === t);
|
|
6093
6111
|
if (!r) {
|
|
6094
|
-
|
|
6112
|
+
vt();
|
|
6095
6113
|
return;
|
|
6096
6114
|
}
|
|
6097
6115
|
let { position: i } = calculatePopupPosition(r, n, e, void 0, Ge.current);
|
|
@@ -6102,13 +6120,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6102
6120
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
6103
6121
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
6104
6122
|
};
|
|
6105
|
-
}, [
|
|
6106
|
-
let e =
|
|
6123
|
+
}, [R?.entityId, vt]), useEffect(() => {
|
|
6124
|
+
let e = F.current, t = Ve.current;
|
|
6107
6125
|
if (!e || !qe || !t) return;
|
|
6108
6126
|
let n = qe.lngLat, r = () => {
|
|
6109
6127
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
6110
6128
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
6111
|
-
|
|
6129
|
+
_n();
|
|
6112
6130
|
return;
|
|
6113
6131
|
}
|
|
6114
6132
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
@@ -6117,7 +6135,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6117
6135
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
6118
6136
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
6119
6137
|
};
|
|
6120
|
-
}, [qe?.lngLat,
|
|
6138
|
+
}, [qe?.lngLat, _n]), useEffect(() => {
|
|
6121
6139
|
if (!Ve.current) return;
|
|
6122
6140
|
let e = {
|
|
6123
6141
|
version: 8,
|
|
@@ -6151,98 +6169,98 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6151
6169
|
return { url: e };
|
|
6152
6170
|
}
|
|
6153
6171
|
});
|
|
6154
|
-
return
|
|
6172
|
+
return F.current = _, _.on("load", () => {
|
|
6155
6173
|
if (!_.getStyle().glyphs) {
|
|
6156
6174
|
let e = _.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
6157
6175
|
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
6158
6176
|
}
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
}),
|
|
6162
|
-
}), _.on("click",
|
|
6163
|
-
_.off("click",
|
|
6177
|
+
L.current.clear(), E.forEach((e) => {
|
|
6178
|
+
L.current.set(e.id, e);
|
|
6179
|
+
}), dn(S), nn(), Dt(), At(), It(), Bt(), Gt(), Qe(_), Fe?.(_);
|
|
6180
|
+
}), _.on("click", pn), _.on("mousemove", mn), _.on("contextmenu", hn), () => {
|
|
6181
|
+
_.off("click", pn), _.off("mousemove", mn), _.off("contextmenu", hn), rn(), Ct(), Y(), X(), Z(), _.remove(), F.current = null;
|
|
6164
6182
|
};
|
|
6165
6183
|
}, []), useEffect(() => {
|
|
6166
|
-
if (
|
|
6167
|
-
if (!
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
}),
|
|
6184
|
+
if (F.current) {
|
|
6185
|
+
if (!F.current.isStyleLoaded()) {
|
|
6186
|
+
F.current.once("load", () => {
|
|
6187
|
+
L.current.clear(), E.forEach((e) => {
|
|
6188
|
+
L.current.set(e.id, e);
|
|
6189
|
+
}), nn();
|
|
6172
6190
|
});
|
|
6173
6191
|
return;
|
|
6174
6192
|
}
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
}),
|
|
6193
|
+
L.current.clear(), E.forEach((e) => {
|
|
6194
|
+
L.current.set(e.id, e);
|
|
6195
|
+
}), nn();
|
|
6178
6196
|
}
|
|
6179
|
-
}, [
|
|
6180
|
-
!
|
|
6197
|
+
}, [E, nn]), useEffect(() => {
|
|
6198
|
+
!F.current || !F.current.isStyleLoaded() || (rn(), nn());
|
|
6181
6199
|
}, [
|
|
6182
|
-
O,
|
|
6183
6200
|
k,
|
|
6184
6201
|
A,
|
|
6185
6202
|
j,
|
|
6186
6203
|
M,
|
|
6187
|
-
|
|
6188
|
-
|
|
6204
|
+
N,
|
|
6205
|
+
rn,
|
|
6206
|
+
nn
|
|
6189
6207
|
]), useEffect(() => {
|
|
6190
|
-
if (
|
|
6191
|
-
if (!
|
|
6192
|
-
|
|
6193
|
-
|
|
6208
|
+
if (F.current) {
|
|
6209
|
+
if (!F.current.isStyleLoaded()) {
|
|
6210
|
+
F.current.once("load", () => {
|
|
6211
|
+
dn(S);
|
|
6194
6212
|
});
|
|
6195
6213
|
return;
|
|
6196
6214
|
}
|
|
6197
|
-
|
|
6215
|
+
dn(S);
|
|
6198
6216
|
}
|
|
6199
|
-
}, [S,
|
|
6200
|
-
let
|
|
6201
|
-
|
|
6202
|
-
let
|
|
6203
|
-
|
|
6204
|
-
let
|
|
6205
|
-
|
|
6206
|
-
let
|
|
6207
|
-
|
|
6208
|
-
let
|
|
6209
|
-
|
|
6210
|
-
let
|
|
6211
|
-
|
|
6212
|
-
let
|
|
6213
|
-
|
|
6214
|
-
let
|
|
6215
|
-
|
|
6216
|
-
let
|
|
6217
|
-
|
|
6218
|
-
let e =
|
|
6217
|
+
}, [S, dn]);
|
|
6218
|
+
let Dn = useRef(void 0), On = useRef(!0), kn = useRef(S);
|
|
6219
|
+
kn.current = S;
|
|
6220
|
+
let An = useRef(dn);
|
|
6221
|
+
An.current = dn;
|
|
6222
|
+
let jn = useRef(rn);
|
|
6223
|
+
jn.current = rn;
|
|
6224
|
+
let Mn = useRef(nn);
|
|
6225
|
+
Mn.current = nn;
|
|
6226
|
+
let Nn = useRef(Dt);
|
|
6227
|
+
Nn.current = Dt;
|
|
6228
|
+
let Pn = useRef(At);
|
|
6229
|
+
Pn.current = At;
|
|
6230
|
+
let Fn = useRef(It);
|
|
6231
|
+
Fn.current = It;
|
|
6232
|
+
let In = useRef(Bt);
|
|
6233
|
+
In.current = Bt;
|
|
6234
|
+
let Ln = useRef(Gt);
|
|
6235
|
+
Ln.current = Gt, useEffect(() => {
|
|
6236
|
+
let e = F.current;
|
|
6219
6237
|
if (!e) return;
|
|
6220
6238
|
let t = h || {
|
|
6221
6239
|
version: 8,
|
|
6222
6240
|
sources: {},
|
|
6223
6241
|
layers: []
|
|
6224
6242
|
};
|
|
6225
|
-
if (
|
|
6226
|
-
|
|
6243
|
+
if (On.current) {
|
|
6244
|
+
On.current = !1, Dn.current = h;
|
|
6227
6245
|
return;
|
|
6228
6246
|
}
|
|
6229
|
-
|
|
6247
|
+
Dn.current !== h && (Dn.current = h, e.setStyle(t), e.once("style.load", () => {
|
|
6230
6248
|
if (!e.getStyle().glyphs) {
|
|
6231
6249
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
6232
6250
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
6233
6251
|
}
|
|
6234
|
-
He.current.clear(),
|
|
6252
|
+
He.current.clear(), An.current(kn.current), jn.current(), Mn.current(), Nn.current(), Pn.current(), Fn.current(), In.current(), Ln.current();
|
|
6235
6253
|
}));
|
|
6236
6254
|
}, [h]), useEffect(() => {
|
|
6237
|
-
let e = new Set(
|
|
6238
|
-
for (let [t, n] of
|
|
6239
|
-
}, [
|
|
6240
|
-
let
|
|
6255
|
+
let e = new Set(D.map(String));
|
|
6256
|
+
for (let [t, n] of I.current) n.setSelected(e.has(String(t)));
|
|
6257
|
+
}, [D]);
|
|
6258
|
+
let Rn = useRef({});
|
|
6241
6259
|
useEffect(() => {
|
|
6242
|
-
let e =
|
|
6260
|
+
let e = F.current;
|
|
6243
6261
|
if (!e) return;
|
|
6244
|
-
let t =
|
|
6245
|
-
!n && !r && !i && !a || (
|
|
6262
|
+
let t = Rn.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;
|
|
6263
|
+
!n && !r && !i && !a || (Rn.current = {
|
|
6246
6264
|
center: l,
|
|
6247
6265
|
zoom: u,
|
|
6248
6266
|
pitch: d,
|
|
@@ -6259,13 +6277,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6259
6277
|
d,
|
|
6260
6278
|
f
|
|
6261
6279
|
]);
|
|
6262
|
-
let
|
|
6280
|
+
let zn = (() => xe === !1 ? null : xe === !0 ? { enabled: !0 } : xe)(), Bn = (() => Te === !1 ? null : Te === !0 ? { enabled: !0 } : Te)(), Vn = (() => Ee === !1 ? null : Ee === !0 ? { enabled: !0 } : Ee)(), $ = (() => {
|
|
6263
6281
|
if (De === !1) return null;
|
|
6264
6282
|
let e, t;
|
|
6265
6283
|
if (S && S.length > 0) {
|
|
6266
6284
|
let n = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
6267
6285
|
if (n.type === "style") {
|
|
6268
|
-
let t =
|
|
6286
|
+
let t = F.current?.getStyle();
|
|
6269
6287
|
if (t?.sources) {
|
|
6270
6288
|
let r = `base-layer-source-${n.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(r));
|
|
6271
6289
|
i && (e = i);
|
|
@@ -6282,10 +6300,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6282
6300
|
source: De.source || e,
|
|
6283
6301
|
sourceLayer: De.sourceLayer || t
|
|
6284
6302
|
};
|
|
6285
|
-
})(),
|
|
6303
|
+
})(), Hn = (() => ke ? ke === !0 ? { enabled: !0 } : ke : null)(), Un = (() => Ae ? Ae === !0 ? { enabled: !0 } : Ae : null)(), Wn = useMemo(() => {
|
|
6286
6304
|
let e = [];
|
|
6287
6305
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
6288
|
-
let n =
|
|
6306
|
+
let n = F.current;
|
|
6289
6307
|
if (n) {
|
|
6290
6308
|
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
6291
6309
|
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
@@ -6294,14 +6312,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6294
6312
|
return e;
|
|
6295
6313
|
}, [S, Ze]);
|
|
6296
6314
|
return /* @__PURE__ */ jsxs("div", {
|
|
6297
|
-
className: `comp-mapbox ${
|
|
6315
|
+
className: `comp-mapbox ${z === "picker" ? "comp-mapbox--picker-mode" : ""} ${ze}`,
|
|
6298
6316
|
style: Be,
|
|
6299
6317
|
children: [
|
|
6300
6318
|
/* @__PURE__ */ jsx("div", {
|
|
6301
6319
|
ref: Ve,
|
|
6302
6320
|
className: "comp-mapbox__map"
|
|
6303
6321
|
}),
|
|
6304
|
-
|
|
6322
|
+
z === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
6305
6323
|
className: "comp-mapbox__crosshair",
|
|
6306
6324
|
children: [/* @__PURE__ */ jsx("div", {
|
|
6307
6325
|
className: "comp-mapbox__crosshair-h",
|
|
@@ -6311,14 +6329,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6311
6329
|
style: y.crosshairColor ? { backgroundColor: y.crosshairColor } : void 0
|
|
6312
6330
|
})]
|
|
6313
6331
|
}),
|
|
6314
|
-
|
|
6332
|
+
z === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
|
|
6315
6333
|
className: "comp-mapbox__edit-controls",
|
|
6316
|
-
children: [
|
|
6334
|
+
children: [z === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
6317
6335
|
markerTemplates: v.markerTemplates || [],
|
|
6318
6336
|
selectedTemplate: rt,
|
|
6319
|
-
onTemplateSelect:
|
|
6337
|
+
onTemplateSelect: Jt,
|
|
6320
6338
|
drawMode: it,
|
|
6321
|
-
onDrawModeChange:
|
|
6339
|
+
onDrawModeChange: Yt,
|
|
6322
6340
|
showRectangleTool: v.showRectangleTool,
|
|
6323
6341
|
showCircleTool: v.showCircleTool,
|
|
6324
6342
|
showPolygonTool: v.showPolygonTool,
|
|
@@ -6335,57 +6353,57 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6335
6353
|
style: $.style
|
|
6336
6354
|
})]
|
|
6337
6355
|
}) : null,
|
|
6338
|
-
(
|
|
6356
|
+
(zn?.enabled !== !1 || Bn?.enabled !== !1 || Vn?.enabled !== !1 || Hn && Hn.enabled !== !1 || Un && Un.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
6339
6357
|
className: "comp-mapbox__controls",
|
|
6340
6358
|
children: [
|
|
6341
|
-
|
|
6342
|
-
map: Ze,
|
|
6343
|
-
precision: Rn.precision,
|
|
6344
|
-
className: Rn.className,
|
|
6345
|
-
style: Rn.style
|
|
6346
|
-
}),
|
|
6347
|
-
zn && zn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
6359
|
+
zn && zn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
6348
6360
|
map: Ze,
|
|
6349
|
-
|
|
6350
|
-
unit: zn.unit,
|
|
6361
|
+
precision: zn.precision,
|
|
6351
6362
|
className: zn.className,
|
|
6352
6363
|
style: zn.style
|
|
6353
6364
|
}),
|
|
6354
|
-
|
|
6365
|
+
Bn && Bn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
6355
6366
|
map: Ze,
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6367
|
+
maxWidth: Bn.maxWidth,
|
|
6368
|
+
unit: Bn.unit,
|
|
6369
|
+
className: Bn.className,
|
|
6370
|
+
style: Bn.style
|
|
6359
6371
|
}),
|
|
6360
|
-
Hn && Hn.enabled !== !1 && /* @__PURE__ */ jsx(
|
|
6372
|
+
Hn && Hn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
6361
6373
|
map: Ze,
|
|
6362
|
-
|
|
6363
|
-
onChange: je,
|
|
6364
|
-
rasterPaintLayerIds: Un,
|
|
6374
|
+
entityConfig: O,
|
|
6365
6375
|
className: Hn.className,
|
|
6366
6376
|
style: Hn.style
|
|
6367
6377
|
}),
|
|
6368
|
-
|
|
6378
|
+
Un && Un.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
6379
|
+
map: Ze,
|
|
6380
|
+
value: T,
|
|
6381
|
+
onChange: Me,
|
|
6382
|
+
rasterPaintLayerIds: Wn,
|
|
6383
|
+
className: Un.className,
|
|
6384
|
+
style: Un.style
|
|
6385
|
+
}),
|
|
6386
|
+
Vn && Vn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
6369
6387
|
map: Ze,
|
|
6370
6388
|
initialCenter: l,
|
|
6371
6389
|
initialZoom: u,
|
|
6372
6390
|
initialPitch: d,
|
|
6373
6391
|
initialBearing: f,
|
|
6374
|
-
duration:
|
|
6375
|
-
className:
|
|
6376
|
-
style:
|
|
6392
|
+
duration: Vn.duration,
|
|
6393
|
+
className: Vn.className,
|
|
6394
|
+
style: Vn.style
|
|
6377
6395
|
})
|
|
6378
6396
|
]
|
|
6379
6397
|
}),
|
|
6380
|
-
|
|
6381
|
-
popupState:
|
|
6382
|
-
onClose: () =>
|
|
6398
|
+
R && We.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
6399
|
+
popupState: R,
|
|
6400
|
+
onClose: () => _t(R.entityId),
|
|
6383
6401
|
portalContainer: We.current,
|
|
6384
6402
|
popupRef: Ge
|
|
6385
6403
|
}),
|
|
6386
6404
|
qe && Ye.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
6387
6405
|
menuState: qe,
|
|
6388
|
-
onClose:
|
|
6406
|
+
onClose: _n,
|
|
6389
6407
|
portalContainer: Ye.current,
|
|
6390
6408
|
menuRef: Xe
|
|
6391
6409
|
})
|