bbl-mapbox-react 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +628 -628
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1781,8 +1781,8 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
1781
1781
|
if (d === 0) return Math.sqrt((r - a) * (r - a) + (i - o) * (i - o));
|
|
1782
1782
|
let f = ((r - a) * l + (i - o) * u) / d;
|
|
1783
1783
|
f = Math.max(0, Math.min(1, f));
|
|
1784
|
-
let p = a + f * l,
|
|
1785
|
-
return Math.sqrt((r - p) * (r - p) + (i -
|
|
1784
|
+
let p = a + f * l, m = o + f * u;
|
|
1785
|
+
return Math.sqrt((r - p) * (r - p) + (i - m) * (i - m));
|
|
1786
1786
|
}
|
|
1787
1787
|
update(t) {
|
|
1788
1788
|
let n = this.entity;
|
|
@@ -3932,8 +3932,8 @@ var RectangleRenderer = class e {
|
|
|
3932
3932
|
}
|
|
3933
3933
|
};
|
|
3934
3934
|
const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef: s }) => {
|
|
3935
|
-
let c = useRef(null), [l, u] = useState("entering"), [d, p] = useState(!1),
|
|
3936
|
-
|
|
3935
|
+
let c = useRef(null), [l, u] = useState("entering"), [d, p] = useState(!1), h = useRef(e.position), g = useRef(!1), _ = s || c;
|
|
3936
|
+
g.current || (h.current = e.position), useEffect(() => {
|
|
3937
3937
|
let e = setTimeout(() => {
|
|
3938
3938
|
p(!0);
|
|
3939
3939
|
}, 60);
|
|
@@ -3944,19 +3944,19 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
3944
3944
|
return () => clearTimeout(e);
|
|
3945
3945
|
}
|
|
3946
3946
|
}, [l, d]);
|
|
3947
|
-
let
|
|
3948
|
-
e.config.animation === "none" ? r() : (
|
|
3947
|
+
let v = useCallback(() => {
|
|
3948
|
+
e.config.animation === "none" ? r() : (g.current = !0, u("exiting"), setTimeout(() => r(), 200));
|
|
3949
3949
|
}, [e.config.animation, r]);
|
|
3950
3950
|
useEffect(() => {
|
|
3951
3951
|
if (!e.config.closeOnEscape) return;
|
|
3952
3952
|
let t = (e) => {
|
|
3953
|
-
e.key === "Escape" &&
|
|
3953
|
+
e.key === "Escape" && v();
|
|
3954
3954
|
};
|
|
3955
3955
|
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
3956
|
-
}, [e.config.closeOnEscape,
|
|
3956
|
+
}, [e.config.closeOnEscape, v]), useEffect(() => {
|
|
3957
3957
|
if (!e.config.closeOnClickOutside) return;
|
|
3958
3958
|
let t = (e) => {
|
|
3959
|
-
|
|
3959
|
+
_.current && !_.current.contains(e.target) && v();
|
|
3960
3960
|
}, n = setTimeout(() => {
|
|
3961
3961
|
document.addEventListener("click", t, !0);
|
|
3962
3962
|
}, 0);
|
|
@@ -3965,10 +3965,10 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
3965
3965
|
};
|
|
3966
3966
|
}, [
|
|
3967
3967
|
e.config.closeOnClickOutside,
|
|
3968
|
-
|
|
3969
|
-
|
|
3968
|
+
v,
|
|
3969
|
+
_
|
|
3970
3970
|
]);
|
|
3971
|
-
let
|
|
3971
|
+
let y = () => {
|
|
3972
3972
|
switch (e.actualPosition) {
|
|
3973
3973
|
case "top": return "center bottom";
|
|
3974
3974
|
case "bottom": return "center top";
|
|
@@ -3977,25 +3977,25 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
3977
3977
|
case "center":
|
|
3978
3978
|
default: return "center center";
|
|
3979
3979
|
}
|
|
3980
|
-
},
|
|
3981
|
-
ref:
|
|
3980
|
+
}, b = h.current, x = /* @__PURE__ */ jsxs("div", {
|
|
3981
|
+
ref: _,
|
|
3982
3982
|
className: `entity-popup ${d ? `entity-popup--${l} animation-${e.config.animation}` : ""} ${e.config.className || ""}`,
|
|
3983
3983
|
style: {
|
|
3984
3984
|
position: "fixed",
|
|
3985
|
-
left: `${
|
|
3986
|
-
top: `${
|
|
3985
|
+
left: `${b.x}px`,
|
|
3986
|
+
top: `${b.y}px`,
|
|
3987
3987
|
maxWidth: e.config.maxWidth,
|
|
3988
3988
|
zIndex: e.config.zIndex,
|
|
3989
3989
|
pointerEvents: "all",
|
|
3990
3990
|
opacity: d ? void 0 : 0,
|
|
3991
|
-
transformOrigin:
|
|
3991
|
+
transformOrigin: y(),
|
|
3992
3992
|
...e.config.style
|
|
3993
3993
|
},
|
|
3994
3994
|
role: "dialog",
|
|
3995
3995
|
"aria-modal": "true",
|
|
3996
3996
|
children: [e.config.showCloseButton && /* @__PURE__ */ jsx("button", {
|
|
3997
3997
|
className: "entity-popup__close",
|
|
3998
|
-
onClick:
|
|
3998
|
+
onClick: v,
|
|
3999
3999
|
"aria-label": "Close popup",
|
|
4000
4000
|
children: "×"
|
|
4001
4001
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -4003,24 +4003,24 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
4003
4003
|
children: e.config.content
|
|
4004
4004
|
})]
|
|
4005
4005
|
});
|
|
4006
|
-
return createPortal(
|
|
4006
|
+
return createPortal(x, i);
|
|
4007
4007
|
};
|
|
4008
4008
|
var location_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768373933818'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='30344'%20width='200'%20height='200'%3e%3cpath%20d='M400.440142%201024h-0.073136a48.781895%2048.781895%200%200%201-45.490763-31.448598L3.383306%2066.061072a48.781895%2048.781895%200%200%201%2062.897196-62.897197l926.563466%20351.419801a48.928168%2048.928168%200%200%201%200.219409%2091.127799L597.761811%20597.688654l-151.904042%20395.082157a48.781895%2048.781895%200%200%201-45.490763%2031.229189zM133.053921%20132.907627l267.678766%20705.691916%20113.87318-296.201913a48.855032%2048.855032%200%200%201%2028.011193-27.938057l296.201913-113.87318-705.765052-267.678766z'%20p-id='30345'%20fill='%23ffffff'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e";
|
|
4009
4009
|
function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style: s }) {
|
|
4010
|
-
let [c, l] = useState(null), [u, d] = useState(!1), f = useRef(void 0),
|
|
4010
|
+
let [c, l] = useState(null), [u, d] = useState(!1), f = useRef(void 0), h = useCallback((e) => {
|
|
4011
4011
|
l({
|
|
4012
4012
|
lng: Number(e.lngLat.lng.toFixed(r)),
|
|
4013
4013
|
lat: Number(e.lngLat.lat.toFixed(r))
|
|
4014
4014
|
});
|
|
4015
4015
|
}, [r]);
|
|
4016
4016
|
useEffect(() => {
|
|
4017
|
-
if (e) return e.on("mousemove",
|
|
4018
|
-
e.off("mousemove",
|
|
4017
|
+
if (e) return e.on("mousemove", h), () => {
|
|
4018
|
+
e.off("mousemove", h);
|
|
4019
4019
|
};
|
|
4020
|
-
}, [e,
|
|
4020
|
+
}, [e, h]), useEffect(() => () => {
|
|
4021
4021
|
f.current && clearTimeout(f.current);
|
|
4022
4022
|
}, []);
|
|
4023
|
-
let
|
|
4023
|
+
let g = useCallback(() => {
|
|
4024
4024
|
if (!c) return;
|
|
4025
4025
|
let e = `${c.lng},${c.lat}`;
|
|
4026
4026
|
navigator.clipboard.writeText(e).then(() => {
|
|
@@ -4030,7 +4030,7 @@ function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style:
|
|
|
4030
4030
|
return c ? /* @__PURE__ */ jsxs("div", {
|
|
4031
4031
|
className: `mapbox-coordinate-display ${u ? "mapbox-coordinate-display--copied" : ""} ${i}`,
|
|
4032
4032
|
style: s,
|
|
4033
|
-
onClick:
|
|
4033
|
+
onClick: g,
|
|
4034
4034
|
title: "点击复制坐标",
|
|
4035
4035
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4036
4036
|
src: location_default,
|
|
@@ -4058,46 +4058,46 @@ function ScaleControl({ map: e, maxWidth: r = 100, unit: i = "metric", className
|
|
|
4058
4058
|
label: "100 m"
|
|
4059
4059
|
}), u = useCallback(() => {
|
|
4060
4060
|
if (!e) return;
|
|
4061
|
-
let t = e.
|
|
4061
|
+
let t = e.getCanvas().clientHeight / 2, n = e.unproject([0, t]), a = e.unproject([r, t]), o = n.lat * Math.PI / 180, s = a.lat * Math.PI / 180, c = s - o, u = (a.lng - n.lng) * Math.PI / 180, d = Math.sin(c / 2) * Math.sin(c / 2) + Math.cos(o) * Math.cos(s) * Math.sin(u / 2) * Math.sin(u / 2), f = 6371008.8 * (2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d))), p, m;
|
|
4062
4062
|
if (i === "imperial") {
|
|
4063
|
-
let e = 3.2808 *
|
|
4063
|
+
let e = 3.2808 * f;
|
|
4064
4064
|
if (e > 5280) {
|
|
4065
4065
|
let t = e / 5280;
|
|
4066
|
-
|
|
4067
|
-
let n =
|
|
4066
|
+
p = getRoundNum(t), m = `${p} mi`;
|
|
4067
|
+
let n = p / t;
|
|
4068
4068
|
l({
|
|
4069
4069
|
width: r * n,
|
|
4070
|
-
label:
|
|
4070
|
+
label: m
|
|
4071
4071
|
});
|
|
4072
4072
|
} else {
|
|
4073
|
-
|
|
4074
|
-
let t =
|
|
4073
|
+
p = getRoundNum(e), m = `${p} ft`;
|
|
4074
|
+
let t = p / e;
|
|
4075
4075
|
l({
|
|
4076
4076
|
width: r * t,
|
|
4077
|
-
label:
|
|
4077
|
+
label: m
|
|
4078
4078
|
});
|
|
4079
4079
|
}
|
|
4080
4080
|
} else if (i === "nautical") {
|
|
4081
|
-
let e =
|
|
4082
|
-
|
|
4083
|
-
let t =
|
|
4081
|
+
let e = f / 1852;
|
|
4082
|
+
p = getRoundNum(e), m = `${p} nm`;
|
|
4083
|
+
let t = p / e;
|
|
4084
4084
|
l({
|
|
4085
4085
|
width: r * t,
|
|
4086
|
-
label:
|
|
4086
|
+
label: m
|
|
4087
4087
|
});
|
|
4088
|
-
} else if (
|
|
4089
|
-
|
|
4090
|
-
let e =
|
|
4088
|
+
} else if (f >= 1e3) {
|
|
4089
|
+
p = getRoundNum(f / 1e3), m = `${p} km`;
|
|
4090
|
+
let e = p / (f / 1e3);
|
|
4091
4091
|
l({
|
|
4092
4092
|
width: r * e,
|
|
4093
|
-
label:
|
|
4093
|
+
label: m
|
|
4094
4094
|
});
|
|
4095
4095
|
} else {
|
|
4096
|
-
|
|
4097
|
-
let e =
|
|
4096
|
+
p = getRoundNum(f), m = `${p} m`;
|
|
4097
|
+
let e = p / f;
|
|
4098
4098
|
l({
|
|
4099
4099
|
width: r * e,
|
|
4100
|
-
label:
|
|
4100
|
+
label: m
|
|
4101
4101
|
});
|
|
4102
4102
|
}
|
|
4103
4103
|
}, [
|
|
@@ -4183,7 +4183,7 @@ function detectVectorSource(e) {
|
|
|
4183
4183
|
return null;
|
|
4184
4184
|
}
|
|
4185
4185
|
function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u, classField: d = "class", className: f = "", style: p }) {
|
|
4186
|
-
let [
|
|
4186
|
+
let [g, _] = useState(!1), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(!1), ye = useRef(null), C = useRef(null), w = useRef(null), T = useCallback((e, t, n) => {
|
|
4187
4187
|
if (!e.isStyleLoaded() || !e.getSource(t)) return !1;
|
|
4188
4188
|
let i = !0;
|
|
4189
4189
|
return ROAD_TYPE_OPTIONS.forEach((a) => {
|
|
@@ -4219,13 +4219,13 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4219
4219
|
let r = detectVectorSource(e);
|
|
4220
4220
|
r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
|
|
4221
4221
|
}
|
|
4222
|
-
t && n ?
|
|
4222
|
+
t && n ? T(e, t, n) && (S.current = !0, x(!0)) : console.warn("No vector source found for road highlighting");
|
|
4223
4223
|
};
|
|
4224
4224
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4225
4225
|
let n = () => {
|
|
4226
4226
|
e.isStyleLoaded() && t();
|
|
4227
4227
|
}, r = () => {
|
|
4228
|
-
|
|
4228
|
+
S.current || t();
|
|
4229
4229
|
};
|
|
4230
4230
|
return e.on("styledata", n), e.on("sourcedata", r), () => {
|
|
4231
4231
|
e.off("styledata", n), e.off("sourcedata", r);
|
|
@@ -4234,12 +4234,12 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4234
4234
|
e,
|
|
4235
4235
|
l,
|
|
4236
4236
|
u,
|
|
4237
|
-
|
|
4237
|
+
T
|
|
4238
4238
|
]), useEffect(() => {
|
|
4239
|
-
!e || !
|
|
4239
|
+
!e || !b || ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
4240
4240
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
4241
4241
|
if (e.getLayer(n)) try {
|
|
4242
|
-
let r =
|
|
4242
|
+
let r = v.includes(t.class);
|
|
4243
4243
|
e.setLayoutProperty(n, "visibility", r ? "visible" : "none");
|
|
4244
4244
|
} catch (e) {
|
|
4245
4245
|
console.error(`Failed to update layer ${n}:`, e);
|
|
@@ -4247,128 +4247,128 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4247
4247
|
});
|
|
4248
4248
|
}, [
|
|
4249
4249
|
e,
|
|
4250
|
-
|
|
4251
|
-
|
|
4250
|
+
b,
|
|
4251
|
+
v
|
|
4252
4252
|
]), useEffect(() => {
|
|
4253
|
-
if (!
|
|
4253
|
+
if (!g) return;
|
|
4254
4254
|
let e = (e) => {
|
|
4255
|
-
|
|
4255
|
+
ye.current && !ye.current.contains(e.target) && C.current && !C.current.contains(e.target) && _(!1);
|
|
4256
4256
|
}, t = setTimeout(() => {
|
|
4257
4257
|
document.addEventListener("mousedown", e);
|
|
4258
4258
|
}, 0);
|
|
4259
4259
|
return () => {
|
|
4260
4260
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
4261
4261
|
};
|
|
4262
|
-
}, [
|
|
4262
|
+
}, [g]), useEffect(() => () => {
|
|
4263
4263
|
e && e.getStyle() && ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
4264
4264
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
4265
4265
|
if (e.getLayer(n)) try {
|
|
4266
4266
|
e.removeLayer(n);
|
|
4267
4267
|
} catch {}
|
|
4268
|
-
}),
|
|
4268
|
+
}), w.current &&= (w.current.remove(), null);
|
|
4269
4269
|
}, [e]);
|
|
4270
|
-
let
|
|
4271
|
-
if (!e ||
|
|
4272
|
-
|
|
4270
|
+
let E = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), be = useCallback((t) => {
|
|
4271
|
+
if (!e || v.length === 0) {
|
|
4272
|
+
w.current && w.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
|
|
4273
4273
|
return;
|
|
4274
4274
|
}
|
|
4275
|
-
let n =
|
|
4275
|
+
let n = v.map((e) => `${LAYER_ID_PREFIX}${e}`), r = [[t.point.x - 10, t.point.y - 10], [t.point.x + 10, t.point.y + 10]], i = e.queryRenderedFeatures(r, { layers: n.filter((t) => e.getLayer(t)) });
|
|
4276
4276
|
if (i.length > 0) {
|
|
4277
|
-
let n = i[0].properties || {}, r = t.lngLat, a = n.name || n.name_en || n.name_local || "", o = n[d] || "", c = n.type || "", l = n.structure || "", u = n.oneway, f = n.layer, p = n.iso_3166_1 || "",
|
|
4278
|
-
|
|
4277
|
+
let n = i[0].properties || {}, r = t.lngLat, a = n.name || n.name_en || n.name_local || "", o = n[d] || "", c = n.type || "", l = n.structure || "", u = n.oneway, f = n.layer, p = n.iso_3166_1 || "", m = n.iso_3166_2 || "", ve = (e) => !(e == null || e === "" || typeof e == "string" && e.toLowerCase() === "none"), h = [];
|
|
4278
|
+
ve(o) && h.push(`
|
|
4279
4279
|
<div class="road-highlight-popup__row">
|
|
4280
4280
|
<span>道路类型:</span>
|
|
4281
|
-
<span class="road-highlight-popup__value">${
|
|
4281
|
+
<span class="road-highlight-popup__value">${E(o)}</span>
|
|
4282
4282
|
</div>
|
|
4283
|
-
`),
|
|
4283
|
+
`), h.push(`
|
|
4284
4284
|
<div class="road-highlight-popup__row">
|
|
4285
4285
|
<span>经度:</span>
|
|
4286
4286
|
<span class="road-highlight-popup__value">${r.lng.toFixed(6)}</span>
|
|
4287
4287
|
</div>
|
|
4288
|
-
`),
|
|
4288
|
+
`), h.push(`
|
|
4289
4289
|
<div class="road-highlight-popup__row">
|
|
4290
4290
|
<span>纬度:</span>
|
|
4291
4291
|
<span class="road-highlight-popup__value">${r.lat.toFixed(6)}</span>
|
|
4292
4292
|
</div>
|
|
4293
|
-
`),
|
|
4293
|
+
`), ve(c) && h.push(`
|
|
4294
4294
|
<div class="road-highlight-popup__row">
|
|
4295
4295
|
<span>类别:</span>
|
|
4296
4296
|
<span class="road-highlight-popup__value">${c}</span>
|
|
4297
4297
|
</div>
|
|
4298
|
-
`),
|
|
4298
|
+
`), ve(l) && h.push(`
|
|
4299
4299
|
<div class="road-highlight-popup__row">
|
|
4300
4300
|
<span>结构:</span>
|
|
4301
4301
|
<span class="road-highlight-popup__value">${l}</span>
|
|
4302
4302
|
</div>
|
|
4303
|
-
`), u != null && u !== "" &&
|
|
4303
|
+
`), u != null && u !== "" && h.push(`
|
|
4304
4304
|
<div class="road-highlight-popup__row">
|
|
4305
4305
|
<span>单行道:</span>
|
|
4306
4306
|
<span class="road-highlight-popup__value">${u ? "是" : "否"}</span>
|
|
4307
4307
|
</div>
|
|
4308
|
-
`),
|
|
4308
|
+
`), ve(f) && h.push(`
|
|
4309
4309
|
<div class="road-highlight-popup__row">
|
|
4310
4310
|
<span>层级:</span>
|
|
4311
4311
|
<span class="road-highlight-popup__value">${f}</span>
|
|
4312
4312
|
</div>
|
|
4313
|
-
`),
|
|
4313
|
+
`), ve(p) && h.push(`
|
|
4314
4314
|
<div class="road-highlight-popup__row">
|
|
4315
4315
|
<span>国家代码:</span>
|
|
4316
4316
|
<span class="road-highlight-popup__value">${p}</span>
|
|
4317
4317
|
</div>
|
|
4318
|
-
`),
|
|
4318
|
+
`), ve(m) && h.push(`
|
|
4319
4319
|
<div class="road-highlight-popup__row">
|
|
4320
4320
|
<span>地区代码:</span>
|
|
4321
|
-
<span class="road-highlight-popup__value">${
|
|
4321
|
+
<span class="road-highlight-popup__value">${m}</span>
|
|
4322
4322
|
</div>
|
|
4323
4323
|
`);
|
|
4324
|
-
let
|
|
4324
|
+
let g = `
|
|
4325
4325
|
<div class="road-highlight-popup__content">
|
|
4326
4326
|
${a ? `<div class="road-highlight-popup__title">${a}</div>` : ""}
|
|
4327
|
-
<div class="road-highlight-popup__info">${
|
|
4327
|
+
<div class="road-highlight-popup__info">${h.join("")}</div>
|
|
4328
4328
|
</div>
|
|
4329
4329
|
`;
|
|
4330
|
-
|
|
4330
|
+
w.current ||= new mapboxgl.Popup({
|
|
4331
4331
|
closeButton: !1,
|
|
4332
4332
|
closeOnClick: !1,
|
|
4333
4333
|
offset: 15,
|
|
4334
4334
|
className: "road-highlight-popup"
|
|
4335
|
-
}),
|
|
4336
|
-
} else
|
|
4335
|
+
}), w.current.setLngLat(r).setHTML(g).addTo(e), e.getCanvas().style.cursor = "pointer";
|
|
4336
|
+
} else w.current && w.current.remove(), e.getCanvas().style.cursor = "";
|
|
4337
4337
|
}, [
|
|
4338
4338
|
e,
|
|
4339
|
-
|
|
4340
|
-
|
|
4339
|
+
v,
|
|
4340
|
+
E,
|
|
4341
4341
|
d
|
|
4342
4342
|
]);
|
|
4343
4343
|
useEffect(() => {
|
|
4344
|
-
if (!(!e || !
|
|
4345
|
-
e.off("mousemove",
|
|
4344
|
+
if (!(!e || !b)) return e.on("mousemove", be), () => {
|
|
4345
|
+
e.off("mousemove", be), w.current && w.current.remove(), e.getCanvas().style.cursor = "";
|
|
4346
4346
|
};
|
|
4347
4347
|
}, [
|
|
4348
4348
|
e,
|
|
4349
|
-
|
|
4350
|
-
|
|
4349
|
+
b,
|
|
4350
|
+
be
|
|
4351
4351
|
]);
|
|
4352
|
-
let
|
|
4353
|
-
|
|
4354
|
-
},
|
|
4355
|
-
|
|
4356
|
-
},
|
|
4352
|
+
let xe = (e, t) => {
|
|
4353
|
+
y((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
4354
|
+
}, O = (e) => {
|
|
4355
|
+
y(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
|
|
4356
|
+
}, Se = v.length > 0;
|
|
4357
4357
|
return /* @__PURE__ */ jsxs("div", {
|
|
4358
4358
|
className: `mapbox-road-highlight-control ${f}`,
|
|
4359
4359
|
style: p,
|
|
4360
4360
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
4361
|
-
ref:
|
|
4362
|
-
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${
|
|
4363
|
-
onClick: () =>
|
|
4364
|
-
title: `路网高亮${
|
|
4361
|
+
ref: C,
|
|
4362
|
+
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${Se ? "mapbox-road-highlight-control__btn--active" : ""}`,
|
|
4363
|
+
onClick: () => _(!g),
|
|
4364
|
+
title: `路网高亮${v.length > 0 ? ` (已选 ${v.length})` : ""}`,
|
|
4365
4365
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4366
4366
|
src: road_default,
|
|
4367
4367
|
alt: "road",
|
|
4368
4368
|
className: "mapbox-road-highlight-control__btn-icon"
|
|
4369
|
-
}), /* @__PURE__ */ jsxs("span", { children: ["路网",
|
|
4370
|
-
}),
|
|
4371
|
-
ref:
|
|
4369
|
+
}), /* @__PURE__ */ jsxs("span", { children: ["路网", v.length > 0 ? ` (${v.length})` : ""] })]
|
|
4370
|
+
}), g && /* @__PURE__ */ jsxs("div", {
|
|
4371
|
+
ref: ye,
|
|
4372
4372
|
className: "mapbox-road-highlight-control__panel",
|
|
4373
4373
|
children: [
|
|
4374
4374
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -4377,9 +4377,9 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4377
4377
|
className: "mapbox-road-highlight-control__panel-title",
|
|
4378
4378
|
children: "道路类型"
|
|
4379
4379
|
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
4380
|
-
checked:
|
|
4381
|
-
indeterminate:
|
|
4382
|
-
onChange:
|
|
4380
|
+
checked: v.length === ROAD_TYPE_OPTIONS.length,
|
|
4381
|
+
indeterminate: v.length > 0 && v.length < ROAD_TYPE_OPTIONS.length,
|
|
4382
|
+
onChange: O,
|
|
4383
4383
|
style: {
|
|
4384
4384
|
"--color-text-1": "#fff",
|
|
4385
4385
|
"--color-border-2": "rgba(255, 255, 255, 0.3)"
|
|
@@ -4396,11 +4396,11 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4396
4396
|
className: "mapbox-road-highlight-control__type-list",
|
|
4397
4397
|
children: ROAD_TYPE_OPTIONS.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
4398
4398
|
className: "mapbox-road-highlight-control__type-item",
|
|
4399
|
-
onClick: () =>
|
|
4399
|
+
onClick: () => xe(e.class, !v.includes(e.class)),
|
|
4400
4400
|
children: [
|
|
4401
4401
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4402
|
-
checked:
|
|
4403
|
-
onChange: (t) =>
|
|
4402
|
+
checked: v.includes(e.class),
|
|
4403
|
+
onChange: (t) => xe(e.class, t),
|
|
4404
4404
|
onClick: (e) => e.stopPropagation(),
|
|
4405
4405
|
style: {
|
|
4406
4406
|
"--color-text-1": "#fff",
|
|
@@ -4425,7 +4425,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4425
4425
|
className: "mapbox-road-highlight-control__tip",
|
|
4426
4426
|
children: "💡 选中道路类型后立即显示高亮"
|
|
4427
4427
|
}),
|
|
4428
|
-
!
|
|
4428
|
+
!b && /* @__PURE__ */ jsx("div", {
|
|
4429
4429
|
className: "mapbox-road-highlight-control__warning",
|
|
4430
4430
|
children: "⚠️ 正在初始化图层..."
|
|
4431
4431
|
})
|
|
@@ -4674,64 +4674,64 @@ function clearAllPreviewSources(e) {
|
|
|
4674
4674
|
]) clearPreviewSource(e, `${PREVIEW_PREFIX}${t}`);
|
|
4675
4675
|
}
|
|
4676
4676
|
function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDrawModeChange: s, className: c = "", style: l }) {
|
|
4677
|
-
let [u, d] = useState(!1), [f, p] = useState(null), [
|
|
4677
|
+
let [u, d] = useState(!1), [f, p] = useState(null), [g, _] = useState({
|
|
4678
4678
|
showArea: !0,
|
|
4679
4679
|
showLength: !0,
|
|
4680
4680
|
showRadius: !0
|
|
4681
|
-
}),
|
|
4681
|
+
}), v = r !== void 0, y = v ? {
|
|
4682
4682
|
showArea: r.showArea ?? !0,
|
|
4683
4683
|
showLength: r.showLength ?? !0,
|
|
4684
4684
|
showRadius: r.showRadius ?? !0
|
|
4685
|
-
} :
|
|
4686
|
-
|
|
4687
|
-
let
|
|
4688
|
-
|
|
4689
|
-
let
|
|
4685
|
+
} : g, [b, x] = useState([]), S = useRef(/* @__PURE__ */ new Map()), ye = useRef(0), w = useRef(null), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef([]), A = useRef([]), j = useRef(y);
|
|
4686
|
+
j.current = y;
|
|
4687
|
+
let Te = useRef(f);
|
|
4688
|
+
Te.current = f;
|
|
4689
|
+
let M = useCallback(() => `measure-${++ye.current}`, []);
|
|
4690
4690
|
useEffect(() => {
|
|
4691
4691
|
s?.(f !== null);
|
|
4692
4692
|
}, [f, s]);
|
|
4693
|
-
let
|
|
4694
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
4693
|
+
let Ee = useRef(!1), De = useCallback(() => {
|
|
4694
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), Ee.current = !0);
|
|
4695
4695
|
}, [e]);
|
|
4696
4696
|
useEffect(() => {
|
|
4697
4697
|
if (!e) return;
|
|
4698
4698
|
let t = () => {
|
|
4699
|
-
initAllPreviewLayers(e),
|
|
4699
|
+
initAllPreviewLayers(e), Ee.current = !0;
|
|
4700
4700
|
};
|
|
4701
4701
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4702
4702
|
let n = () => {
|
|
4703
|
-
|
|
4703
|
+
Ee.current = !1;
|
|
4704
4704
|
};
|
|
4705
4705
|
return e.on("style.load", n), () => {
|
|
4706
4706
|
e.off("style.load", n);
|
|
4707
4707
|
};
|
|
4708
4708
|
}, [e]), useEffect(() => {
|
|
4709
4709
|
let e = (e) => {
|
|
4710
|
-
|
|
4710
|
+
w.current && !w.current.contains(e.target) && T.current && !T.current.contains(e.target) && d(!1);
|
|
4711
4711
|
};
|
|
4712
4712
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4713
4713
|
}, []);
|
|
4714
|
-
let
|
|
4714
|
+
let N = useCallback((t) => {
|
|
4715
4715
|
if (!e) return;
|
|
4716
|
-
let n = applyEntityConfig(t,
|
|
4716
|
+
let n = applyEntityConfig(t, j.current), r = null;
|
|
4717
4717
|
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) {
|
|
4718
|
-
|
|
4718
|
+
S.current.set(n.id, r);
|
|
4719
4719
|
let e = {
|
|
4720
4720
|
entity: n,
|
|
4721
4721
|
shapeLabel: SHAPE_LABELS[n.type] || n.type,
|
|
4722
4722
|
area: computeEntityArea(n),
|
|
4723
4723
|
lengthOrRadius: computeEntityLengthOrRadius(n)
|
|
4724
4724
|
};
|
|
4725
|
-
|
|
4726
|
-
}
|
|
4727
|
-
}, [e]),
|
|
4728
|
-
let t =
|
|
4729
|
-
t && (t.destroy(),
|
|
4730
|
-
}, []),
|
|
4731
|
-
|
|
4732
|
-
}, []),
|
|
4725
|
+
x((t) => [...t, e]);
|
|
4726
|
+
}
|
|
4727
|
+
}, [e]), Oe = useCallback((e) => {
|
|
4728
|
+
let t = S.current.get(e);
|
|
4729
|
+
t && (t.destroy(), S.current.delete(e)), x((t) => t.filter((t) => t.entity.id !== e));
|
|
4730
|
+
}, []), ke = useCallback(() => {
|
|
4731
|
+
S.current.forEach((e) => e.destroy()), S.current.clear(), x([]);
|
|
4732
|
+
}, []), Ae = useCallback((t) => {
|
|
4733
4733
|
if (!e) return;
|
|
4734
|
-
let n =
|
|
4734
|
+
let n = S.current.get(t);
|
|
4735
4735
|
if (!n) return;
|
|
4736
4736
|
let r = n.getBounds();
|
|
4737
4737
|
e.fitBounds(r, {
|
|
@@ -4739,21 +4739,21 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4739
4739
|
maxZoom: 18,
|
|
4740
4740
|
duration: 1e3
|
|
4741
4741
|
});
|
|
4742
|
-
}, [e]),
|
|
4742
|
+
}, [e]), je = useCallback((e, t) => {
|
|
4743
4743
|
let n = {
|
|
4744
|
-
...
|
|
4744
|
+
...j.current,
|
|
4745
4745
|
[e]: t
|
|
4746
4746
|
};
|
|
4747
|
-
|
|
4747
|
+
v ? i?.({ ...n }) : _(n), x((t) => t.map((t) => {
|
|
4748
4748
|
let r = { ...t.entity };
|
|
4749
4749
|
r[e] = void 0;
|
|
4750
|
-
let i = applyEntityConfig(r, n), a =
|
|
4750
|
+
let i = applyEntityConfig(r, n), a = S.current.get(t.entity.id);
|
|
4751
4751
|
return a && a.update(i), {
|
|
4752
4752
|
...t,
|
|
4753
4753
|
entity: i
|
|
4754
4754
|
};
|
|
4755
4755
|
}));
|
|
4756
|
-
}, [
|
|
4756
|
+
}, [v, i]), Me = useCallback((t, n) => {
|
|
4757
4757
|
if (!e) return;
|
|
4758
4758
|
let [r, i] = t, [a, o] = n, s = [
|
|
4759
4759
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -4772,7 +4772,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4772
4772
|
});
|
|
4773
4773
|
let l = e.getSource(`${PREVIEW_PREFIX}rect-preview-measure-source`);
|
|
4774
4774
|
if (l) {
|
|
4775
|
-
let e =
|
|
4775
|
+
let e = j.current, t = [], n = s[0], r = s[1], i = s[2];
|
|
4776
4776
|
if (e?.showArea) {
|
|
4777
4777
|
let e = distance(n, r), a = distance(r, i);
|
|
4778
4778
|
t.push({
|
|
@@ -4803,7 +4803,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4803
4803
|
features: t
|
|
4804
4804
|
});
|
|
4805
4805
|
}
|
|
4806
|
-
}, [e]),
|
|
4806
|
+
}, [e]), Ne = useCallback((t, n) => {
|
|
4807
4807
|
if (!e) return;
|
|
4808
4808
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
4809
4809
|
a && a.setData({
|
|
@@ -4814,7 +4814,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4814
4814
|
},
|
|
4815
4815
|
properties: {}
|
|
4816
4816
|
});
|
|
4817
|
-
let o =
|
|
4817
|
+
let o = j.current, s = [], c = [];
|
|
4818
4818
|
if (o?.showArea && s.push({
|
|
4819
4819
|
type: "Feature",
|
|
4820
4820
|
geometry: {
|
|
@@ -4850,7 +4850,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4850
4850
|
type: "FeatureCollection",
|
|
4851
4851
|
features: c
|
|
4852
4852
|
});
|
|
4853
|
-
}, [e]),
|
|
4853
|
+
}, [e]), Pe = useCallback((t, n) => {
|
|
4854
4854
|
if (!e) return;
|
|
4855
4855
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
4856
4856
|
a && a.setData({
|
|
@@ -4863,7 +4863,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4863
4863
|
});
|
|
4864
4864
|
let o = e.getSource(`${PREVIEW_PREFIX}square-preview-measure-source`);
|
|
4865
4865
|
if (o) {
|
|
4866
|
-
let e =
|
|
4866
|
+
let e = j.current, n = [];
|
|
4867
4867
|
if (e?.showArea && n.push({
|
|
4868
4868
|
type: "Feature",
|
|
4869
4869
|
geometry: {
|
|
@@ -4887,7 +4887,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4887
4887
|
features: n
|
|
4888
4888
|
});
|
|
4889
4889
|
}
|
|
4890
|
-
}, [e]),
|
|
4890
|
+
}, [e]), P = useCallback((t, n) => {
|
|
4891
4891
|
if (!e) return;
|
|
4892
4892
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
4893
4893
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -4922,7 +4922,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4922
4922
|
});
|
|
4923
4923
|
let o = e.getSource(`${PREVIEW_PREFIX}polygon-preview-measure-source`);
|
|
4924
4924
|
if (o) {
|
|
4925
|
-
let e =
|
|
4925
|
+
let e = j.current, t = [];
|
|
4926
4926
|
if (e?.showArea && r.length >= 3) {
|
|
4927
4927
|
let e = polygonArea([...r, r[0]]), n = 0, i = 0;
|
|
4928
4928
|
for (let e of r) n += e[0], i += e[1];
|
|
@@ -4964,7 +4964,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4964
4964
|
features: t
|
|
4965
4965
|
});
|
|
4966
4966
|
}
|
|
4967
|
-
}, [e]),
|
|
4967
|
+
}, [e]), Fe = useCallback((t, n) => {
|
|
4968
4968
|
if (!e) return;
|
|
4969
4969
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
4970
4970
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -4992,7 +4992,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4992
4992
|
});
|
|
4993
4993
|
let o = e.getSource(`${PREVIEW_PREFIX}polyline-preview-measure-source`);
|
|
4994
4994
|
if (o) {
|
|
4995
|
-
let e =
|
|
4995
|
+
let e = j.current, t = [];
|
|
4996
4996
|
if (e?.showLength && r.length >= 2) for (let e = 0; e < r.length - 1; e++) {
|
|
4997
4997
|
let n = r[e], i = r[e + 1];
|
|
4998
4998
|
t.push({
|
|
@@ -5012,117 +5012,117 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5012
5012
|
}, [e]);
|
|
5013
5013
|
useEffect(() => {
|
|
5014
5014
|
if (!e || !f) return;
|
|
5015
|
-
|
|
5015
|
+
De(), e.getCanvas().style.cursor = "crosshair";
|
|
5016
5016
|
let t = (t) => {
|
|
5017
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
5017
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = Te.current;
|
|
5018
5018
|
if (r === "rectangle") {
|
|
5019
|
-
let t =
|
|
5020
|
-
if (!t)
|
|
5019
|
+
let t = E.current;
|
|
5020
|
+
if (!t) E.current = n;
|
|
5021
5021
|
else {
|
|
5022
5022
|
let r = {
|
|
5023
|
-
id:
|
|
5023
|
+
id: M(),
|
|
5024
5024
|
type: "rectangle",
|
|
5025
5025
|
bounds: [t, n]
|
|
5026
5026
|
};
|
|
5027
|
-
|
|
5027
|
+
N(r), E.current = null, clearAllPreviewSources(e), p(null);
|
|
5028
5028
|
}
|
|
5029
5029
|
} else if (r === "circle") {
|
|
5030
|
-
let t =
|
|
5031
|
-
if (!t)
|
|
5030
|
+
let t = D.current;
|
|
5031
|
+
if (!t) D.current = { center: n };
|
|
5032
5032
|
else {
|
|
5033
5033
|
let r = calculateDistance(t.center, n), i = {
|
|
5034
|
-
id:
|
|
5034
|
+
id: M(),
|
|
5035
5035
|
type: "circle",
|
|
5036
5036
|
center: t.center,
|
|
5037
5037
|
radius: r
|
|
5038
5038
|
};
|
|
5039
|
-
|
|
5039
|
+
N(i), D.current = null, clearAllPreviewSources(e), p(null);
|
|
5040
5040
|
}
|
|
5041
5041
|
} else if (r === "square") {
|
|
5042
|
-
let t =
|
|
5043
|
-
if (!t)
|
|
5042
|
+
let t = O.current;
|
|
5043
|
+
if (!t) O.current = { center: n };
|
|
5044
5044
|
else {
|
|
5045
5045
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
5046
|
-
id:
|
|
5046
|
+
id: M(),
|
|
5047
5047
|
type: "square",
|
|
5048
5048
|
center: t.center,
|
|
5049
5049
|
length: r
|
|
5050
5050
|
};
|
|
5051
|
-
|
|
5051
|
+
N(i), O.current = null, clearAllPreviewSources(e), p(null);
|
|
5052
5052
|
}
|
|
5053
5053
|
} else if (r === "polygon") {
|
|
5054
|
-
let t =
|
|
5054
|
+
let t = k.current;
|
|
5055
5055
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
5056
5056
|
let n = {
|
|
5057
|
-
id:
|
|
5057
|
+
id: M(),
|
|
5058
5058
|
type: "polygon",
|
|
5059
5059
|
coordinates: [...t]
|
|
5060
5060
|
};
|
|
5061
|
-
|
|
5061
|
+
N(n), k.current = [], clearAllPreviewSources(e), p(null);
|
|
5062
5062
|
return;
|
|
5063
5063
|
}
|
|
5064
|
-
|
|
5065
|
-
} else r === "polyline" && (
|
|
5064
|
+
k.current = [...t, n];
|
|
5065
|
+
} else r === "polyline" && (A.current = [...A.current, n]);
|
|
5066
5066
|
}, n = (e) => {
|
|
5067
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5068
|
-
if (n === "rectangle" &&
|
|
5069
|
-
else if (n === "circle" &&
|
|
5070
|
-
else if (n === "square" &&
|
|
5067
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = Te.current;
|
|
5068
|
+
if (n === "rectangle" && E.current) Me(E.current, t);
|
|
5069
|
+
else if (n === "circle" && D.current) Ne(D.current.center, t);
|
|
5070
|
+
else if (n === "square" && O.current) Pe(O.current.center, t);
|
|
5071
5071
|
else if (n === "polygon") {
|
|
5072
|
-
let e = O.current;
|
|
5073
|
-
e.length > 0 && N(e, t);
|
|
5074
|
-
} else if (n === "polyline") {
|
|
5075
5072
|
let e = k.current;
|
|
5076
|
-
e.length > 0 &&
|
|
5073
|
+
e.length > 0 && P(e, t);
|
|
5074
|
+
} else if (n === "polyline") {
|
|
5075
|
+
let e = A.current;
|
|
5076
|
+
e.length > 0 && Fe(e, t);
|
|
5077
5077
|
}
|
|
5078
5078
|
}, r = (t) => {
|
|
5079
5079
|
t.preventDefault();
|
|
5080
|
-
let n =
|
|
5080
|
+
let n = Te.current;
|
|
5081
5081
|
if (n === "polygon") {
|
|
5082
|
-
let t =
|
|
5082
|
+
let t = k.current;
|
|
5083
5083
|
if (t.length >= 3) {
|
|
5084
5084
|
let n = {
|
|
5085
|
-
id:
|
|
5085
|
+
id: M(),
|
|
5086
5086
|
type: "polygon",
|
|
5087
5087
|
coordinates: [...t]
|
|
5088
5088
|
};
|
|
5089
|
-
|
|
5090
|
-
} else
|
|
5089
|
+
N(n), k.current = [], clearAllPreviewSources(e), p(null);
|
|
5090
|
+
} else k.current = [], clearAllPreviewSources(e);
|
|
5091
5091
|
} else if (n === "polyline") {
|
|
5092
|
-
let t =
|
|
5092
|
+
let t = A.current;
|
|
5093
5093
|
if (t.length >= 2) {
|
|
5094
5094
|
let n = {
|
|
5095
|
-
id:
|
|
5095
|
+
id: M(),
|
|
5096
5096
|
type: "polyline",
|
|
5097
5097
|
coordinates: [...t]
|
|
5098
5098
|
};
|
|
5099
|
-
|
|
5100
|
-
} else
|
|
5099
|
+
N(n), A.current = [], clearAllPreviewSources(e), p(null);
|
|
5100
|
+
} else A.current = [], clearAllPreviewSources(e);
|
|
5101
5101
|
}
|
|
5102
5102
|
}, i = (t) => {
|
|
5103
|
-
t.key === "Escape" && (
|
|
5103
|
+
t.key === "Escape" && (E.current = null, D.current = null, O.current = null, k.current = [], A.current = [], clearAllPreviewSources(e), p(null));
|
|
5104
5104
|
}, a = (t) => {
|
|
5105
5105
|
t.preventDefault();
|
|
5106
|
-
let n =
|
|
5106
|
+
let n = Te.current;
|
|
5107
5107
|
if (n === "polygon") {
|
|
5108
|
-
let t =
|
|
5108
|
+
let t = k.current;
|
|
5109
5109
|
if (t.length >= 3) {
|
|
5110
5110
|
let n = {
|
|
5111
|
-
id:
|
|
5111
|
+
id: M(),
|
|
5112
5112
|
type: "polygon",
|
|
5113
5113
|
coordinates: [...t]
|
|
5114
5114
|
};
|
|
5115
|
-
|
|
5115
|
+
N(n), k.current = [], clearAllPreviewSources(e), p(null);
|
|
5116
5116
|
}
|
|
5117
5117
|
} else if (n === "polyline") {
|
|
5118
|
-
let t =
|
|
5118
|
+
let t = A.current;
|
|
5119
5119
|
if (t.length >= 2) {
|
|
5120
5120
|
let n = {
|
|
5121
|
-
id:
|
|
5121
|
+
id: M(),
|
|
5122
5122
|
type: "polyline",
|
|
5123
5123
|
coordinates: [...t]
|
|
5124
5124
|
};
|
|
5125
|
-
|
|
5125
|
+
N(n), A.current = [], clearAllPreviewSources(e), p(null);
|
|
5126
5126
|
}
|
|
5127
5127
|
}
|
|
5128
5128
|
};
|
|
@@ -5132,25 +5132,25 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5132
5132
|
}, [
|
|
5133
5133
|
e,
|
|
5134
5134
|
f,
|
|
5135
|
-
j,
|
|
5136
5135
|
M,
|
|
5137
|
-
|
|
5136
|
+
N,
|
|
5137
|
+
De,
|
|
5138
|
+
Me,
|
|
5138
5139
|
Ne,
|
|
5139
5140
|
Pe,
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
Ie
|
|
5141
|
+
P,
|
|
5142
|
+
Fe
|
|
5143
5143
|
]), useEffect(() => () => {
|
|
5144
|
-
|
|
5144
|
+
S.current.forEach((e) => e.destroy()), S.current.clear();
|
|
5145
5145
|
}, []);
|
|
5146
|
-
let
|
|
5147
|
-
p((e) => e === t ? null : t),
|
|
5146
|
+
let Ie = useCallback((t) => {
|
|
5147
|
+
p((e) => e === t ? null : t), E.current = null, D.current = null, O.current = null, k.current = [], A.current = [], e && clearAllPreviewSources(e);
|
|
5148
5148
|
}, [e]);
|
|
5149
5149
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
5150
5150
|
className: `mapbox-measure-control ${c}`,
|
|
5151
5151
|
style: l,
|
|
5152
5152
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5153
|
-
ref:
|
|
5153
|
+
ref: T,
|
|
5154
5154
|
className: `mapbox-control-btn mapbox-measure-control__btn ${u ? "mapbox-measure-control__btn--active" : ""}`,
|
|
5155
5155
|
onClick: () => d(!u),
|
|
5156
5156
|
title: "测量",
|
|
@@ -5161,14 +5161,14 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5161
5161
|
className: "mapbox-measure-control__btn-icon"
|
|
5162
5162
|
}),
|
|
5163
5163
|
/* @__PURE__ */ jsx("span", { children: "测量" }),
|
|
5164
|
-
|
|
5164
|
+
b.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
5165
5165
|
"(",
|
|
5166
|
-
|
|
5166
|
+
b.length,
|
|
5167
5167
|
")"
|
|
5168
5168
|
] })
|
|
5169
5169
|
]
|
|
5170
5170
|
}), u && /* @__PURE__ */ jsxs("div", {
|
|
5171
|
-
ref:
|
|
5171
|
+
ref: w,
|
|
5172
5172
|
className: "mapbox-measure-control__panel",
|
|
5173
5173
|
children: [
|
|
5174
5174
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -5179,18 +5179,18 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5179
5179
|
className: "mapbox-measure-control__settings",
|
|
5180
5180
|
children: [
|
|
5181
5181
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5182
|
-
checked:
|
|
5183
|
-
onChange: (e) =>
|
|
5182
|
+
checked: y.showArea,
|
|
5183
|
+
onChange: (e) => je("showArea", e),
|
|
5184
5184
|
children: "面积"
|
|
5185
5185
|
}),
|
|
5186
5186
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5187
|
-
checked:
|
|
5188
|
-
onChange: (e) =>
|
|
5187
|
+
checked: y.showLength,
|
|
5188
|
+
onChange: (e) => je("showLength", e),
|
|
5189
5189
|
children: "长度"
|
|
5190
5190
|
}),
|
|
5191
5191
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5192
|
-
checked:
|
|
5193
|
-
onChange: (e) =>
|
|
5192
|
+
checked: y.showRadius,
|
|
5193
|
+
onChange: (e) => je("showRadius", e),
|
|
5194
5194
|
children: "半径"
|
|
5195
5195
|
})
|
|
5196
5196
|
]
|
|
@@ -5203,15 +5203,15 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5203
5203
|
className: "mapbox-measure-control__tools",
|
|
5204
5204
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
5205
5205
|
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5206
|
-
onClick: () =>
|
|
5206
|
+
onClick: () => Ie(e.mode),
|
|
5207
5207
|
title: e.label,
|
|
5208
5208
|
children: /* @__PURE__ */ jsx("img", {
|
|
5209
5209
|
src: e.icon,
|
|
5210
5210
|
alt: e.label
|
|
5211
5211
|
})
|
|
5212
|
-
}, e.mode)),
|
|
5212
|
+
}, e.mode)), b.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
5213
5213
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
5214
|
-
onClick:
|
|
5214
|
+
onClick: ke,
|
|
5215
5215
|
title: "清除全部",
|
|
5216
5216
|
children: /* @__PURE__ */ jsx("img", {
|
|
5217
5217
|
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",
|
|
@@ -5219,7 +5219,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5219
5219
|
})
|
|
5220
5220
|
})]
|
|
5221
5221
|
}),
|
|
5222
|
-
|
|
5222
|
+
b.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
5223
5223
|
className: "mapbox-measure-control__list",
|
|
5224
5224
|
children: /* @__PURE__ */ jsxs("table", {
|
|
5225
5225
|
className: "mapbox-measure-control__table",
|
|
@@ -5229,9 +5229,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5229
5229
|
/* @__PURE__ */ jsx("th", { children: "面积" }),
|
|
5230
5230
|
/* @__PURE__ */ jsx("th", { children: "长度/半径" }),
|
|
5231
5231
|
/* @__PURE__ */ jsx("th", {})
|
|
5232
|
-
] }) }), /* @__PURE__ */ jsx("tbody", { children:
|
|
5232
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: b.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
5233
5233
|
className: "mapbox-measure-control__table-row",
|
|
5234
|
-
onClick: () =>
|
|
5234
|
+
onClick: () => Ae(e.entity.id),
|
|
5235
5235
|
children: [
|
|
5236
5236
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
5237
5237
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -5240,7 +5240,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5240
5240
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
5241
5241
|
className: "mapbox-measure-control__delete-btn",
|
|
5242
5242
|
onClick: (t) => {
|
|
5243
|
-
t.stopPropagation(),
|
|
5243
|
+
t.stopPropagation(), Oe(e.entity.id);
|
|
5244
5244
|
},
|
|
5245
5245
|
title: "删除",
|
|
5246
5246
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -5295,31 +5295,31 @@ var raster_paint_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standal
|
|
|
5295
5295
|
}
|
|
5296
5296
|
];
|
|
5297
5297
|
function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds: c = [], className: l, style: u }) {
|
|
5298
|
-
let [d, f] = useState(!1), [p,
|
|
5298
|
+
let [d, f] = useState(!1), [p, h] = useState({ ...DEFAULT_CONFIG }), _ = useRef(null), v = useRef(null), y = r !== void 0;
|
|
5299
5299
|
useEffect(() => {
|
|
5300
5300
|
let e = (e) => {
|
|
5301
|
-
|
|
5301
|
+
_.current && !_.current.contains(e.target) && v.current && !v.current.contains(e.target) && f(!1);
|
|
5302
5302
|
};
|
|
5303
5303
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
5304
5304
|
}, []);
|
|
5305
|
-
let
|
|
5305
|
+
let b = useMemo(() => y ? {
|
|
5306
5306
|
brightness: r.brightness ?? DEFAULT_CONFIG.brightness,
|
|
5307
5307
|
saturation: r.saturation ?? DEFAULT_CONFIG.saturation,
|
|
5308
5308
|
contrast: r.contrast ?? DEFAULT_CONFIG.contrast,
|
|
5309
5309
|
hueRotate: r.hueRotate ?? DEFAULT_CONFIG.hueRotate
|
|
5310
5310
|
} : p, [
|
|
5311
|
-
|
|
5311
|
+
y,
|
|
5312
5312
|
r,
|
|
5313
5313
|
p
|
|
5314
|
-
]),
|
|
5314
|
+
]), x = useRef(y);
|
|
5315
5315
|
useEffect(() => {
|
|
5316
|
-
|
|
5317
|
-
}, [
|
|
5318
|
-
let
|
|
5316
|
+
y && !x.current && h({ ...b }), x.current = y;
|
|
5317
|
+
}, [y, b]);
|
|
5318
|
+
let S = useCallback((t) => {
|
|
5319
5319
|
if (!(!e || c.length === 0)) for (let n of c) e.getLayer(n) && (e.setPaintProperty(n, "raster-brightness-min", 0), e.setPaintProperty(n, "raster-brightness-max", t.brightness), e.setPaintProperty(n, "raster-saturation", t.saturation), e.setPaintProperty(n, "raster-contrast", t.contrast), e.setPaintProperty(n, "raster-hue-rotate", t.hueRotate));
|
|
5320
|
-
}, [e, c]),
|
|
5321
|
-
if (
|
|
5322
|
-
...
|
|
5320
|
+
}, [e, c]), ye = useCallback((e, t) => {
|
|
5321
|
+
if (y) s?.({
|
|
5322
|
+
...b,
|
|
5323
5323
|
[e]: t
|
|
5324
5324
|
});
|
|
5325
5325
|
else {
|
|
@@ -5327,35 +5327,35 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5327
5327
|
...p,
|
|
5328
5328
|
[e]: t
|
|
5329
5329
|
};
|
|
5330
|
-
|
|
5330
|
+
h(n), S(n);
|
|
5331
5331
|
}
|
|
5332
5332
|
}, [
|
|
5333
|
-
v,
|
|
5334
|
-
s,
|
|
5335
5333
|
y,
|
|
5334
|
+
s,
|
|
5335
|
+
b,
|
|
5336
5336
|
p,
|
|
5337
|
-
|
|
5338
|
-
]),
|
|
5339
|
-
|
|
5337
|
+
S
|
|
5338
|
+
]), C = useCallback(() => {
|
|
5339
|
+
y ? s?.({ ...DEFAULT_CONFIG }) : (h({ ...DEFAULT_CONFIG }), S({ ...DEFAULT_CONFIG }));
|
|
5340
5340
|
}, [
|
|
5341
|
-
|
|
5341
|
+
y,
|
|
5342
5342
|
s,
|
|
5343
|
-
|
|
5343
|
+
S
|
|
5344
5344
|
]);
|
|
5345
5345
|
useEffect(() => {
|
|
5346
|
-
!
|
|
5346
|
+
!y && c.length > 0 && S(p);
|
|
5347
5347
|
}, [
|
|
5348
5348
|
c,
|
|
5349
|
-
|
|
5350
|
-
|
|
5349
|
+
y,
|
|
5350
|
+
S,
|
|
5351
5351
|
p
|
|
5352
5352
|
]);
|
|
5353
|
-
let
|
|
5353
|
+
let w = (e, t) => e === "hueRotate" ? `${Math.round(t)}°` : t.toFixed(2);
|
|
5354
5354
|
return /* @__PURE__ */ jsxs("div", {
|
|
5355
5355
|
className: `mapbox-raster-paint-control${l ? ` ${l}` : ""}`,
|
|
5356
5356
|
style: u,
|
|
5357
5357
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5358
|
-
ref:
|
|
5358
|
+
ref: v,
|
|
5359
5359
|
className: `mapbox-control-btn mapbox-raster-paint-control__btn${d ? " mapbox-raster-paint-control__btn--active" : ""}`,
|
|
5360
5360
|
onClick: () => f(!d),
|
|
5361
5361
|
title: "栅格渲染调节",
|
|
@@ -5365,7 +5365,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5365
5365
|
alt: "raster paint"
|
|
5366
5366
|
}), /* @__PURE__ */ jsx("span", { children: "渲染" })]
|
|
5367
5367
|
}), d && /* @__PURE__ */ jsxs("div", {
|
|
5368
|
-
ref:
|
|
5368
|
+
ref: _,
|
|
5369
5369
|
className: "mapbox-raster-paint-control__panel",
|
|
5370
5370
|
children: [SLIDER_CONFIG.map(({ key: e, label: t, min: n, max: r, step: i }) => /* @__PURE__ */ jsxs("div", {
|
|
5371
5371
|
className: "mapbox-raster-paint-control__slider-row",
|
|
@@ -5379,18 +5379,18 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5379
5379
|
min: n,
|
|
5380
5380
|
max: r,
|
|
5381
5381
|
step: i,
|
|
5382
|
-
value:
|
|
5383
|
-
onChange: (t) =>
|
|
5382
|
+
value: b[e],
|
|
5383
|
+
onChange: (t) => ye(e, t),
|
|
5384
5384
|
tooltipVisible: !1
|
|
5385
5385
|
}),
|
|
5386
5386
|
/* @__PURE__ */ jsx("span", {
|
|
5387
5387
|
className: "mapbox-raster-paint-control__value",
|
|
5388
|
-
children:
|
|
5388
|
+
children: w(e, b[e])
|
|
5389
5389
|
})
|
|
5390
5390
|
]
|
|
5391
5391
|
}, e)), /* @__PURE__ */ jsx("button", {
|
|
5392
5392
|
className: "mapbox-raster-paint-control__reset",
|
|
5393
|
-
onClick:
|
|
5393
|
+
onClick: C,
|
|
5394
5394
|
children: "重置"
|
|
5395
5395
|
})]
|
|
5396
5396
|
})]
|
|
@@ -5398,43 +5398,43 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5398
5398
|
}
|
|
5399
5399
|
var marker_default = "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='1769397418113'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10253'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M755.4048%20217.2928A348.3648%20348.3648%200%200%200%20512%20119.3472a348.3136%20348.3136%200%200%200-243.3536%2097.8944%20328.4992%20328.4992%200%200%200-100.864%20236.3392c0%2049.408%2011.7248%2095.744%2032%20137.728a378.0096%20378.0096%200%200%200%2091.136%20118.4256l203.5712%20179.456%2017.5104%2015.4624%2017.5104-15.4624%20203.4176-179.3536a378.6752%20378.6752%200%200%200%2091.2384-118.4768c20.2752-41.984%2032.0512-88.32%2032.0512-137.7792a328.448%20328.448%200%200%200-100.8128-236.288z%20m24.1152%20353.3824a329.216%20329.216%200%200%201-79.872%20103.0656l-188.0064%20164.6592-187.1872-164.7616a329.0624%20329.0624%200%200%201-79.7696-103.0144%20267.0592%20267.0592%200%200%201-27.136-117.0944c0-78.7968%2032.9728-150.1184%2086.272-201.728a298.3936%20298.3936%200%200%201%20208.2816-83.5584c81.3056%200%20154.9824%2031.9488%20208.2304%2083.6096a279.9104%20279.9104%200%200%201%2086.272%20201.728%20266.496%20266.496%200%200%201-27.0848%20117.0944z%20m-164.1472-212.1728l0.0512-0.0512a146.9952%20146.9952%200%200%200-104.2432-43.2128c-40.6528%200-77.568%2016.5376-104.2432%2043.2128l0.0512%200.0512a147.3536%20147.3536%200%200%200-0.0512%20208.6912%20147.0464%20147.0464%200%200%200%20208.4864%200%20147.5072%20147.5072%200%200%200-0.0512-208.6912z%20m-34.1504%20174.2336a97.536%2097.536%200%200%201-69.2736%2028.7232%2097.6384%2097.6384%200%200%201-69.3248-28.7232%2097.792%2097.792%200%200%201-0.1536-138.4448h0.1024a97.9456%2097.9456%200%200%201%20138.5984%200h0.1536c17.664%2017.6128%2028.5696%2042.1376%2028.5696%2069.2224a97.1776%2097.1776%200%200%201-28.672%2069.2224z'%20fill='%23ffffff'%20p-id='10254'%3e%3c/path%3e%3c/svg%3e";
|
|
5400
5400
|
const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect: r, drawMode: i, onDrawModeChange: s, showRectangleTool: c = !1, showCircleTool: l = !1, showPolygonTool: u = !1, showSquareTool: d = !1, showPolylineTool: f = !1 }) => {
|
|
5401
|
-
let [p,
|
|
5401
|
+
let [p, h] = useState(!1), g = useRef(null);
|
|
5402
5402
|
useEffect(() => {
|
|
5403
5403
|
let e = (e) => {
|
|
5404
|
-
|
|
5404
|
+
g.current && !g.current.contains(e.target) && h(!1);
|
|
5405
5405
|
};
|
|
5406
5406
|
if (p) return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
5407
5407
|
}, [p]);
|
|
5408
|
-
let
|
|
5409
|
-
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")),
|
|
5410
|
-
}, _ = () => {
|
|
5411
|
-
i === "rectangle" ? s(null) : (r(null), s("rectangle"));
|
|
5408
|
+
let _ = (e) => {
|
|
5409
|
+
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")), h(!1);
|
|
5412
5410
|
}, v = () => {
|
|
5413
|
-
i === "
|
|
5411
|
+
i === "rectangle" ? s(null) : (r(null), s("rectangle"));
|
|
5414
5412
|
}, y = () => {
|
|
5415
|
-
i === "
|
|
5413
|
+
i === "circle" ? s(null) : (r(null), s("circle"));
|
|
5416
5414
|
}, b = () => {
|
|
5417
|
-
i === "
|
|
5415
|
+
i === "polygon" ? s(null) : (r(null), s("polygon"));
|
|
5418
5416
|
}, x = () => {
|
|
5417
|
+
i === "square" ? s(null) : (r(null), s("square"));
|
|
5418
|
+
}, S = () => {
|
|
5419
5419
|
i === "polyline" ? s(null) : (r(null), s("polyline"));
|
|
5420
|
-
},
|
|
5421
|
-
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null),
|
|
5422
|
-
},
|
|
5420
|
+
}, ye = () => {
|
|
5421
|
+
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), h(!p);
|
|
5422
|
+
}, C = (e) => e.size ? {
|
|
5423
5423
|
width: e.size,
|
|
5424
5424
|
height: e.size
|
|
5425
5425
|
} : {
|
|
5426
5426
|
width: e.width || 32,
|
|
5427
5427
|
height: e.height || 32
|
|
5428
|
-
},
|
|
5428
|
+
}, w = p || t, T = i === "rectangle", E = i === "circle", D = i === "polygon", be = i === "square", xe = i === "polyline";
|
|
5429
5429
|
return /* @__PURE__ */ jsxs("div", {
|
|
5430
|
-
ref:
|
|
5430
|
+
ref: g,
|
|
5431
5431
|
className: "mapbox-edit-control",
|
|
5432
5432
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
5433
5433
|
className: "mapbox-edit-control__btn-group",
|
|
5434
5434
|
children: [
|
|
5435
5435
|
/* @__PURE__ */ jsxs("button", {
|
|
5436
|
-
className: `mapbox-control-btn ${
|
|
5437
|
-
onClick:
|
|
5436
|
+
className: `mapbox-control-btn ${w ? "mapbox-control-btn--active" : ""}`,
|
|
5437
|
+
onClick: ye,
|
|
5438
5438
|
title: "Marker",
|
|
5439
5439
|
children: [t ? /* @__PURE__ */ jsx("img", {
|
|
5440
5440
|
src: t.icon,
|
|
@@ -5447,8 +5447,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5447
5447
|
}), /* @__PURE__ */ jsx("span", { children: t ? t.name : "Marker" })]
|
|
5448
5448
|
}),
|
|
5449
5449
|
d && /* @__PURE__ */ jsxs("button", {
|
|
5450
|
-
className: `mapbox-control-btn ${
|
|
5451
|
-
onClick:
|
|
5450
|
+
className: `mapbox-control-btn ${be ? "mapbox-control-btn--active" : ""}`,
|
|
5451
|
+
onClick: x,
|
|
5452
5452
|
title: "绘制正方形",
|
|
5453
5453
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5454
5454
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e",
|
|
@@ -5457,8 +5457,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5457
5457
|
}), /* @__PURE__ */ jsx("span", { children: "正方形" })]
|
|
5458
5458
|
}),
|
|
5459
5459
|
c && /* @__PURE__ */ jsxs("button", {
|
|
5460
|
-
className: `mapbox-control-btn ${
|
|
5461
|
-
onClick:
|
|
5460
|
+
className: `mapbox-control-btn ${T ? "mapbox-control-btn--active" : ""}`,
|
|
5461
|
+
onClick: v,
|
|
5462
5462
|
title: "绘制矩形",
|
|
5463
5463
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5464
5464
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e",
|
|
@@ -5467,8 +5467,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5467
5467
|
}), /* @__PURE__ */ jsx("span", { children: "矩形" })]
|
|
5468
5468
|
}),
|
|
5469
5469
|
l && /* @__PURE__ */ jsxs("button", {
|
|
5470
|
-
className: `mapbox-control-btn ${
|
|
5471
|
-
onClick:
|
|
5470
|
+
className: `mapbox-control-btn ${E ? "mapbox-control-btn--active" : ""}`,
|
|
5471
|
+
onClick: y,
|
|
5472
5472
|
title: "绘制圆形",
|
|
5473
5473
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5474
5474
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e",
|
|
@@ -5477,8 +5477,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5477
5477
|
}), /* @__PURE__ */ jsx("span", { children: "圆形" })]
|
|
5478
5478
|
}),
|
|
5479
5479
|
u && /* @__PURE__ */ jsxs("button", {
|
|
5480
|
-
className: `mapbox-control-btn ${
|
|
5481
|
-
onClick:
|
|
5480
|
+
className: `mapbox-control-btn ${D ? "mapbox-control-btn--active" : ""}`,
|
|
5481
|
+
onClick: b,
|
|
5482
5482
|
title: "绘制多边形",
|
|
5483
5483
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5484
5484
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e",
|
|
@@ -5487,8 +5487,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5487
5487
|
}), /* @__PURE__ */ jsx("span", { children: "多边形" })]
|
|
5488
5488
|
}),
|
|
5489
5489
|
f && /* @__PURE__ */ jsxs("button", {
|
|
5490
|
-
className: `mapbox-control-btn ${
|
|
5491
|
-
onClick:
|
|
5490
|
+
className: `mapbox-control-btn ${xe ? "mapbox-control-btn--active" : ""}`,
|
|
5491
|
+
onClick: S,
|
|
5492
5492
|
title: "绘制折线",
|
|
5493
5493
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5494
5494
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e",
|
|
@@ -5505,10 +5505,10 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5505
5505
|
}), /* @__PURE__ */ jsx("div", {
|
|
5506
5506
|
className: "mapbox-edit-control__template-list",
|
|
5507
5507
|
children: e.map((e) => {
|
|
5508
|
-
let n =
|
|
5508
|
+
let n = C(e), r = t?.id === e.id;
|
|
5509
5509
|
return /* @__PURE__ */ jsxs("div", {
|
|
5510
5510
|
className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
|
|
5511
|
-
onClick: () =>
|
|
5511
|
+
onClick: () => _(e),
|
|
5512
5512
|
title: e.name,
|
|
5513
5513
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5514
5514
|
src: e.icon,
|
|
@@ -5577,28 +5577,28 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5577
5577
|
};
|
|
5578
5578
|
var route_planning_default = "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='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e", SOURCE_ID = "route-planning-temp-line", LINE_LAYER_ID = "route-planning-temp-line-layer", POINT_LAYER_ID = "route-planning-temp-point-layer";
|
|
5579
5579
|
const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointCountInput: c = !1, visualType: l = "marker", onSelectFinished: u, showButton: d = !0 }, f) => {
|
|
5580
|
-
let [p,
|
|
5580
|
+
let [p, h] = useState("idle"), [g, _] = useState(0), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(null), ye = useRef(null), C = useRef([]), w = useRef([]), T = useRef("idle"), E = useRef(null), D = useRef("");
|
|
5581
5581
|
useEffect(() => {
|
|
5582
|
-
|
|
5582
|
+
T.current = p;
|
|
5583
5583
|
}, [p]), useEffect(() => {
|
|
5584
|
-
|
|
5584
|
+
y(i);
|
|
5585
5585
|
}, [i]), useEffect(() => {
|
|
5586
|
-
if (!
|
|
5586
|
+
if (!b) return;
|
|
5587
5587
|
let e = (e) => {
|
|
5588
|
-
|
|
5588
|
+
ye.current && !ye.current.contains(e.target) && S.current && !S.current.contains(e.target) && x(!1);
|
|
5589
5589
|
}, t = setTimeout(() => {
|
|
5590
5590
|
document.addEventListener("mousedown", e);
|
|
5591
5591
|
}, 0);
|
|
5592
5592
|
return () => {
|
|
5593
5593
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
5594
5594
|
};
|
|
5595
|
-
}, [
|
|
5596
|
-
let
|
|
5597
|
-
for (let e of
|
|
5598
|
-
|
|
5599
|
-
}, [e]),
|
|
5595
|
+
}, [b]);
|
|
5596
|
+
let be = useCallback(() => {
|
|
5597
|
+
for (let e of w.current) e.remove();
|
|
5598
|
+
w.current = [], e && (e.getLayer(LINE_LAYER_ID) && e.removeLayer(LINE_LAYER_ID), e.getLayer(POINT_LAYER_ID) && e.removeLayer(POINT_LAYER_ID), e.getSource(SOURCE_ID) && e.removeSource(SOURCE_ID));
|
|
5599
|
+
}, [e]), xe = useCallback(() => {
|
|
5600
5600
|
if (!e) return;
|
|
5601
|
-
let t =
|
|
5601
|
+
let t = C.current, n = {
|
|
5602
5602
|
type: "FeatureCollection",
|
|
5603
5603
|
features: [{
|
|
5604
5604
|
type: "Feature",
|
|
@@ -5649,104 +5649,104 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5649
5649
|
"circle-stroke-color": "#fff"
|
|
5650
5650
|
}
|
|
5651
5651
|
}));
|
|
5652
|
-
}, [e]),
|
|
5653
|
-
if (!e || !
|
|
5654
|
-
let { visualType: n } =
|
|
5652
|
+
}, [e]), O = useCallback((t) => {
|
|
5653
|
+
if (!e || !E.current) return;
|
|
5654
|
+
let { visualType: n } = E.current;
|
|
5655
5655
|
if (n === "marker") {
|
|
5656
5656
|
let n = document.createElement("div");
|
|
5657
|
-
n.className = "route-planning-temp-marker", n.textContent = String(
|
|
5657
|
+
n.className = "route-planning-temp-marker", n.textContent = String(C.current.length);
|
|
5658
5658
|
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5659
|
-
|
|
5660
|
-
} else
|
|
5661
|
-
}, [e,
|
|
5662
|
-
|
|
5663
|
-
}, [
|
|
5664
|
-
let e =
|
|
5659
|
+
w.current.push(r);
|
|
5660
|
+
} else xe();
|
|
5661
|
+
}, [e, xe]), Se = useCallback(() => {
|
|
5662
|
+
be(), C.current = [], E.current = null, _(0), h("idle"), e && (e.getCanvas().style.cursor = D.current);
|
|
5663
|
+
}, [be, e]), Ce = useCallback(async () => {
|
|
5664
|
+
let e = E.current, t = [...C.current];
|
|
5665
5665
|
if (!e || t.length < 2) {
|
|
5666
|
-
|
|
5666
|
+
Se();
|
|
5667
5667
|
return;
|
|
5668
5668
|
}
|
|
5669
|
-
|
|
5669
|
+
h("planning");
|
|
5670
5670
|
try {
|
|
5671
5671
|
await e.onSelectFinished(t);
|
|
5672
5672
|
} catch (e) {
|
|
5673
5673
|
console.error("Route planning onSelectFinished failed:", e);
|
|
5674
5674
|
} finally {
|
|
5675
|
-
|
|
5675
|
+
Se();
|
|
5676
5676
|
}
|
|
5677
|
-
}, [
|
|
5678
|
-
if (
|
|
5677
|
+
}, [Se]), we = useCallback((e) => {
|
|
5678
|
+
if (T.current !== "selecting" || !E.current) return;
|
|
5679
5679
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5680
|
-
|
|
5681
|
-
let n =
|
|
5682
|
-
|
|
5683
|
-
}, [
|
|
5684
|
-
|
|
5685
|
-
}, [
|
|
5680
|
+
C.current.push(t);
|
|
5681
|
+
let n = C.current.length;
|
|
5682
|
+
_(n), O(t), n >= E.current.pointCount && Ce();
|
|
5683
|
+
}, [O, Ce]), k = useCallback((e) => {
|
|
5684
|
+
T.current === "selecting" && (e.preventDefault(), Se());
|
|
5685
|
+
}, [Se]);
|
|
5686
5686
|
useEffect(() => {
|
|
5687
|
-
if (e && p === "selecting") return e.on("click",
|
|
5688
|
-
e.off("click",
|
|
5687
|
+
if (e && p === "selecting") return e.on("click", we), e.on("contextmenu", k), () => {
|
|
5688
|
+
e.off("click", we), e.off("contextmenu", k);
|
|
5689
5689
|
};
|
|
5690
5690
|
}, [
|
|
5691
5691
|
e,
|
|
5692
5692
|
p,
|
|
5693
|
-
|
|
5694
|
-
|
|
5693
|
+
we,
|
|
5694
|
+
k
|
|
5695
5695
|
]);
|
|
5696
|
-
let
|
|
5696
|
+
let A = useCallback((t) => {
|
|
5697
5697
|
if (!e) return;
|
|
5698
|
-
|
|
5698
|
+
T.current !== "idle" && Se();
|
|
5699
5699
|
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5700
|
-
|
|
5700
|
+
E.current = {
|
|
5701
5701
|
pointCount: n,
|
|
5702
5702
|
visualType: r,
|
|
5703
5703
|
onSelectFinished: t.onSelectFinished
|
|
5704
|
-
},
|
|
5704
|
+
}, C.current = [], _(0), y(n), x(!1), D.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", h("selecting");
|
|
5705
5705
|
}, [
|
|
5706
5706
|
e,
|
|
5707
5707
|
i,
|
|
5708
5708
|
l,
|
|
5709
|
-
|
|
5709
|
+
Se
|
|
5710
5710
|
]);
|
|
5711
|
-
useImperativeHandle(f, () => ({ startPlanning:
|
|
5712
|
-
let
|
|
5713
|
-
p === "idle" ?
|
|
5714
|
-
},
|
|
5715
|
-
u &&
|
|
5716
|
-
pointCount: Math.max(2,
|
|
5711
|
+
useImperativeHandle(f, () => ({ startPlanning: A }), [A]);
|
|
5712
|
+
let j = () => {
|
|
5713
|
+
p === "idle" ? x((e) => !e) : p === "selecting" && Se();
|
|
5714
|
+
}, Te = () => {
|
|
5715
|
+
u && A({
|
|
5716
|
+
pointCount: Math.max(2, v),
|
|
5717
5717
|
visualType: l,
|
|
5718
5718
|
onSelectFinished: u
|
|
5719
5719
|
});
|
|
5720
|
-
},
|
|
5720
|
+
}, M = (e) => {
|
|
5721
5721
|
let t = parseInt(e.target.value, 10);
|
|
5722
|
-
!isNaN(t) && t >= 2 ?
|
|
5723
|
-
},
|
|
5722
|
+
!isNaN(t) && t >= 2 ? y(t) : e.target.value === "" && y(2);
|
|
5723
|
+
}, Ee = () => {
|
|
5724
5724
|
if (p === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5725
5725
|
if (p === "selecting") {
|
|
5726
|
-
let e =
|
|
5726
|
+
let e = E.current?.pointCount ?? v;
|
|
5727
5727
|
return /* @__PURE__ */ jsxs("span", { children: [
|
|
5728
|
-
|
|
5728
|
+
g,
|
|
5729
5729
|
"/",
|
|
5730
5730
|
e
|
|
5731
5731
|
] });
|
|
5732
5732
|
}
|
|
5733
5733
|
return "路径规划";
|
|
5734
|
-
},
|
|
5734
|
+
}, De = p === "selecting", N = p === "planning";
|
|
5735
5735
|
return !d && p === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5736
5736
|
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5737
5737
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5738
|
-
ref:
|
|
5739
|
-
className: `mapbox-control-btn mapbox-route-planning-control__btn${
|
|
5740
|
-
onClick:
|
|
5741
|
-
disabled:
|
|
5738
|
+
ref: S,
|
|
5739
|
+
className: `mapbox-control-btn mapbox-route-planning-control__btn${De ? " mapbox-route-planning-control__btn--active" : ""}${N ? " mapbox-route-planning-control__btn--planning" : ""}${b ? " mapbox-route-planning-control__btn--active" : ""}`,
|
|
5740
|
+
onClick: j,
|
|
5741
|
+
disabled: N,
|
|
5742
5742
|
title: p === "idle" ? "路径规划" : p === "selecting" ? "取消选点" : "规划中...",
|
|
5743
5743
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5744
5744
|
src: route_planning_default,
|
|
5745
5745
|
alt: "route",
|
|
5746
5746
|
className: "mapbox-route-planning-control__btn-icon"
|
|
5747
|
-
}),
|
|
5748
|
-
}),
|
|
5749
|
-
ref:
|
|
5747
|
+
}), Ee()]
|
|
5748
|
+
}), b && p === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5749
|
+
ref: ye,
|
|
5750
5750
|
className: "mapbox-route-planning-control__panel",
|
|
5751
5751
|
children: [/* @__PURE__ */ jsx("div", {
|
|
5752
5752
|
className: "mapbox-route-planning-control__panel-header",
|
|
@@ -5765,12 +5765,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5765
5765
|
}), c ? /* @__PURE__ */ jsx("input", {
|
|
5766
5766
|
type: "number",
|
|
5767
5767
|
className: "mapbox-route-planning-control__panel-input",
|
|
5768
|
-
value:
|
|
5768
|
+
value: v,
|
|
5769
5769
|
min: 2,
|
|
5770
|
-
onChange:
|
|
5770
|
+
onChange: M
|
|
5771
5771
|
}) : /* @__PURE__ */ jsx("span", {
|
|
5772
5772
|
className: "mapbox-route-planning-control__panel-value",
|
|
5773
|
-
children:
|
|
5773
|
+
children: v
|
|
5774
5774
|
})]
|
|
5775
5775
|
}),
|
|
5776
5776
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -5779,7 +5779,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5779
5779
|
}),
|
|
5780
5780
|
/* @__PURE__ */ jsx("button", {
|
|
5781
5781
|
className: "mapbox-route-planning-control__panel-start",
|
|
5782
|
-
onClick:
|
|
5782
|
+
onClick: Te,
|
|
5783
5783
|
disabled: !u,
|
|
5784
5784
|
children: "开始规划"
|
|
5785
5785
|
})
|
|
@@ -5936,53 +5936,53 @@ function adjustPopupForBounds(e, t) {
|
|
|
5936
5936
|
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;
|
|
5937
5937
|
}
|
|
5938
5938
|
const Mapbox = forwardRef((e, c) => {
|
|
5939
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds:
|
|
5939
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: h, mode: g = "display", editConfig: _ = {}, pickerConfig: v = {}, onPick: y, interactive: b = {}, layers: x = [], rasterPaint: S, entities: w = [], selectedIds: T = [], entityConfig: E, nameConfig: D, selectNameConfig: O, areaConfig: k, circleConfig: A, lengthConfig: j, showCoordinates: Te = !0, showScale: M = !0, showResetView: Ee = !0, showRoadHighlight: De = !1, showMeasure: N = !1, showRasterPaint: ke = !1, showRoutePlanning: Ne, onRasterPaintChange: Pe, popupDefaults: P, renderPopup: Ie, onMapLoad: Le, onEntityClick: Re, onPopupOpen: ze, onPopupClose: Be, className: Ve = "", containerStyle: He } = e, Ue = useRef(null), We = useRef(null), F = useRef(null), I = useRef(/* @__PURE__ */ new Map()), L = useRef(/* @__PURE__ */ new Map()), Ge = useRef(/* @__PURE__ */ new Set()), [R, Ke] = useState(null), qe = useRef(null), Je = useRef(null), Ye = useRef(null), [Xe, Ze] = useState(null), Qe = useRef(null), $e = useRef(null), [z, et] = useState(null), [tt, nt] = useState(g), [rt, it] = useState(null), at = useRef(null), [ot, B] = useState(null), [st, V] = useState(null), [ct, lt] = useState(null), H = useRef(!1), U = useRef(null), ut = useRef(null), W = useRef(null), dt = useRef(null), G = useRef(null), ft = useRef([]), K = useRef(null), pt = useRef(null), q = useRef(null), mt = useRef([]), ht = useRef(null), gt = useRef(!1), [_t, vt] = useState([]), yt = useRef([]);
|
|
5940
5940
|
yt.current = _t;
|
|
5941
5941
|
let J = useRef(null);
|
|
5942
5942
|
useEffect(() => {
|
|
5943
|
-
nt(
|
|
5944
|
-
}, [
|
|
5943
|
+
nt(g);
|
|
5944
|
+
}, [g]);
|
|
5945
5945
|
let bt = useCallback((e) => {
|
|
5946
|
-
let t =
|
|
5946
|
+
let t = I.current.get(e), n = L.current.get(e);
|
|
5947
5947
|
if (t && n) {
|
|
5948
5948
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5949
5949
|
let r = {
|
|
5950
5950
|
...n,
|
|
5951
5951
|
isAnimating: !0
|
|
5952
5952
|
};
|
|
5953
|
-
|
|
5953
|
+
L.current.set(e, r), t.startAnimation();
|
|
5954
5954
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5955
5955
|
let r = {
|
|
5956
5956
|
...n,
|
|
5957
5957
|
isAnimating: !0
|
|
5958
5958
|
};
|
|
5959
|
-
|
|
5959
|
+
L.current.set(e, r), t.startAnimation();
|
|
5960
5960
|
}
|
|
5961
5961
|
}
|
|
5962
5962
|
}, []), xt = useCallback((e) => {
|
|
5963
|
-
let t =
|
|
5963
|
+
let t = I.current.get(e), n = L.current.get(e);
|
|
5964
5964
|
if (t && n) {
|
|
5965
5965
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5966
5966
|
let r = {
|
|
5967
5967
|
...n,
|
|
5968
5968
|
isAnimating: !1
|
|
5969
5969
|
};
|
|
5970
|
-
|
|
5970
|
+
L.current.set(e, r), t.stopAnimation();
|
|
5971
5971
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5972
5972
|
let r = {
|
|
5973
5973
|
...n,
|
|
5974
5974
|
isAnimating: !1
|
|
5975
5975
|
};
|
|
5976
|
-
|
|
5976
|
+
L.current.set(e, r), t.stopAnimation();
|
|
5977
5977
|
}
|
|
5978
5978
|
}
|
|
5979
5979
|
}, []), St = useCallback((e) => {
|
|
5980
|
-
let t =
|
|
5980
|
+
let t = L.current.get(e);
|
|
5981
5981
|
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? xt(e) : bt(e));
|
|
5982
5982
|
}, [bt, xt]), Ct = useCallback((e) => {
|
|
5983
5983
|
if (e === void 0) {
|
|
5984
5984
|
let e = !1;
|
|
5985
|
-
for (let [, t] of
|
|
5985
|
+
for (let [, t] of I.current) if (t instanceof UnitRenderer) {
|
|
5986
5986
|
let n = t.getShowTrajectory();
|
|
5987
5987
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
5988
5988
|
e = !0;
|
|
@@ -5990,46 +5990,46 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5990
5990
|
}
|
|
5991
5991
|
}
|
|
5992
5992
|
let t = e ? 0 : "all";
|
|
5993
|
-
for (let [, e] of
|
|
5993
|
+
for (let [, e] of I.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
5994
5994
|
} else {
|
|
5995
5995
|
let t = new Set(e.map(String));
|
|
5996
|
-
for (let [e, n] of
|
|
5996
|
+
for (let [e, n] of I.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
5997
5997
|
}
|
|
5998
5998
|
}, []), wt = useCallback((e, t, n) => {
|
|
5999
|
-
let r =
|
|
6000
|
-
if (!r?.popup || !
|
|
6001
|
-
let i = r.popup.content ??
|
|
5999
|
+
let r = w.find((t) => String(t.id) === String(e));
|
|
6000
|
+
if (!r?.popup || !F.current) return;
|
|
6001
|
+
let i = r.popup.content ?? Ie?.(r);
|
|
6002
6002
|
if (!i) return;
|
|
6003
|
-
let a = mergePopupConfig(r.popup,
|
|
6004
|
-
|
|
6003
|
+
let a = mergePopupConfig(r.popup, P, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, F.current, n);
|
|
6004
|
+
Ke({
|
|
6005
6005
|
entityId: e,
|
|
6006
6006
|
position: o,
|
|
6007
6007
|
config: a,
|
|
6008
6008
|
openedBy: t,
|
|
6009
6009
|
actualPosition: s
|
|
6010
|
-
}),
|
|
6010
|
+
}), ze?.(e);
|
|
6011
6011
|
}, [
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6012
|
+
w,
|
|
6013
|
+
P,
|
|
6014
|
+
Ie,
|
|
6015
|
+
ze
|
|
6016
6016
|
]), Tt = useCallback((e) => {
|
|
6017
|
-
|
|
6018
|
-
}, [
|
|
6019
|
-
|
|
6020
|
-
}, [
|
|
6021
|
-
let r =
|
|
6017
|
+
R?.entityId === e && (Ke(null), Be?.(e));
|
|
6018
|
+
}, [R, Be]), Et = useCallback(() => {
|
|
6019
|
+
Ke((e) => (e && Be?.(e.entityId), null));
|
|
6020
|
+
}, [Be]), Dt = useCallback((e) => R?.entityId === e, [R]), Ot = useCallback((e, t, n) => {
|
|
6021
|
+
let r = F.current;
|
|
6022
6022
|
r && r.flyTo({
|
|
6023
6023
|
center: e,
|
|
6024
6024
|
zoom: t ?? r.getZoom(),
|
|
6025
6025
|
...n
|
|
6026
6026
|
});
|
|
6027
6027
|
}, []), kt = useCallback((e, t, n) => {
|
|
6028
|
-
let r =
|
|
6028
|
+
let r = F.current;
|
|
6029
6029
|
if (!r || e.length === 0) return;
|
|
6030
6030
|
let i = [];
|
|
6031
6031
|
for (let t of e) {
|
|
6032
|
-
let e =
|
|
6032
|
+
let e = I.current.get(t);
|
|
6033
6033
|
e && i.push(e.getBounds());
|
|
6034
6034
|
}
|
|
6035
6035
|
if (i.length === 0) return;
|
|
@@ -6052,9 +6052,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6052
6052
|
};
|
|
6053
6053
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
6054
6054
|
}, []), At = useCallback((e) => {
|
|
6055
|
-
let t =
|
|
6055
|
+
let t = F.current;
|
|
6056
6056
|
if (!t || !t.getContainer()) return;
|
|
6057
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } =
|
|
6057
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = v;
|
|
6058
6058
|
if (!n) {
|
|
6059
6059
|
at.current &&= (at.current.remove(), null);
|
|
6060
6060
|
return;
|
|
@@ -6063,7 +6063,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6063
6063
|
at.current.setLngLat(e);
|
|
6064
6064
|
let t = at.current.getElement(), n = t.querySelector(".marker-label");
|
|
6065
6065
|
if (i) {
|
|
6066
|
-
let e = resolveNameConfig(a,
|
|
6066
|
+
let e = resolveNameConfig(a, D);
|
|
6067
6067
|
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`;
|
|
6068
6068
|
else {
|
|
6069
6069
|
let n = document.createElement("div");
|
|
@@ -6075,7 +6075,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6075
6075
|
n.className = "mapbox-picker-marker";
|
|
6076
6076
|
let o = document.createElement("div");
|
|
6077
6077
|
if (o.className = "marker-inner", o.style.background = r, n.appendChild(o), i) {
|
|
6078
|
-
let e = resolveNameConfig(a,
|
|
6078
|
+
let e = resolveNameConfig(a, D), t = document.createElement("div");
|
|
6079
6079
|
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);
|
|
6080
6080
|
}
|
|
6081
6081
|
at.current = new mapboxgl.Marker({
|
|
@@ -6083,11 +6083,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6083
6083
|
anchor: "bottom"
|
|
6084
6084
|
}).setLngLat(e).addTo(t);
|
|
6085
6085
|
}
|
|
6086
|
-
}, [
|
|
6086
|
+
}, [v, D]), jt = useCallback(() => {
|
|
6087
6087
|
at.current &&= (at.current.remove(), null);
|
|
6088
6088
|
}, []), Mt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Nt = useCallback((e) => {
|
|
6089
|
-
let t =
|
|
6090
|
-
if (
|
|
6089
|
+
let t = F.current;
|
|
6090
|
+
if (Ue.current) if (ht.current &&= (ht.current.remove(), null), e && t) {
|
|
6091
6091
|
t.getCanvas().style.cursor = "none";
|
|
6092
6092
|
let n = document.createElement("div");
|
|
6093
6093
|
n.className = "mapbox-custom-cursor";
|
|
@@ -6107,7 +6107,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6107
6107
|
let e = ht.current._cleanup;
|
|
6108
6108
|
e && e(), ht.current.remove(), ht.current = null;
|
|
6109
6109
|
}
|
|
6110
|
-
let e =
|
|
6110
|
+
let e = F.current;
|
|
6111
6111
|
e && (e.getCanvas().style.cursor = "");
|
|
6112
6112
|
}, []), Pt = useCallback((e, t, n) => {
|
|
6113
6113
|
if (!e.getSource(t)) {
|
|
@@ -6146,7 +6146,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6146
6146
|
});
|
|
6147
6147
|
}
|
|
6148
6148
|
}, []), Ft = useCallback(() => {
|
|
6149
|
-
let e =
|
|
6149
|
+
let e = F.current;
|
|
6150
6150
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6151
6151
|
type: "geojson",
|
|
6152
6152
|
data: {
|
|
@@ -6172,7 +6172,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6172
6172
|
}
|
|
6173
6173
|
}), Pt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6174
6174
|
}, [Pt]), It = useCallback((e, t) => {
|
|
6175
|
-
let n =
|
|
6175
|
+
let n = F.current;
|
|
6176
6176
|
if (!n) return;
|
|
6177
6177
|
let r = n.getSource("rect-preview-source");
|
|
6178
6178
|
if (!r) return;
|
|
@@ -6193,8 +6193,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6193
6193
|
});
|
|
6194
6194
|
let l = U.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6195
6195
|
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));
|
|
6196
|
-
let
|
|
6197
|
-
if (
|
|
6196
|
+
let m = n.getSource("rect-preview-measure-source");
|
|
6197
|
+
if (m) {
|
|
6198
6198
|
let e = Pn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6199
6199
|
if (e?.showArea) {
|
|
6200
6200
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
@@ -6227,13 +6227,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6227
6227
|
properties: { label: formatLength(distance(r, i)) }
|
|
6228
6228
|
});
|
|
6229
6229
|
}
|
|
6230
|
-
|
|
6230
|
+
m.setData({
|
|
6231
6231
|
type: "FeatureCollection",
|
|
6232
6232
|
features: t
|
|
6233
6233
|
});
|
|
6234
6234
|
}
|
|
6235
6235
|
}, []), Lt = useCallback(() => {
|
|
6236
|
-
let e =
|
|
6236
|
+
let e = F.current;
|
|
6237
6237
|
if (!e) return;
|
|
6238
6238
|
let t = e.getSource("rect-preview-source");
|
|
6239
6239
|
t && t.setData({
|
|
@@ -6248,7 +6248,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6248
6248
|
}, []), X = useCallback(() => {
|
|
6249
6249
|
lt(null), Lt();
|
|
6250
6250
|
}, [Lt]), Rt = useCallback(() => {
|
|
6251
|
-
let e =
|
|
6251
|
+
let e = F.current;
|
|
6252
6252
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6253
6253
|
type: "geojson",
|
|
6254
6254
|
data: {
|
|
@@ -6300,7 +6300,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6300
6300
|
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);
|
|
6301
6301
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6302
6302
|
}, []), Vt = useCallback((e, t) => {
|
|
6303
|
-
let n =
|
|
6303
|
+
let n = F.current;
|
|
6304
6304
|
if (!n) return;
|
|
6305
6305
|
let r = n.getSource("circle-preview-source");
|
|
6306
6306
|
if (!r) return;
|
|
@@ -6345,18 +6345,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6345
6345
|
properties: { label: formatLength(i) }
|
|
6346
6346
|
});
|
|
6347
6347
|
}
|
|
6348
|
-
let
|
|
6349
|
-
|
|
6348
|
+
let m = n.getSource("circle-preview-measure-source");
|
|
6349
|
+
m && m.setData({
|
|
6350
6350
|
type: "FeatureCollection",
|
|
6351
6351
|
features: f
|
|
6352
6352
|
});
|
|
6353
|
-
let
|
|
6354
|
-
|
|
6353
|
+
let ve = n.getSource("circle-preview-radius-source");
|
|
6354
|
+
ve && ve.setData({
|
|
6355
6355
|
type: "FeatureCollection",
|
|
6356
6356
|
features: p
|
|
6357
6357
|
});
|
|
6358
6358
|
}, [Bt, zt]), Ht = useCallback(() => {
|
|
6359
|
-
let e =
|
|
6359
|
+
let e = F.current;
|
|
6360
6360
|
if (!e) return;
|
|
6361
6361
|
let t = e.getSource("circle-preview-source");
|
|
6362
6362
|
t && t.setData({
|
|
@@ -6376,7 +6376,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6376
6376
|
}, []), Ut = useCallback(() => {
|
|
6377
6377
|
dt.current = null, Ht();
|
|
6378
6378
|
}, [Ht]), Wt = useCallback(() => {
|
|
6379
|
-
let e =
|
|
6379
|
+
let e = F.current;
|
|
6380
6380
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6381
6381
|
type: "geojson",
|
|
6382
6382
|
data: {
|
|
@@ -6418,7 +6418,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6418
6418
|
}
|
|
6419
6419
|
}), Pt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6420
6420
|
}, [Pt]), Gt = useCallback((e, t) => {
|
|
6421
|
-
let n =
|
|
6421
|
+
let n = F.current;
|
|
6422
6422
|
if (!n) return;
|
|
6423
6423
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
6424
6424
|
if (!r || !i) return;
|
|
@@ -6502,7 +6502,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6502
6502
|
});
|
|
6503
6503
|
}
|
|
6504
6504
|
}, []), Kt = useCallback(() => {
|
|
6505
|
-
let e =
|
|
6505
|
+
let e = F.current;
|
|
6506
6506
|
if (!e) return;
|
|
6507
6507
|
let t = e.getSource("polygon-preview-source");
|
|
6508
6508
|
t && t.setData({
|
|
@@ -6522,7 +6522,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6522
6522
|
}, []), qt = useCallback(() => {
|
|
6523
6523
|
ft.current = [], Kt();
|
|
6524
6524
|
}, [Kt]), Jt = useCallback(() => {
|
|
6525
|
-
let e =
|
|
6525
|
+
let e = F.current;
|
|
6526
6526
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6527
6527
|
type: "geojson",
|
|
6528
6528
|
data: {
|
|
@@ -6557,7 +6557,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6557
6557
|
[n - s, r + o]
|
|
6558
6558
|
];
|
|
6559
6559
|
}, []), Xt = useCallback((e, t) => {
|
|
6560
|
-
let n =
|
|
6560
|
+
let n = F.current;
|
|
6561
6561
|
if (!n) return;
|
|
6562
6562
|
let r = n.getSource("square-preview-source");
|
|
6563
6563
|
if (!r) return;
|
|
@@ -6599,7 +6599,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6599
6599
|
});
|
|
6600
6600
|
}
|
|
6601
6601
|
}, [Bt, Yt]), Zt = useCallback(() => {
|
|
6602
|
-
let e =
|
|
6602
|
+
let e = F.current;
|
|
6603
6603
|
if (!e) return;
|
|
6604
6604
|
let t = e.getSource("square-preview-source");
|
|
6605
6605
|
t && t.setData({
|
|
@@ -6614,7 +6614,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6614
6614
|
}, []), Qt = useCallback(() => {
|
|
6615
6615
|
pt.current = null, Zt();
|
|
6616
6616
|
}, [Zt]), $t = useCallback(() => {
|
|
6617
|
-
let e =
|
|
6617
|
+
let e = F.current;
|
|
6618
6618
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6619
6619
|
type: "geojson",
|
|
6620
6620
|
data: {
|
|
@@ -6648,7 +6648,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6648
6648
|
}
|
|
6649
6649
|
}), Pt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
6650
6650
|
}, [Pt]), en = useCallback((e, t) => {
|
|
6651
|
-
let n =
|
|
6651
|
+
let n = F.current;
|
|
6652
6652
|
if (!n) return;
|
|
6653
6653
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
6654
6654
|
if (!r || !i) return;
|
|
@@ -6696,7 +6696,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6696
6696
|
});
|
|
6697
6697
|
}
|
|
6698
6698
|
}, []), tn = useCallback(() => {
|
|
6699
|
-
let e =
|
|
6699
|
+
let e = F.current;
|
|
6700
6700
|
if (!e) return;
|
|
6701
6701
|
let t = e.getSource("polyline-preview-source");
|
|
6702
6702
|
t && t.setData({
|
|
@@ -6727,23 +6727,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6727
6727
|
]), rn = useCallback((e) => {
|
|
6728
6728
|
if (V(e), e === "rectangle") {
|
|
6729
6729
|
B(null), Y(), Ut(), qt(), Qt(), Z();
|
|
6730
|
-
let e =
|
|
6730
|
+
let e = F.current;
|
|
6731
6731
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6732
6732
|
} else if (e === "circle") {
|
|
6733
6733
|
B(null), Y(), X(), qt(), Qt(), Z();
|
|
6734
|
-
let e =
|
|
6734
|
+
let e = F.current;
|
|
6735
6735
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6736
6736
|
} else if (e === "polygon") {
|
|
6737
6737
|
B(null), Y(), X(), Ut(), Qt(), Z();
|
|
6738
|
-
let e =
|
|
6738
|
+
let e = F.current;
|
|
6739
6739
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6740
6740
|
} else if (e === "square") {
|
|
6741
6741
|
B(null), Y(), X(), Ut(), qt(), Z();
|
|
6742
|
-
let e =
|
|
6742
|
+
let e = F.current;
|
|
6743
6743
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6744
6744
|
} else if (e === "polyline") {
|
|
6745
6745
|
B(null), Y(), X(), Ut(), qt(), Qt();
|
|
6746
|
-
let e =
|
|
6746
|
+
let e = F.current;
|
|
6747
6747
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6748
6748
|
} else e === "marker" ? (X(), Ut(), qt(), Qt(), Z()) : (B(null), Y(), X(), Ut(), qt(), Qt(), Z());
|
|
6749
6749
|
}, [
|
|
@@ -6755,7 +6755,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6755
6755
|
Z
|
|
6756
6756
|
]), an = useCallback((e) => {
|
|
6757
6757
|
if (e !== "picker") {
|
|
6758
|
-
let e =
|
|
6758
|
+
let e = v.value && isFinite(v.value.lng) && isFinite(v.value.lat), t = v.showMarker !== !1;
|
|
6759
6759
|
(!e || !t) && jt(), it(null);
|
|
6760
6760
|
}
|
|
6761
6761
|
e !== "edit" && (B(null), V(null), X(), Z(), Y()), nt(e);
|
|
@@ -6764,20 +6764,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6764
6764
|
Y,
|
|
6765
6765
|
X,
|
|
6766
6766
|
Z
|
|
6767
|
-
]), on = useCallback(() =>
|
|
6767
|
+
]), on = useCallback(() => tt, [tt]), sn = useCallback(() => rt, [rt]), cn = useCallback(() => {
|
|
6768
6768
|
jt(), it(null);
|
|
6769
6769
|
}, [jt]);
|
|
6770
6770
|
useEffect(() => {
|
|
6771
|
-
if (!
|
|
6772
|
-
let e =
|
|
6771
|
+
if (!z) return;
|
|
6772
|
+
let e = v.value;
|
|
6773
6773
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6774
6774
|
let t = [e.lng, e.lat];
|
|
6775
6775
|
it(e), At(t);
|
|
6776
6776
|
}
|
|
6777
6777
|
}, [
|
|
6778
|
-
|
|
6778
|
+
v.value,
|
|
6779
6779
|
At,
|
|
6780
|
-
|
|
6780
|
+
z
|
|
6781
6781
|
]);
|
|
6782
6782
|
let ln = (e) => "mode" in e, un = useCallback((e) => {
|
|
6783
6783
|
if (nt("edit"), jt(), it(null), H.current = !0, ln(e)) {
|
|
@@ -6789,23 +6789,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6789
6789
|
}) : Y()) : e.template && (ut.current = null, U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, B(e.template), V("marker"), Nt(e.template));
|
|
6790
6790
|
else if (e.mode === "rectangle") {
|
|
6791
6791
|
U.current = e.rectangleStyle || null, ut.current = null, W.current = null, G.current = null, K.current = null, q.current = null, B(null), V("rectangle"), Y();
|
|
6792
|
-
let t =
|
|
6792
|
+
let t = F.current;
|
|
6793
6793
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6794
6794
|
} else if (e.mode === "circle") {
|
|
6795
6795
|
W.current = e.circleStyle || null, U.current = null, ut.current = null, G.current = null, K.current = null, q.current = null, B(null), V("circle"), Y();
|
|
6796
|
-
let t =
|
|
6796
|
+
let t = F.current;
|
|
6797
6797
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6798
6798
|
} else if (e.mode === "polygon") {
|
|
6799
6799
|
G.current = e.polygonStyle || null, U.current = null, ut.current = null, W.current = null, K.current = null, q.current = null, B(null), V("polygon"), Y();
|
|
6800
|
-
let t =
|
|
6800
|
+
let t = F.current;
|
|
6801
6801
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6802
6802
|
} else if (e.mode === "square") {
|
|
6803
6803
|
K.current = e.squareStyle || null, U.current = null, ut.current = null, W.current = null, G.current = null, q.current = null, B(null), V("square"), Y();
|
|
6804
|
-
let t =
|
|
6804
|
+
let t = F.current;
|
|
6805
6805
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6806
6806
|
} else if (e.mode === "polyline") {
|
|
6807
6807
|
q.current = e.polylineStyle || null, U.current = null, ut.current = null, W.current = null, G.current = null, K.current = null, B(null), V("polyline"), Y();
|
|
6808
|
-
let t =
|
|
6808
|
+
let t = F.current;
|
|
6809
6809
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6810
6810
|
}
|
|
6811
6811
|
} else B(e), V("marker"), Nt(e), U.current = null, ut.current = null, W.current = null, G.current = null, K.current = null, q.current = null;
|
|
@@ -6818,7 +6818,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6818
6818
|
startAnimation: bt,
|
|
6819
6819
|
stopAnimation: xt,
|
|
6820
6820
|
toggleAnimation: St,
|
|
6821
|
-
getMap: () =>
|
|
6821
|
+
getMap: () => F.current,
|
|
6822
6822
|
openPopup: (e) => wt(e, "programmatic"),
|
|
6823
6823
|
closePopup: Tt,
|
|
6824
6824
|
closeAllPopups: Et,
|
|
@@ -6831,15 +6831,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6831
6831
|
getPickedLocation: sn,
|
|
6832
6832
|
clearPickedLocation: cn,
|
|
6833
6833
|
startDrawing: un,
|
|
6834
|
-
getRenderer: (e) =>
|
|
6834
|
+
getRenderer: (e) => I.current.get(e),
|
|
6835
6835
|
setEditingEntities: (e) => {
|
|
6836
|
-
for (let t of yt.current) e.map(String).includes(String(t)) ||
|
|
6837
|
-
for (let t of e)
|
|
6838
|
-
J.current &&= (
|
|
6836
|
+
for (let t of yt.current) e.map(String).includes(String(t)) || I.current.get(t)?.setEditing?.(!1);
|
|
6837
|
+
for (let t of e) I.current.get(t)?.setEditing?.(!0);
|
|
6838
|
+
J.current &&= (I.current.get(J.current.entityId)?.cancelEditPreview?.(), null), vt(e);
|
|
6839
6839
|
},
|
|
6840
6840
|
getEditingEntities: () => yt.current,
|
|
6841
6841
|
startRoutePlanning: (e) => {
|
|
6842
|
-
|
|
6842
|
+
We.current?.startPlanning(e);
|
|
6843
6843
|
}
|
|
6844
6844
|
}), [
|
|
6845
6845
|
bt,
|
|
@@ -6859,13 +6859,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6859
6859
|
un
|
|
6860
6860
|
]);
|
|
6861
6861
|
let dn = useCallback(() => {
|
|
6862
|
-
let e =
|
|
6862
|
+
let e = F.current;
|
|
6863
6863
|
if (!e) return;
|
|
6864
|
-
let t = new Set(
|
|
6865
|
-
for (let e of n) t.has(e) || (
|
|
6866
|
-
let r = new Set(
|
|
6867
|
-
for (let t of
|
|
6868
|
-
let n = applyEntityConfig(t,
|
|
6864
|
+
let t = new Set(w.map((e) => e.id)), n = new Set(I.current.keys());
|
|
6865
|
+
for (let e of n) t.has(e) || (I.current.get(e)?.destroy(), I.current.delete(e));
|
|
6866
|
+
let r = new Set(T.map(String));
|
|
6867
|
+
for (let t of w) {
|
|
6868
|
+
let n = applyEntityConfig(t, E), i = I.current.get(n.id);
|
|
6869
6869
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
6870
6870
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
6871
6871
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -6874,37 +6874,37 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6874
6874
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
6875
6875
|
else {
|
|
6876
6876
|
i.destroy();
|
|
6877
|
-
let t = new CanvasCircleRenderer(e, n,
|
|
6878
|
-
|
|
6877
|
+
let t = new CanvasCircleRenderer(e, n, D, O, k, A);
|
|
6878
|
+
I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6879
6879
|
}
|
|
6880
6880
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
6881
6881
|
else {
|
|
6882
6882
|
i.destroy();
|
|
6883
|
-
let t = new CircleRenderer(e, n,
|
|
6884
|
-
|
|
6883
|
+
let t = new CircleRenderer(e, n, D, O, k, A);
|
|
6884
|
+
I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6885
6885
|
}
|
|
6886
6886
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
6887
6887
|
else {
|
|
6888
6888
|
let t = null;
|
|
6889
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n,
|
|
6889
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, D, O) : n.type === "image" ? t = new CanvasImageRenderer(e, n, D, O) : n.type === "marker" ? t = new MarkerRenderer(e, n, D, O) : n.type === "unit" ? t = new UnitRenderer(e, n, D, O) : n.type === "polygon" ? t = new PolygonRenderer(e, n, D, O, k, j) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, D, O, k, A) : new CircleRenderer(e, n, D, O, k, A) : n.type === "square" ? t = new SquareRenderer(e, n, D, O, k, j) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, D, O, k, j) : n.type === "polyline" && (t = new PolylineRenderer(e, n, D, O, j)), t && (I.current.set(n.id, t), t.setSelected(r.has(String(n.id))), yt.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
6890
6890
|
}
|
|
6891
6891
|
}
|
|
6892
6892
|
for (let e of yt.current) {
|
|
6893
|
-
let t =
|
|
6893
|
+
let t = I.current.get(e);
|
|
6894
6894
|
t && t.setEditing?.(!0);
|
|
6895
6895
|
}
|
|
6896
6896
|
}, [
|
|
6897
|
-
C,
|
|
6898
6897
|
w,
|
|
6899
6898
|
T,
|
|
6900
6899
|
E,
|
|
6901
6900
|
D,
|
|
6902
6901
|
O,
|
|
6903
6902
|
k,
|
|
6904
|
-
A
|
|
6903
|
+
A,
|
|
6904
|
+
j
|
|
6905
6905
|
]), fn = useCallback(() => {
|
|
6906
|
-
for (let e of
|
|
6907
|
-
|
|
6906
|
+
for (let e of I.current.values()) e.destroy();
|
|
6907
|
+
I.current.clear();
|
|
6908
6908
|
}, []), pn = useCallback((e) => {
|
|
6909
6909
|
let t = e.getStyle();
|
|
6910
6910
|
if (!t?.layers) return;
|
|
@@ -6921,9 +6921,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6921
6921
|
];
|
|
6922
6922
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6923
6923
|
}, []), mn = useCallback((e) => {
|
|
6924
|
-
let t =
|
|
6924
|
+
let t = S, 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;
|
|
6925
6925
|
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;
|
|
6926
|
-
}, [
|
|
6926
|
+
}, [S]), hn = useCallback((e, t) => {
|
|
6927
6927
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6928
6928
|
type: "raster",
|
|
6929
6929
|
tiles: [t.url],
|
|
@@ -6944,7 +6944,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6944
6944
|
}, [pn, mn]), gn = useCallback(async (e, t) => {
|
|
6945
6945
|
try {
|
|
6946
6946
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6947
|
-
if (!
|
|
6947
|
+
if (!Ge.current.has(t.id)) return;
|
|
6948
6948
|
let a = n.format === "pbf" || n.vector_layers, o = pn(e);
|
|
6949
6949
|
if (a) {
|
|
6950
6950
|
let t = {
|
|
@@ -6975,7 +6975,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6975
6975
|
}, [pn, mn]), _n = useCallback(async (e, t) => {
|
|
6976
6976
|
try {
|
|
6977
6977
|
let n = await (await fetch(t.url)).json();
|
|
6978
|
-
if (!
|
|
6978
|
+
if (!Ge.current.has(t.id)) return;
|
|
6979
6979
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
6980
6980
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
6981
6981
|
e.getSource(n) || e.addSource(n, i);
|
|
@@ -7012,9 +7012,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7012
7012
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7013
7013
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7014
7014
|
}, []), yn = useCallback((e) => {
|
|
7015
|
-
let t =
|
|
7015
|
+
let t = F.current;
|
|
7016
7016
|
if (!t) return;
|
|
7017
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
7017
|
+
let n = new Set(e.map((e) => e.id)), r = Ge.current;
|
|
7018
7018
|
for (let e of r) n.has(e) || (vn(t, e), r.delete(e));
|
|
7019
7019
|
for (let n of e) if (r.has(n.id)) {
|
|
7020
7020
|
let e = `base-layer-${n.id}`;
|
|
@@ -7080,12 +7080,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7080
7080
|
id: n?.id ?? Mt(),
|
|
7081
7081
|
type: "rectangle",
|
|
7082
7082
|
bounds: [e, t]
|
|
7083
|
-
},
|
|
7083
|
+
}, E);
|
|
7084
7084
|
Lt();
|
|
7085
|
-
let i =
|
|
7086
|
-
if (i && !
|
|
7087
|
-
let e = new RectangleRenderer(i, r,
|
|
7088
|
-
|
|
7085
|
+
let i = F.current;
|
|
7086
|
+
if (i && !I.current.has(r.id)) {
|
|
7087
|
+
let e = new RectangleRenderer(i, r, D, O, k, j);
|
|
7088
|
+
I.current.set(r.id, e);
|
|
7089
7089
|
}
|
|
7090
7090
|
Q.current.onRectangleAdd?.(r), lt(null), U.current = null, H.current && (H.current = !1, V(null), i && (i.getCanvas().style.cursor = ""));
|
|
7091
7091
|
}
|
|
@@ -7101,12 +7101,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7101
7101
|
type: "circle",
|
|
7102
7102
|
center: e.center,
|
|
7103
7103
|
radius: n
|
|
7104
|
-
},
|
|
7104
|
+
}, E);
|
|
7105
7105
|
Ht();
|
|
7106
|
-
let a =
|
|
7107
|
-
if (a && !
|
|
7108
|
-
let e = new CircleRenderer(a, i,
|
|
7109
|
-
|
|
7106
|
+
let a = F.current;
|
|
7107
|
+
if (a && !I.current.has(i.id)) {
|
|
7108
|
+
let e = new CircleRenderer(a, i, D, O, k, A);
|
|
7109
|
+
I.current.set(i.id, e);
|
|
7110
7110
|
}
|
|
7111
7111
|
Q.current.onCircleAdd?.(i), dt.current = null, W.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
7112
7112
|
}
|
|
@@ -7122,12 +7122,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7122
7122
|
id: t?.id ?? Mt(),
|
|
7123
7123
|
type: "polygon",
|
|
7124
7124
|
coordinates: [...e]
|
|
7125
|
-
},
|
|
7125
|
+
}, E);
|
|
7126
7126
|
Kt();
|
|
7127
|
-
let r =
|
|
7128
|
-
if (r && !
|
|
7129
|
-
let e = new PolygonRenderer(r, n,
|
|
7130
|
-
|
|
7127
|
+
let r = F.current;
|
|
7128
|
+
if (r && !I.current.has(n.id)) {
|
|
7129
|
+
let e = new PolygonRenderer(r, n, D, O, k, j);
|
|
7130
|
+
I.current.set(n.id, e);
|
|
7131
7131
|
}
|
|
7132
7132
|
Q.current.onPolygonAdd?.(n), ft.current = [], G.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7133
7133
|
return;
|
|
@@ -7146,12 +7146,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7146
7146
|
type: "square",
|
|
7147
7147
|
center: e.center,
|
|
7148
7148
|
length: n
|
|
7149
|
-
},
|
|
7149
|
+
}, E);
|
|
7150
7150
|
Zt();
|
|
7151
|
-
let a =
|
|
7152
|
-
if (a && !
|
|
7153
|
-
let e = new SquareRenderer(a, i,
|
|
7154
|
-
|
|
7151
|
+
let a = F.current;
|
|
7152
|
+
if (a && !I.current.has(i.id)) {
|
|
7153
|
+
let e = new SquareRenderer(a, i, D, O, k, j);
|
|
7154
|
+
I.current.set(i.id, e);
|
|
7155
7155
|
}
|
|
7156
7156
|
Q.current.onSquareAdd?.(i), pt.current = null, K.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
7157
7157
|
}
|
|
@@ -7189,9 +7189,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7189
7189
|
}
|
|
7190
7190
|
}
|
|
7191
7191
|
if (yt.current.length > 0) {
|
|
7192
|
-
let e =
|
|
7192
|
+
let e = F.current?.getZoom() ?? 12;
|
|
7193
7193
|
if (J.current) {
|
|
7194
|
-
let { entityId: e, activeHandle: n } = J.current, r =
|
|
7194
|
+
let { entityId: e, activeHandle: n } = J.current, r = I.current.get(e);
|
|
7195
7195
|
if (r?.applyHandleMove) {
|
|
7196
7196
|
let e = r.applyHandleMove(n, t);
|
|
7197
7197
|
Q.current.onEntityEdit?.(e);
|
|
@@ -7200,7 +7200,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7200
7200
|
return;
|
|
7201
7201
|
}
|
|
7202
7202
|
for (let n of yt.current) {
|
|
7203
|
-
let r =
|
|
7203
|
+
let r = I.current.get(n);
|
|
7204
7204
|
if (!r?.getEditHandleAt) continue;
|
|
7205
7205
|
let i = r.getEditHandleAt(t, e);
|
|
7206
7206
|
if (i) {
|
|
@@ -7227,44 +7227,44 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7227
7227
|
let e = i.find((e) => String(e.id) === s);
|
|
7228
7228
|
if (e) {
|
|
7229
7229
|
if (a?.(e), e.popup) {
|
|
7230
|
-
let t = e.popup.content ??
|
|
7231
|
-
t && mergePopupConfig(e.popup,
|
|
7230
|
+
let t = e.popup.content ?? Ie?.(e);
|
|
7231
|
+
t && mergePopupConfig(e.popup, P, t).trigger === "click" && o(s, "click", n);
|
|
7232
7232
|
}
|
|
7233
7233
|
return;
|
|
7234
7234
|
}
|
|
7235
7235
|
}
|
|
7236
|
-
for (let [t, r] of
|
|
7236
|
+
for (let [t, r] of I.current) {
|
|
7237
7237
|
let s = r.getLabelLayerId();
|
|
7238
|
-
if (s &&
|
|
7238
|
+
if (s && F.current?.getLayer(s) && F.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
7239
7239
|
let e = i.find((e) => e.id === t);
|
|
7240
7240
|
if (e) {
|
|
7241
7241
|
if (a?.(e), e.popup) {
|
|
7242
|
-
let r = e.popup.content ??
|
|
7243
|
-
r && mergePopupConfig(e.popup,
|
|
7242
|
+
let r = e.popup.content ?? Ie?.(e);
|
|
7243
|
+
r && mergePopupConfig(e.popup, P, r).trigger === "click" && o(t, "click", n);
|
|
7244
7244
|
}
|
|
7245
7245
|
return;
|
|
7246
7246
|
}
|
|
7247
7247
|
}
|
|
7248
7248
|
}
|
|
7249
|
-
for (let [e, r] of
|
|
7249
|
+
for (let [e, r] of I.current) if (r.isPointInEntity(t)) {
|
|
7250
7250
|
let t = i.find((t) => t.id === e);
|
|
7251
7251
|
if (t) {
|
|
7252
7252
|
if (a?.(t), t.popup) {
|
|
7253
|
-
let r = t.popup.content ??
|
|
7254
|
-
r && mergePopupConfig(t.popup,
|
|
7253
|
+
let r = t.popup.content ?? Ie?.(t);
|
|
7254
|
+
r && mergePopupConfig(t.popup, P, r).trigger === "click" && o(e, "click", n);
|
|
7255
7255
|
}
|
|
7256
7256
|
return;
|
|
7257
7257
|
}
|
|
7258
7258
|
}
|
|
7259
7259
|
}, [
|
|
7260
|
-
|
|
7261
|
-
|
|
7260
|
+
P,
|
|
7261
|
+
Ie,
|
|
7262
7262
|
bn
|
|
7263
7263
|
]), Sn = useCallback((e) => {
|
|
7264
7264
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7265
7265
|
if (J.current) {
|
|
7266
7266
|
let { entityId: e, activeHandle: n } = J.current;
|
|
7267
|
-
|
|
7267
|
+
I.current.get(e)?.updateEditPreview?.(n, t);
|
|
7268
7268
|
return;
|
|
7269
7269
|
}
|
|
7270
7270
|
let n = Mn.current, r = Nn.current;
|
|
@@ -7278,27 +7278,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7278
7278
|
let s = mt.current;
|
|
7279
7279
|
n === "polyline" && s.length > 0 && en(s, t);
|
|
7280
7280
|
let c = En.current, l = On.current;
|
|
7281
|
-
for (let [e, n] of
|
|
7281
|
+
for (let [e, n] of I.current) if (n.isPointInEntity(t)) {
|
|
7282
7282
|
let t = c.find((t) => t.id === e);
|
|
7283
7283
|
if (!t?.popup) continue;
|
|
7284
|
-
let n = t.popup.content ??
|
|
7284
|
+
let n = t.popup.content ?? Ie?.(t);
|
|
7285
7285
|
if (!n) continue;
|
|
7286
|
-
let r = mergePopupConfig(t.popup,
|
|
7286
|
+
let r = mergePopupConfig(t.popup, P, n);
|
|
7287
7287
|
if (r.trigger === "hover") {
|
|
7288
|
-
|
|
7288
|
+
Ye.current && clearTimeout(Ye.current), Ye.current = window.setTimeout(() => {
|
|
7289
7289
|
l(e, "hover");
|
|
7290
7290
|
}, r.hoverDelay);
|
|
7291
7291
|
return;
|
|
7292
7292
|
}
|
|
7293
7293
|
}
|
|
7294
|
-
if (
|
|
7295
|
-
let e =
|
|
7296
|
-
e && !e.isPointInEntity(t) && Tt(
|
|
7294
|
+
if (Ye.current &&= (clearTimeout(Ye.current), null), R?.openedBy === "hover") {
|
|
7295
|
+
let e = I.current.get(R.entityId);
|
|
7296
|
+
e && !e.isPointInEntity(t) && Tt(R.entityId);
|
|
7297
7297
|
}
|
|
7298
7298
|
}, [
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7299
|
+
P,
|
|
7300
|
+
Ie,
|
|
7301
|
+
R,
|
|
7302
7302
|
Tt,
|
|
7303
7303
|
It,
|
|
7304
7304
|
Vt,
|
|
@@ -7310,12 +7310,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7310
7310
|
if (yt.current.length > 0) {
|
|
7311
7311
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7312
7312
|
if (J.current) {
|
|
7313
|
-
|
|
7313
|
+
I.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7314
7314
|
return;
|
|
7315
7315
|
}
|
|
7316
|
-
let n =
|
|
7316
|
+
let n = F.current?.getZoom() ?? 12;
|
|
7317
7317
|
for (let e of yt.current) {
|
|
7318
|
-
let r =
|
|
7318
|
+
let r = I.current.get(e);
|
|
7319
7319
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7320
7320
|
let i = r.getEditHandleAt(t, n);
|
|
7321
7321
|
if (i && i.type === "vertex") {
|
|
@@ -7335,7 +7335,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7335
7335
|
if (Nn.current) lt(null), Lt();
|
|
7336
7336
|
else {
|
|
7337
7337
|
V(null);
|
|
7338
|
-
let e =
|
|
7338
|
+
let e = F.current;
|
|
7339
7339
|
e && (e.getCanvas().style.cursor = "");
|
|
7340
7340
|
}
|
|
7341
7341
|
return;
|
|
@@ -7344,7 +7344,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7344
7344
|
if (dt.current) dt.current = null, Ht();
|
|
7345
7345
|
else {
|
|
7346
7346
|
V(null);
|
|
7347
|
-
let e =
|
|
7347
|
+
let e = F.current;
|
|
7348
7348
|
e && (e.getCanvas().style.cursor = "");
|
|
7349
7349
|
}
|
|
7350
7350
|
return;
|
|
@@ -7357,18 +7357,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7357
7357
|
id: t?.id ?? Mt(),
|
|
7358
7358
|
type: "polygon",
|
|
7359
7359
|
coordinates: [...e]
|
|
7360
|
-
},
|
|
7360
|
+
}, E);
|
|
7361
7361
|
Kt();
|
|
7362
|
-
let r =
|
|
7363
|
-
if (r && !
|
|
7364
|
-
let e = new PolygonRenderer(r, n,
|
|
7365
|
-
|
|
7362
|
+
let r = F.current;
|
|
7363
|
+
if (r && !I.current.has(n.id)) {
|
|
7364
|
+
let e = new PolygonRenderer(r, n, D, O, k, j);
|
|
7365
|
+
I.current.set(n.id, e);
|
|
7366
7366
|
}
|
|
7367
7367
|
Q.current.onPolygonAdd?.(n), ft.current = [], G.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7368
7368
|
} else if (e.length > 0) ft.current = [], Kt();
|
|
7369
7369
|
else {
|
|
7370
7370
|
V(null);
|
|
7371
|
-
let e =
|
|
7371
|
+
let e = F.current;
|
|
7372
7372
|
e && (e.getCanvas().style.cursor = "");
|
|
7373
7373
|
}
|
|
7374
7374
|
return;
|
|
@@ -7377,7 +7377,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7377
7377
|
if (pt.current) pt.current = null, Zt();
|
|
7378
7378
|
else {
|
|
7379
7379
|
V(null);
|
|
7380
|
-
let e =
|
|
7380
|
+
let e = F.current;
|
|
7381
7381
|
e && (e.getCanvas().style.cursor = "");
|
|
7382
7382
|
}
|
|
7383
7383
|
return;
|
|
@@ -7390,18 +7390,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7390
7390
|
id: t?.id ?? Mt(),
|
|
7391
7391
|
type: "polyline",
|
|
7392
7392
|
coordinates: [...e]
|
|
7393
|
-
},
|
|
7393
|
+
}, E);
|
|
7394
7394
|
tn();
|
|
7395
|
-
let r =
|
|
7396
|
-
if (r && !
|
|
7397
|
-
let e = new PolylineRenderer(r, n,
|
|
7398
|
-
|
|
7395
|
+
let r = F.current;
|
|
7396
|
+
if (r && !I.current.has(n.id)) {
|
|
7397
|
+
let e = new PolylineRenderer(r, n, D, O, j);
|
|
7398
|
+
I.current.set(n.id, e);
|
|
7399
7399
|
}
|
|
7400
7400
|
Q.current.onPolylineAdd?.(n), mt.current = [], q.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7401
7401
|
} else if (e.length > 0) mt.current = [], tn();
|
|
7402
7402
|
else {
|
|
7403
7403
|
V(null);
|
|
7404
|
-
let e =
|
|
7404
|
+
let e = F.current;
|
|
7405
7405
|
e && (e.getCanvas().style.cursor = "");
|
|
7406
7406
|
}
|
|
7407
7407
|
return;
|
|
@@ -7417,9 +7417,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7417
7417
|
return;
|
|
7418
7418
|
}
|
|
7419
7419
|
}
|
|
7420
|
-
for (let [t, a] of
|
|
7420
|
+
for (let [t, a] of I.current) {
|
|
7421
7421
|
let o = a.getLabelLayerId();
|
|
7422
|
-
if (o &&
|
|
7422
|
+
if (o && F.current?.getLayer(o) && F.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7423
7423
|
let e = i.find((e) => e.id === t);
|
|
7424
7424
|
if (e) {
|
|
7425
7425
|
wn(e, r, n);
|
|
@@ -7427,7 +7427,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7427
7427
|
}
|
|
7428
7428
|
}
|
|
7429
7429
|
}
|
|
7430
|
-
for (let [e, t] of
|
|
7430
|
+
for (let [e, t] of I.current) if (t.isPointInEntity(n)) {
|
|
7431
7431
|
let t = i.find((t) => t.id === e);
|
|
7432
7432
|
if (t) {
|
|
7433
7433
|
wn(t, r, n);
|
|
@@ -7443,11 +7443,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7443
7443
|
Zt,
|
|
7444
7444
|
tn
|
|
7445
7445
|
]), wn = useCallback((e, t, n) => {
|
|
7446
|
-
let r =
|
|
7446
|
+
let r = Ue.current?.getBoundingClientRect(), i = r ? {
|
|
7447
7447
|
x: t.x + r.left,
|
|
7448
7448
|
y: t.y + r.top
|
|
7449
7449
|
} : t;
|
|
7450
|
-
|
|
7450
|
+
Ze({
|
|
7451
7451
|
position: i,
|
|
7452
7452
|
lngLat: n,
|
|
7453
7453
|
items: [{
|
|
@@ -7468,7 +7468,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7468
7468
|
}]
|
|
7469
7469
|
});
|
|
7470
7470
|
}, []), Tn = useCallback(() => {
|
|
7471
|
-
|
|
7471
|
+
Ze(null);
|
|
7472
7472
|
}, []);
|
|
7473
7473
|
useEffect(() => {
|
|
7474
7474
|
let e = document.createElement("div");
|
|
@@ -7479,11 +7479,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7479
7479
|
width: 100%;
|
|
7480
7480
|
pointer-events: none;
|
|
7481
7481
|
height: 100%;
|
|
7482
|
-
z-index: ${
|
|
7483
|
-
`, document.body.appendChild(e),
|
|
7482
|
+
z-index: ${P?.zIndex ?? 1e3};
|
|
7483
|
+
`, document.body.appendChild(e), qe.current = e, () => {
|
|
7484
7484
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7485
7485
|
};
|
|
7486
|
-
}, [
|
|
7486
|
+
}, [P?.zIndex]), useEffect(() => {
|
|
7487
7487
|
let e = document.createElement("div");
|
|
7488
7488
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
7489
7489
|
position: fixed;
|
|
@@ -7492,65 +7492,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7492
7492
|
width: 100%;
|
|
7493
7493
|
pointer-events: none;
|
|
7494
7494
|
height: 100%;
|
|
7495
|
-
z-index: ${(
|
|
7496
|
-
`, document.body.appendChild(e),
|
|
7495
|
+
z-index: ${(P?.zIndex ?? 1e3) + 100};
|
|
7496
|
+
`, document.body.appendChild(e), Qe.current = e, () => {
|
|
7497
7497
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7498
7498
|
};
|
|
7499
|
-
}, [
|
|
7500
|
-
let En = useRef(
|
|
7501
|
-
En.current =
|
|
7502
|
-
let Dn = useRef(
|
|
7503
|
-
Dn.current =
|
|
7499
|
+
}, [P?.zIndex]);
|
|
7500
|
+
let En = useRef(w);
|
|
7501
|
+
En.current = w;
|
|
7502
|
+
let Dn = useRef(Re);
|
|
7503
|
+
Dn.current = Re;
|
|
7504
7504
|
let On = useRef(wt);
|
|
7505
7505
|
On.current = wt;
|
|
7506
|
-
let kn = useRef(
|
|
7507
|
-
kn.current =
|
|
7508
|
-
let An = useRef(
|
|
7509
|
-
An.current =
|
|
7506
|
+
let kn = useRef(tt);
|
|
7507
|
+
kn.current = tt;
|
|
7508
|
+
let An = useRef(y);
|
|
7509
|
+
An.current = y;
|
|
7510
7510
|
let jn = useRef(ot);
|
|
7511
7511
|
jn.current = ot;
|
|
7512
7512
|
let Mn = useRef(st);
|
|
7513
7513
|
Mn.current = st;
|
|
7514
7514
|
let Nn = useRef(ct);
|
|
7515
7515
|
Nn.current = ct;
|
|
7516
|
-
let Q = useRef(
|
|
7517
|
-
Q.current =
|
|
7518
|
-
let Pn = useRef(
|
|
7519
|
-
Pn.current =
|
|
7516
|
+
let Q = useRef(_);
|
|
7517
|
+
Q.current = _;
|
|
7518
|
+
let Pn = useRef(E);
|
|
7519
|
+
Pn.current = E, useEffect(() => {
|
|
7520
7520
|
let e = (e) => {
|
|
7521
7521
|
if (e.key === "Escape" && J.current) {
|
|
7522
|
-
|
|
7522
|
+
I.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7523
7523
|
return;
|
|
7524
7524
|
}
|
|
7525
|
-
if (e.key === "Escape" &&
|
|
7525
|
+
if (e.key === "Escape" && tt === "edit") {
|
|
7526
7526
|
if (ot && (B(null), V(null), Y()), st === "rectangle") if (ct) lt(null), Lt();
|
|
7527
7527
|
else {
|
|
7528
7528
|
V(null);
|
|
7529
|
-
let e =
|
|
7529
|
+
let e = F.current;
|
|
7530
7530
|
e && (e.getCanvas().style.cursor = "");
|
|
7531
7531
|
}
|
|
7532
7532
|
if (st === "circle") if (dt.current) dt.current = null, Ht();
|
|
7533
7533
|
else {
|
|
7534
7534
|
V(null);
|
|
7535
|
-
let e =
|
|
7535
|
+
let e = F.current;
|
|
7536
7536
|
e && (e.getCanvas().style.cursor = "");
|
|
7537
7537
|
}
|
|
7538
7538
|
if (st === "polygon") if (ft.current.length > 0) ft.current = [], Kt();
|
|
7539
7539
|
else {
|
|
7540
7540
|
V(null);
|
|
7541
|
-
let e =
|
|
7541
|
+
let e = F.current;
|
|
7542
7542
|
e && (e.getCanvas().style.cursor = "");
|
|
7543
7543
|
}
|
|
7544
7544
|
if (st === "square") if (pt.current) pt.current = null, Zt();
|
|
7545
7545
|
else {
|
|
7546
7546
|
V(null);
|
|
7547
|
-
let e =
|
|
7547
|
+
let e = F.current;
|
|
7548
7548
|
e && (e.getCanvas().style.cursor = "");
|
|
7549
7549
|
}
|
|
7550
7550
|
if (st === "polyline") if (mt.current.length > 0) mt.current = [], tn();
|
|
7551
7551
|
else {
|
|
7552
7552
|
V(null);
|
|
7553
|
-
let e =
|
|
7553
|
+
let e = F.current;
|
|
7554
7554
|
e && (e.getCanvas().style.cursor = "");
|
|
7555
7555
|
}
|
|
7556
7556
|
}
|
|
@@ -7559,7 +7559,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7559
7559
|
document.removeEventListener("keydown", e);
|
|
7560
7560
|
};
|
|
7561
7561
|
}, [
|
|
7562
|
-
|
|
7562
|
+
tt,
|
|
7563
7563
|
ot,
|
|
7564
7564
|
st,
|
|
7565
7565
|
ct,
|
|
@@ -7570,51 +7570,51 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7570
7570
|
Zt,
|
|
7571
7571
|
tn
|
|
7572
7572
|
]), useEffect(() => {
|
|
7573
|
-
let e =
|
|
7574
|
-
if (!e || !
|
|
7575
|
-
let t =
|
|
7573
|
+
let e = F.current;
|
|
7574
|
+
if (!e || !R) return;
|
|
7575
|
+
let t = R.entityId, n = R.config, r = () => {
|
|
7576
7576
|
let r = En.current.find((e) => e.id === t);
|
|
7577
7577
|
if (!r) {
|
|
7578
7578
|
Et();
|
|
7579
7579
|
return;
|
|
7580
7580
|
}
|
|
7581
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7582
|
-
|
|
7581
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Je.current);
|
|
7582
|
+
Je.current && (Je.current.style.left = `${i.x}px`, Je.current.style.top = `${i.y}px`);
|
|
7583
7583
|
}, i = setTimeout(() => {
|
|
7584
7584
|
r();
|
|
7585
7585
|
}, 50);
|
|
7586
7586
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7587
7587
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7588
7588
|
};
|
|
7589
|
-
}, [
|
|
7590
|
-
let e =
|
|
7591
|
-
if (!e || !
|
|
7592
|
-
let n =
|
|
7589
|
+
}, [R?.entityId, Et]), useEffect(() => {
|
|
7590
|
+
let e = F.current, t = Ue.current;
|
|
7591
|
+
if (!e || !Xe || !t) return;
|
|
7592
|
+
let n = Xe.lngLat, r = () => {
|
|
7593
7593
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7594
7594
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7595
7595
|
Tn();
|
|
7596
7596
|
return;
|
|
7597
7597
|
}
|
|
7598
7598
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7599
|
-
|
|
7599
|
+
$e.current && ($e.current.style.left = `${s}px`, $e.current.style.top = `${c}px`);
|
|
7600
7600
|
};
|
|
7601
7601
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7602
7602
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7603
7603
|
};
|
|
7604
|
-
}, [
|
|
7605
|
-
if (!
|
|
7604
|
+
}, [Xe?.lngLat, Tn]), useEffect(() => {
|
|
7605
|
+
if (!Ue.current) return;
|
|
7606
7606
|
let e = {
|
|
7607
7607
|
version: 8,
|
|
7608
7608
|
sources: {},
|
|
7609
7609
|
layers: []
|
|
7610
|
-
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch:
|
|
7611
|
-
container:
|
|
7610
|
+
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: m = !0, boxZoom: ve = !0 } = b, g = new mapboxgl.Map({
|
|
7611
|
+
container: Ue.current,
|
|
7612
7612
|
style: p || e,
|
|
7613
7613
|
center: l,
|
|
7614
7614
|
zoom: u,
|
|
7615
7615
|
pitch: d,
|
|
7616
7616
|
bearing: f,
|
|
7617
|
-
maxBounds:
|
|
7617
|
+
maxBounds: h,
|
|
7618
7618
|
dragPan: t,
|
|
7619
7619
|
scrollZoom: n,
|
|
7620
7620
|
doubleClickZoom: r,
|
|
@@ -7622,8 +7622,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7622
7622
|
keyboard: a,
|
|
7623
7623
|
dragRotate: o,
|
|
7624
7624
|
pitchWithRotate: c,
|
|
7625
|
-
touchPitch:
|
|
7626
|
-
boxZoom:
|
|
7625
|
+
touchPitch: m,
|
|
7626
|
+
boxZoom: ve,
|
|
7627
7627
|
transformRequest: (e, t) => {
|
|
7628
7628
|
if (t === "Glyphs") {
|
|
7629
7629
|
let t = e.match(/\/fonts\/([^/]+)\/(\d+-\d+)\.pbf/);
|
|
@@ -7635,54 +7635,54 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7635
7635
|
return { url: e };
|
|
7636
7636
|
}
|
|
7637
7637
|
});
|
|
7638
|
-
return
|
|
7639
|
-
if (!
|
|
7640
|
-
let e =
|
|
7638
|
+
return F.current = g, g.on("load", () => {
|
|
7639
|
+
if (!g.getStyle().glyphs) {
|
|
7640
|
+
let e = g.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7641
7641
|
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
7642
7642
|
}
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
}), yn(
|
|
7646
|
-
}),
|
|
7647
|
-
|
|
7643
|
+
L.current.clear(), w.forEach((e) => {
|
|
7644
|
+
L.current.set(e.id, e);
|
|
7645
|
+
}), yn(x), dn(), Ft(), Rt(), Wt(), Jt(), $t(), et(g), Le?.(g);
|
|
7646
|
+
}), g.on("click", xn), g.on("mousemove", Sn), g.on("contextmenu", Cn), () => {
|
|
7647
|
+
g.off("click", xn), g.off("mousemove", Sn), g.off("contextmenu", Cn), fn(), jt(), Y(), X(), Z(), g.remove(), F.current = null;
|
|
7648
7648
|
};
|
|
7649
7649
|
}, []), useEffect(() => {
|
|
7650
|
-
if (
|
|
7651
|
-
if (!
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7650
|
+
if (F.current) {
|
|
7651
|
+
if (!F.current.isStyleLoaded()) {
|
|
7652
|
+
F.current.once("load", () => {
|
|
7653
|
+
L.current.clear(), w.forEach((e) => {
|
|
7654
|
+
L.current.set(e.id, e);
|
|
7655
7655
|
}), dn();
|
|
7656
7656
|
});
|
|
7657
7657
|
return;
|
|
7658
7658
|
}
|
|
7659
|
-
|
|
7660
|
-
|
|
7659
|
+
L.current.clear(), w.forEach((e) => {
|
|
7660
|
+
L.current.set(e.id, e);
|
|
7661
7661
|
}), dn();
|
|
7662
7662
|
}
|
|
7663
|
-
}, [
|
|
7664
|
-
!
|
|
7663
|
+
}, [w, dn]), useEffect(() => {
|
|
7664
|
+
!F.current || !F.current.isStyleLoaded() || (fn(), dn());
|
|
7665
7665
|
}, [
|
|
7666
|
-
E,
|
|
7667
7666
|
D,
|
|
7668
7667
|
O,
|
|
7669
7668
|
k,
|
|
7670
7669
|
A,
|
|
7670
|
+
j,
|
|
7671
7671
|
fn,
|
|
7672
7672
|
dn
|
|
7673
7673
|
]), useEffect(() => {
|
|
7674
|
-
if (
|
|
7675
|
-
if (!
|
|
7676
|
-
|
|
7677
|
-
yn(
|
|
7674
|
+
if (F.current) {
|
|
7675
|
+
if (!F.current.isStyleLoaded()) {
|
|
7676
|
+
F.current.once("load", () => {
|
|
7677
|
+
yn(x);
|
|
7678
7678
|
});
|
|
7679
7679
|
return;
|
|
7680
7680
|
}
|
|
7681
|
-
yn(
|
|
7681
|
+
yn(x);
|
|
7682
7682
|
}
|
|
7683
|
-
}, [
|
|
7684
|
-
let Fn = useRef(void 0), In = useRef(!0), Ln = useRef(
|
|
7685
|
-
Ln.current =
|
|
7683
|
+
}, [x, yn]);
|
|
7684
|
+
let Fn = useRef(void 0), In = useRef(!0), Ln = useRef(x);
|
|
7685
|
+
Ln.current = x;
|
|
7686
7686
|
let Rn = useRef(yn);
|
|
7687
7687
|
Rn.current = yn;
|
|
7688
7688
|
let zn = useRef(fn);
|
|
@@ -7699,7 +7699,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7699
7699
|
Wn.current = Jt;
|
|
7700
7700
|
let Gn = useRef($t);
|
|
7701
7701
|
Gn.current = $t, useEffect(() => {
|
|
7702
|
-
let e =
|
|
7702
|
+
let e = F.current;
|
|
7703
7703
|
if (!e) return;
|
|
7704
7704
|
let t = p || {
|
|
7705
7705
|
version: 8,
|
|
@@ -7715,15 +7715,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7715
7715
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7716
7716
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7717
7717
|
}
|
|
7718
|
-
|
|
7718
|
+
Ge.current.clear(), Rn.current(Ln.current), zn.current(), Bn.current(), Vn.current(), Hn.current(), Un.current(), Wn.current(), Gn.current();
|
|
7719
7719
|
}));
|
|
7720
7720
|
}, [p]), useEffect(() => {
|
|
7721
|
-
let e = new Set(
|
|
7722
|
-
for (let [t, n] of
|
|
7723
|
-
}, [
|
|
7721
|
+
let e = new Set(T.map(String));
|
|
7722
|
+
for (let [t, n] of I.current) n.setSelected(e.has(String(t)));
|
|
7723
|
+
}, [T]);
|
|
7724
7724
|
let Kn = useRef({});
|
|
7725
7725
|
useEffect(() => {
|
|
7726
|
-
let e =
|
|
7726
|
+
let e = F.current;
|
|
7727
7727
|
if (!e) return;
|
|
7728
7728
|
let t = Kn.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;
|
|
7729
7729
|
!n && !r && !i && !a || (Kn.current = {
|
|
@@ -7743,13 +7743,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7743
7743
|
d,
|
|
7744
7744
|
f
|
|
7745
7745
|
]);
|
|
7746
|
-
let qn = (() =>
|
|
7747
|
-
if (
|
|
7746
|
+
let qn = (() => Te === !1 ? null : Te === !0 ? { enabled: !0 } : Te)(), Jn = (() => M === !1 ? null : M === !0 ? { enabled: !0 } : M)(), Yn = (() => Ee === !1 ? null : Ee === !0 ? { enabled: !0 } : Ee)(), $ = (() => {
|
|
7747
|
+
if (De === !1) return null;
|
|
7748
7748
|
let e, t, n;
|
|
7749
|
-
if (
|
|
7750
|
-
let r =
|
|
7749
|
+
if (x && x.length > 0) {
|
|
7750
|
+
let r = x.find((e) => e.hasRoadNetwork === !0) || x[0];
|
|
7751
7751
|
if (r.type === "style") {
|
|
7752
|
-
let t =
|
|
7752
|
+
let t = F.current?.getStyle();
|
|
7753
7753
|
if (t?.sources) {
|
|
7754
7754
|
let n = `base-layer-source-${r.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(n));
|
|
7755
7755
|
i && (e = i);
|
|
@@ -7757,63 +7757,63 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7757
7757
|
} else e = `base-layer-source-${r.id}`;
|
|
7758
7758
|
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7759
7759
|
}
|
|
7760
|
-
return
|
|
7760
|
+
return De === !0 ? {
|
|
7761
7761
|
enabled: !0,
|
|
7762
7762
|
source: e,
|
|
7763
7763
|
sourceLayer: t,
|
|
7764
7764
|
classField: n
|
|
7765
7765
|
} : {
|
|
7766
|
-
...
|
|
7767
|
-
source:
|
|
7768
|
-
sourceLayer:
|
|
7769
|
-
classField:
|
|
7766
|
+
...De,
|
|
7767
|
+
source: De.source || e,
|
|
7768
|
+
sourceLayer: De.sourceLayer || t,
|
|
7769
|
+
classField: De.classField || n
|
|
7770
7770
|
};
|
|
7771
|
-
})(), Xn = (() =>
|
|
7771
|
+
})(), Xn = (() => N ? N === !0 ? { enabled: !0 } : N : null)(), Zn = (() => ke ? ke === !0 ? { enabled: !0 } : ke : null)(), Qn = (() => Ne || null)(), $n = useMemo(() => {
|
|
7772
7772
|
let e = [];
|
|
7773
|
-
for (let t of
|
|
7774
|
-
let n =
|
|
7773
|
+
for (let t of x) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7774
|
+
let n = F.current;
|
|
7775
7775
|
if (n) {
|
|
7776
7776
|
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
7777
7777
|
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
7778
7778
|
}
|
|
7779
7779
|
} else e.push(`base-layer-${t.id}`);
|
|
7780
7780
|
return e;
|
|
7781
|
-
}, [
|
|
7781
|
+
}, [x, z]);
|
|
7782
7782
|
return /* @__PURE__ */ jsxs("div", {
|
|
7783
|
-
className: `comp-mapbox ${
|
|
7784
|
-
style:
|
|
7783
|
+
className: `comp-mapbox ${tt === "picker" ? "comp-mapbox--picker-mode" : ""} ${Ve}`,
|
|
7784
|
+
style: He,
|
|
7785
7785
|
children: [
|
|
7786
7786
|
/* @__PURE__ */ jsx("div", {
|
|
7787
|
-
ref:
|
|
7787
|
+
ref: Ue,
|
|
7788
7788
|
className: "comp-mapbox__map"
|
|
7789
7789
|
}),
|
|
7790
|
-
|
|
7790
|
+
tt === "picker" && v.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
7791
7791
|
className: "comp-mapbox__crosshair",
|
|
7792
7792
|
children: [/* @__PURE__ */ jsx("div", {
|
|
7793
7793
|
className: "comp-mapbox__crosshair-h",
|
|
7794
|
-
style:
|
|
7794
|
+
style: v.crosshairColor ? { backgroundColor: v.crosshairColor } : void 0
|
|
7795
7795
|
}), /* @__PURE__ */ jsx("div", {
|
|
7796
7796
|
className: "comp-mapbox__crosshair-v",
|
|
7797
|
-
style:
|
|
7797
|
+
style: v.crosshairColor ? { backgroundColor: v.crosshairColor } : void 0
|
|
7798
7798
|
})]
|
|
7799
7799
|
}),
|
|
7800
|
-
|
|
7800
|
+
tt === "edit" && _.showEditTools !== !1 && (_.markerTemplates && _.markerTemplates.length > 0 || _.showRectangleTool || _.showCircleTool || _.showPolygonTool || _.showSquareTool || _.showPolylineTool) || $ && $.enabled !== !1 || Qn && Qn.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
|
|
7801
7801
|
className: "comp-mapbox__edit-controls",
|
|
7802
7802
|
children: [
|
|
7803
|
-
|
|
7804
|
-
markerTemplates:
|
|
7803
|
+
tt === "edit" && _.showEditTools !== !1 && (_.markerTemplates && _.markerTemplates.length > 0 || _.showRectangleTool || _.showCircleTool || _.showPolygonTool || _.showSquareTool || _.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7804
|
+
markerTemplates: _.markerTemplates || [],
|
|
7805
7805
|
selectedTemplate: ot,
|
|
7806
7806
|
onTemplateSelect: nn,
|
|
7807
7807
|
drawMode: st,
|
|
7808
7808
|
onDrawModeChange: rn,
|
|
7809
|
-
showRectangleTool:
|
|
7810
|
-
showCircleTool:
|
|
7811
|
-
showPolygonTool:
|
|
7812
|
-
showSquareTool:
|
|
7813
|
-
showPolylineTool:
|
|
7809
|
+
showRectangleTool: _.showRectangleTool,
|
|
7810
|
+
showCircleTool: _.showCircleTool,
|
|
7811
|
+
showPolygonTool: _.showPolygonTool,
|
|
7812
|
+
showSquareTool: _.showSquareTool,
|
|
7813
|
+
showPolylineTool: _.showPolylineTool
|
|
7814
7814
|
}),
|
|
7815
7815
|
$ && $.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7816
|
-
map:
|
|
7816
|
+
map: z,
|
|
7817
7817
|
highlightWidth: $.highlightWidth,
|
|
7818
7818
|
defaultRoadTypes: $.defaultRoadTypes,
|
|
7819
7819
|
defaultMinWidth: $.defaultMinWidth,
|
|
@@ -7824,8 +7824,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7824
7824
|
style: $.style
|
|
7825
7825
|
}),
|
|
7826
7826
|
Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7827
|
-
ref:
|
|
7828
|
-
map:
|
|
7827
|
+
ref: We,
|
|
7828
|
+
map: z,
|
|
7829
7829
|
pointCount: Qn.pointCount,
|
|
7830
7830
|
showPointCountInput: Qn.showPointCountInput,
|
|
7831
7831
|
visualType: Qn.visualType,
|
|
@@ -7837,21 +7837,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7837
7837
|
className: "comp-mapbox__controls",
|
|
7838
7838
|
children: [
|
|
7839
7839
|
qn && qn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7840
|
-
map:
|
|
7840
|
+
map: z,
|
|
7841
7841
|
precision: qn.precision,
|
|
7842
7842
|
className: qn.className,
|
|
7843
7843
|
style: qn.style
|
|
7844
7844
|
}),
|
|
7845
7845
|
Jn && Jn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7846
|
-
map:
|
|
7846
|
+
map: z,
|
|
7847
7847
|
maxWidth: Jn.maxWidth,
|
|
7848
7848
|
unit: Jn.unit,
|
|
7849
7849
|
className: Jn.className,
|
|
7850
7850
|
style: Jn.style
|
|
7851
7851
|
}),
|
|
7852
7852
|
Xn && Xn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7853
|
-
map:
|
|
7854
|
-
entityConfig:
|
|
7853
|
+
map: z,
|
|
7854
|
+
entityConfig: E,
|
|
7855
7855
|
onDrawModeChange: (e) => {
|
|
7856
7856
|
gt.current = e;
|
|
7857
7857
|
},
|
|
@@ -7859,15 +7859,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7859
7859
|
style: Xn.style
|
|
7860
7860
|
}),
|
|
7861
7861
|
Zn && Zn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7862
|
-
map:
|
|
7863
|
-
value:
|
|
7864
|
-
onChange:
|
|
7862
|
+
map: z,
|
|
7863
|
+
value: S,
|
|
7864
|
+
onChange: Pe,
|
|
7865
7865
|
rasterPaintLayerIds: $n,
|
|
7866
7866
|
className: Zn.className,
|
|
7867
7867
|
style: Zn.style
|
|
7868
7868
|
}),
|
|
7869
7869
|
Yn && Yn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7870
|
-
map:
|
|
7870
|
+
map: z,
|
|
7871
7871
|
initialCenter: l,
|
|
7872
7872
|
initialZoom: u,
|
|
7873
7873
|
initialPitch: d,
|
|
@@ -7879,21 +7879,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7879
7879
|
]
|
|
7880
7880
|
}),
|
|
7881
7881
|
!(Qn && Qn.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7882
|
-
ref:
|
|
7883
|
-
map:
|
|
7882
|
+
ref: We,
|
|
7883
|
+
map: z,
|
|
7884
7884
|
showButton: !1
|
|
7885
7885
|
}),
|
|
7886
|
-
|
|
7887
|
-
popupState:
|
|
7888
|
-
onClose: () => Tt(
|
|
7889
|
-
portalContainer:
|
|
7890
|
-
popupRef:
|
|
7886
|
+
R && qe.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7887
|
+
popupState: R,
|
|
7888
|
+
onClose: () => Tt(R.entityId),
|
|
7889
|
+
portalContainer: qe.current,
|
|
7890
|
+
popupRef: Je
|
|
7891
7891
|
}),
|
|
7892
|
-
|
|
7893
|
-
menuState:
|
|
7892
|
+
Xe && Qe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7893
|
+
menuState: Xe,
|
|
7894
7894
|
onClose: Tn,
|
|
7895
|
-
portalContainer:
|
|
7896
|
-
menuRef:
|
|
7895
|
+
portalContainer: Qe.current,
|
|
7896
|
+
menuRef: $e
|
|
7897
7897
|
})
|
|
7898
7898
|
]
|
|
7899
7899
|
});
|