bbl-mapbox-react 0.0.20 → 0.0.21
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/components/CanvasImageRenderer.d.ts +1 -1
- package/dist/components/CircleRenderer.d.ts +1 -1
- package/dist/components/PolygonRenderer.d.ts +1 -1
- package/dist/components/PolylineRenderer.d.ts +1 -1
- package/dist/components/RectangleRenderer.d.ts +1 -1
- package/dist/components/SquareRenderer.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.mjs +637 -622
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import * as turf from "@turf/turf";
|
|
|
4
4
|
import { centroid, polygon } from "@turf/turf";
|
|
5
5
|
import { createRoot } from "react-dom/client";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { Checkbox, Slider } from "@arco-design/web-react";
|
|
9
9
|
const DEFAULT_NAME_CONFIG = {
|
|
10
10
|
fillColor: "#ffffff",
|
|
@@ -3932,10 +3932,10 @@ 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,
|
|
3936
|
-
|
|
3935
|
+
let c = useRef(null), [l, u] = useState("entering"), [d, p] = useState(!1), m = useRef(e.position), h = useRef(!1), g = s || c;
|
|
3936
|
+
h.current || (m.current = e.position), useEffect(() => {
|
|
3937
3937
|
let e = setTimeout(() => {
|
|
3938
|
-
|
|
3938
|
+
p(!0);
|
|
3939
3939
|
}, 60);
|
|
3940
3940
|
return () => clearTimeout(e);
|
|
3941
3941
|
}, []), useEffect(() => {
|
|
@@ -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 _ = useCallback(() => {
|
|
3948
|
+
e.config.animation === "none" ? r() : (h.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" && _();
|
|
3954
3954
|
};
|
|
3955
3955
|
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
3956
|
-
}, [e.config.closeOnEscape,
|
|
3956
|
+
}, [e.config.closeOnEscape, _]), useEffect(() => {
|
|
3957
3957
|
if (!e.config.closeOnClickOutside) return;
|
|
3958
3958
|
let t = (e) => {
|
|
3959
|
-
|
|
3959
|
+
g.current && !g.current.contains(e.target) && _();
|
|
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
|
+
_,
|
|
3969
|
+
g
|
|
3970
3970
|
]);
|
|
3971
|
-
let
|
|
3971
|
+
let v = () => {
|
|
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
|
+
}, y = m.current, b = /* @__PURE__ */ jsxs("div", {
|
|
3981
|
+
ref: g,
|
|
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: `${y.x}px`,
|
|
3986
|
+
top: `${y.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: v(),
|
|
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: _,
|
|
3999
3999
|
"aria-label": "Close popup",
|
|
4000
4000
|
children: "×"
|
|
4001
4001
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -4003,36 +4003,51 @@ 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(b, 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
|
-
function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style:
|
|
4010
|
-
let [
|
|
4011
|
-
|
|
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), m = useCallback((e) => {
|
|
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
|
-
|
|
4017
|
-
if (e) return e.on("mousemove",
|
|
4018
|
-
e.off("mousemove",
|
|
4016
|
+
useEffect(() => {
|
|
4017
|
+
if (e) return e.on("mousemove", m), () => {
|
|
4018
|
+
e.off("mousemove", m);
|
|
4019
4019
|
};
|
|
4020
|
-
}, [e,
|
|
4021
|
-
|
|
4022
|
-
|
|
4020
|
+
}, [e, m]), useEffect(() => () => {
|
|
4021
|
+
f.current && clearTimeout(f.current);
|
|
4022
|
+
}, []);
|
|
4023
|
+
let h = useCallback(() => {
|
|
4024
|
+
if (!c) return;
|
|
4025
|
+
let e = `${c.lng},${c.lat}`;
|
|
4026
|
+
navigator.clipboard.writeText(e).then(() => {
|
|
4027
|
+
d(!0), f.current && clearTimeout(f.current), f.current = setTimeout(() => d(!1), 1500);
|
|
4028
|
+
});
|
|
4029
|
+
}, [c]);
|
|
4030
|
+
return c ? /* @__PURE__ */ jsxs("div", {
|
|
4031
|
+
className: `mapbox-coordinate-display ${u ? "mapbox-coordinate-display--copied" : ""} ${i}`,
|
|
4032
|
+
style: s,
|
|
4033
|
+
onClick: h,
|
|
4034
|
+
title: "点击复制坐标",
|
|
4023
4035
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4024
4036
|
src: location_default,
|
|
4025
4037
|
alt: "location",
|
|
4026
4038
|
className: "mapbox-coordinate-display__icon"
|
|
4027
|
-
}), /* @__PURE__ */
|
|
4039
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4028
4040
|
className: "mapbox-coordinate-display__content",
|
|
4029
|
-
children:
|
|
4041
|
+
children: u ? /* @__PURE__ */ jsx("span", {
|
|
4042
|
+
className: "mapbox-coordinate-display__copied",
|
|
4043
|
+
children: "已复制"
|
|
4044
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
4030
4045
|
className: "mapbox-coordinate-display__item",
|
|
4031
|
-
children: ["经度:",
|
|
4046
|
+
children: ["经度:", c.lng]
|
|
4032
4047
|
}), /* @__PURE__ */ jsxs("span", {
|
|
4033
4048
|
className: "mapbox-coordinate-display__item",
|
|
4034
|
-
children: ["纬度:",
|
|
4035
|
-
})]
|
|
4049
|
+
children: ["纬度:", c.lat]
|
|
4050
|
+
})] })
|
|
4036
4051
|
})]
|
|
4037
4052
|
}) : null;
|
|
4038
4053
|
}
|
|
@@ -4167,8 +4182,8 @@ function detectVectorSource(e) {
|
|
|
4167
4182
|
};
|
|
4168
4183
|
return null;
|
|
4169
4184
|
}
|
|
4170
|
-
function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u, classField: d = "class", className: f = "", style:
|
|
4171
|
-
let [
|
|
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 [h, g] = useState(!1), [_, v] = useState(i), [y, b] = useState(!1), x = useRef(!1), be = useRef(null), S = useRef(null), C = useRef(null), w = useCallback((e, t, n) => {
|
|
4172
4187
|
if (!e.isStyleLoaded() || !e.getSource(t)) return !1;
|
|
4173
4188
|
let i = !0;
|
|
4174
4189
|
return ROAD_TYPE_OPTIONS.forEach((a) => {
|
|
@@ -4204,13 +4219,13 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4204
4219
|
let r = detectVectorSource(e);
|
|
4205
4220
|
r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
|
|
4206
4221
|
}
|
|
4207
|
-
t && n ?
|
|
4222
|
+
t && n ? w(e, t, n) && (x.current = !0, b(!0)) : console.warn("No vector source found for road highlighting");
|
|
4208
4223
|
};
|
|
4209
4224
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4210
4225
|
let n = () => {
|
|
4211
4226
|
e.isStyleLoaded() && t();
|
|
4212
4227
|
}, r = () => {
|
|
4213
|
-
|
|
4228
|
+
x.current || t();
|
|
4214
4229
|
};
|
|
4215
4230
|
return e.on("styledata", n), e.on("sourcedata", r), () => {
|
|
4216
4231
|
e.off("styledata", n), e.off("sourcedata", r);
|
|
@@ -4219,12 +4234,12 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4219
4234
|
e,
|
|
4220
4235
|
l,
|
|
4221
4236
|
u,
|
|
4222
|
-
|
|
4237
|
+
w
|
|
4223
4238
|
]), useEffect(() => {
|
|
4224
|
-
!e || !
|
|
4239
|
+
!e || !y || ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
4225
4240
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
4226
4241
|
if (e.getLayer(n)) try {
|
|
4227
|
-
let r =
|
|
4242
|
+
let r = _.includes(t.class);
|
|
4228
4243
|
e.setLayoutProperty(n, "visibility", r ? "visible" : "none");
|
|
4229
4244
|
} catch (e) {
|
|
4230
4245
|
console.error(`Failed to update layer ${n}:`, e);
|
|
@@ -4232,128 +4247,128 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4232
4247
|
});
|
|
4233
4248
|
}, [
|
|
4234
4249
|
e,
|
|
4235
|
-
|
|
4236
|
-
|
|
4250
|
+
y,
|
|
4251
|
+
_
|
|
4237
4252
|
]), useEffect(() => {
|
|
4238
|
-
if (!
|
|
4253
|
+
if (!h) return;
|
|
4239
4254
|
let e = (e) => {
|
|
4240
|
-
|
|
4255
|
+
be.current && !be.current.contains(e.target) && S.current && !S.current.contains(e.target) && g(!1);
|
|
4241
4256
|
}, t = setTimeout(() => {
|
|
4242
4257
|
document.addEventListener("mousedown", e);
|
|
4243
4258
|
}, 0);
|
|
4244
4259
|
return () => {
|
|
4245
4260
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
4246
4261
|
};
|
|
4247
|
-
}, [
|
|
4262
|
+
}, [h]), useEffect(() => () => {
|
|
4248
4263
|
e && e.getStyle() && ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
4249
4264
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
4250
4265
|
if (e.getLayer(n)) try {
|
|
4251
4266
|
e.removeLayer(n);
|
|
4252
4267
|
} catch {}
|
|
4253
|
-
}),
|
|
4268
|
+
}), C.current &&= (C.current.remove(), null);
|
|
4254
4269
|
}, [e]);
|
|
4255
|
-
let
|
|
4256
|
-
if (!e ||
|
|
4257
|
-
|
|
4270
|
+
let T = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), xe = useCallback((t) => {
|
|
4271
|
+
if (!e || _.length === 0) {
|
|
4272
|
+
C.current && C.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
|
|
4258
4273
|
return;
|
|
4259
4274
|
}
|
|
4260
|
-
let n =
|
|
4275
|
+
let n = _.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)) });
|
|
4261
4276
|
if (i.length > 0) {
|
|
4262
|
-
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 || "", ve = n.iso_3166_2 || "",
|
|
4263
|
-
|
|
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 || "", ve = n.iso_3166_2 || "", ye = (e) => !(e == null || e === "" || typeof e == "string" && e.toLowerCase() === "none"), m = [];
|
|
4278
|
+
ye(o) && m.push(`
|
|
4264
4279
|
<div class="road-highlight-popup__row">
|
|
4265
4280
|
<span>道路类型:</span>
|
|
4266
|
-
<span class="road-highlight-popup__value">${
|
|
4281
|
+
<span class="road-highlight-popup__value">${T(o)}</span>
|
|
4267
4282
|
</div>
|
|
4268
|
-
`),
|
|
4283
|
+
`), m.push(`
|
|
4269
4284
|
<div class="road-highlight-popup__row">
|
|
4270
4285
|
<span>经度:</span>
|
|
4271
4286
|
<span class="road-highlight-popup__value">${r.lng.toFixed(6)}</span>
|
|
4272
4287
|
</div>
|
|
4273
|
-
`),
|
|
4288
|
+
`), m.push(`
|
|
4274
4289
|
<div class="road-highlight-popup__row">
|
|
4275
4290
|
<span>纬度:</span>
|
|
4276
4291
|
<span class="road-highlight-popup__value">${r.lat.toFixed(6)}</span>
|
|
4277
4292
|
</div>
|
|
4278
|
-
`),
|
|
4293
|
+
`), ye(c) && m.push(`
|
|
4279
4294
|
<div class="road-highlight-popup__row">
|
|
4280
4295
|
<span>类别:</span>
|
|
4281
4296
|
<span class="road-highlight-popup__value">${c}</span>
|
|
4282
4297
|
</div>
|
|
4283
|
-
`),
|
|
4298
|
+
`), ye(l) && m.push(`
|
|
4284
4299
|
<div class="road-highlight-popup__row">
|
|
4285
4300
|
<span>结构:</span>
|
|
4286
4301
|
<span class="road-highlight-popup__value">${l}</span>
|
|
4287
4302
|
</div>
|
|
4288
|
-
`), u != null && u !== "" &&
|
|
4303
|
+
`), u != null && u !== "" && m.push(`
|
|
4289
4304
|
<div class="road-highlight-popup__row">
|
|
4290
4305
|
<span>单行道:</span>
|
|
4291
4306
|
<span class="road-highlight-popup__value">${u ? "是" : "否"}</span>
|
|
4292
4307
|
</div>
|
|
4293
|
-
`),
|
|
4308
|
+
`), ye(f) && m.push(`
|
|
4294
4309
|
<div class="road-highlight-popup__row">
|
|
4295
4310
|
<span>层级:</span>
|
|
4296
4311
|
<span class="road-highlight-popup__value">${f}</span>
|
|
4297
4312
|
</div>
|
|
4298
|
-
`),
|
|
4313
|
+
`), ye(p) && m.push(`
|
|
4299
4314
|
<div class="road-highlight-popup__row">
|
|
4300
4315
|
<span>国家代码:</span>
|
|
4301
4316
|
<span class="road-highlight-popup__value">${p}</span>
|
|
4302
4317
|
</div>
|
|
4303
|
-
`),
|
|
4318
|
+
`), ye(ve) && m.push(`
|
|
4304
4319
|
<div class="road-highlight-popup__row">
|
|
4305
4320
|
<span>地区代码:</span>
|
|
4306
4321
|
<span class="road-highlight-popup__value">${ve}</span>
|
|
4307
4322
|
</div>
|
|
4308
4323
|
`);
|
|
4309
|
-
let
|
|
4324
|
+
let h = `
|
|
4310
4325
|
<div class="road-highlight-popup__content">
|
|
4311
4326
|
${a ? `<div class="road-highlight-popup__title">${a}</div>` : ""}
|
|
4312
|
-
<div class="road-highlight-popup__info">${
|
|
4327
|
+
<div class="road-highlight-popup__info">${m.join("")}</div>
|
|
4313
4328
|
</div>
|
|
4314
4329
|
`;
|
|
4315
|
-
|
|
4330
|
+
C.current ||= new mapboxgl.Popup({
|
|
4316
4331
|
closeButton: !1,
|
|
4317
4332
|
closeOnClick: !1,
|
|
4318
4333
|
offset: 15,
|
|
4319
4334
|
className: "road-highlight-popup"
|
|
4320
|
-
}),
|
|
4321
|
-
} else
|
|
4335
|
+
}), C.current.setLngLat(r).setHTML(h).addTo(e), e.getCanvas().style.cursor = "pointer";
|
|
4336
|
+
} else C.current && C.current.remove(), e.getCanvas().style.cursor = "";
|
|
4322
4337
|
}, [
|
|
4323
4338
|
e,
|
|
4324
|
-
|
|
4325
|
-
|
|
4339
|
+
_,
|
|
4340
|
+
T,
|
|
4326
4341
|
d
|
|
4327
4342
|
]);
|
|
4328
4343
|
useEffect(() => {
|
|
4329
|
-
if (!(!e || !
|
|
4330
|
-
e.off("mousemove", xe),
|
|
4344
|
+
if (!(!e || !y)) return e.on("mousemove", xe), () => {
|
|
4345
|
+
e.off("mousemove", xe), C.current && C.current.remove(), e.getCanvas().style.cursor = "";
|
|
4331
4346
|
};
|
|
4332
4347
|
}, [
|
|
4333
4348
|
e,
|
|
4334
|
-
|
|
4349
|
+
y,
|
|
4335
4350
|
xe
|
|
4336
4351
|
]);
|
|
4337
|
-
let
|
|
4338
|
-
|
|
4339
|
-
},
|
|
4340
|
-
|
|
4341
|
-
}, Ce =
|
|
4352
|
+
let Se = (e, t) => {
|
|
4353
|
+
v((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
4354
|
+
}, D = (e) => {
|
|
4355
|
+
v(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
|
|
4356
|
+
}, Ce = _.length > 0;
|
|
4342
4357
|
return /* @__PURE__ */ jsxs("div", {
|
|
4343
4358
|
className: `mapbox-road-highlight-control ${f}`,
|
|
4344
|
-
style:
|
|
4359
|
+
style: p,
|
|
4345
4360
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
4346
|
-
ref:
|
|
4361
|
+
ref: S,
|
|
4347
4362
|
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${Ce ? "mapbox-road-highlight-control__btn--active" : ""}`,
|
|
4348
|
-
onClick: () =>
|
|
4349
|
-
title: `路网高亮${
|
|
4363
|
+
onClick: () => g(!h),
|
|
4364
|
+
title: `路网高亮${_.length > 0 ? ` (已选 ${_.length})` : ""}`,
|
|
4350
4365
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4351
4366
|
src: road_default,
|
|
4352
4367
|
alt: "road",
|
|
4353
4368
|
className: "mapbox-road-highlight-control__btn-icon"
|
|
4354
|
-
}), /* @__PURE__ */ jsxs("span", { children: ["路网",
|
|
4355
|
-
}),
|
|
4356
|
-
ref:
|
|
4369
|
+
}), /* @__PURE__ */ jsxs("span", { children: ["路网", _.length > 0 ? ` (${_.length})` : ""] })]
|
|
4370
|
+
}), h && /* @__PURE__ */ jsxs("div", {
|
|
4371
|
+
ref: be,
|
|
4357
4372
|
className: "mapbox-road-highlight-control__panel",
|
|
4358
4373
|
children: [
|
|
4359
4374
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -4362,9 +4377,9 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4362
4377
|
className: "mapbox-road-highlight-control__panel-title",
|
|
4363
4378
|
children: "道路类型"
|
|
4364
4379
|
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
4365
|
-
checked:
|
|
4366
|
-
indeterminate:
|
|
4367
|
-
onChange:
|
|
4380
|
+
checked: _.length === ROAD_TYPE_OPTIONS.length,
|
|
4381
|
+
indeterminate: _.length > 0 && _.length < ROAD_TYPE_OPTIONS.length,
|
|
4382
|
+
onChange: D,
|
|
4368
4383
|
style: {
|
|
4369
4384
|
"--color-text-1": "#fff",
|
|
4370
4385
|
"--color-border-2": "rgba(255, 255, 255, 0.3)"
|
|
@@ -4381,11 +4396,11 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4381
4396
|
className: "mapbox-road-highlight-control__type-list",
|
|
4382
4397
|
children: ROAD_TYPE_OPTIONS.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
4383
4398
|
className: "mapbox-road-highlight-control__type-item",
|
|
4384
|
-
onClick: () =>
|
|
4399
|
+
onClick: () => Se(e.class, !_.includes(e.class)),
|
|
4385
4400
|
children: [
|
|
4386
4401
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4387
|
-
checked:
|
|
4388
|
-
onChange: (t) =>
|
|
4402
|
+
checked: _.includes(e.class),
|
|
4403
|
+
onChange: (t) => Se(e.class, t),
|
|
4389
4404
|
onClick: (e) => e.stopPropagation(),
|
|
4390
4405
|
style: {
|
|
4391
4406
|
"--color-text-1": "#fff",
|
|
@@ -4410,7 +4425,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4410
4425
|
className: "mapbox-road-highlight-control__tip",
|
|
4411
4426
|
children: "💡 选中道路类型后立即显示高亮"
|
|
4412
4427
|
}),
|
|
4413
|
-
!
|
|
4428
|
+
!y && /* @__PURE__ */ jsx("div", {
|
|
4414
4429
|
className: "mapbox-road-highlight-control__warning",
|
|
4415
4430
|
children: "⚠️ 正在初始化图层..."
|
|
4416
4431
|
})
|
|
@@ -4659,64 +4674,64 @@ function clearAllPreviewSources(e) {
|
|
|
4659
4674
|
]) clearPreviewSource(e, `${PREVIEW_PREFIX}${t}`);
|
|
4660
4675
|
}
|
|
4661
4676
|
function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDrawModeChange: s, className: c = "", style: l }) {
|
|
4662
|
-
let [u, d] = useState(!1), [f,
|
|
4677
|
+
let [u, d] = useState(!1), [f, p] = useState(null), [h, g] = useState({
|
|
4663
4678
|
showArea: !0,
|
|
4664
4679
|
showLength: !0,
|
|
4665
4680
|
showRadius: !0
|
|
4666
|
-
}),
|
|
4681
|
+
}), _ = r !== void 0, v = _ ? {
|
|
4667
4682
|
showArea: r.showArea ?? !0,
|
|
4668
4683
|
showLength: r.showLength ?? !0,
|
|
4669
4684
|
showRadius: r.showRadius ?? !0
|
|
4670
|
-
} :
|
|
4671
|
-
|
|
4672
|
-
let
|
|
4673
|
-
|
|
4674
|
-
let
|
|
4685
|
+
} : h, [y, b] = useState([]), x = useRef(/* @__PURE__ */ new Map()), be = useRef(0), C = useRef(null), w = useRef(null), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef([]), k = useRef([]), A = useRef(v);
|
|
4686
|
+
A.current = v;
|
|
4687
|
+
let Ee = useRef(f);
|
|
4688
|
+
Ee.current = f;
|
|
4689
|
+
let j = useCallback(() => `measure-${++be.current}`, []);
|
|
4675
4690
|
useEffect(() => {
|
|
4676
4691
|
s?.(f !== null);
|
|
4677
4692
|
}, [f, s]);
|
|
4678
|
-
let
|
|
4679
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
4693
|
+
let De = useRef(!1), Oe = useCallback(() => {
|
|
4694
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), De.current = !0);
|
|
4680
4695
|
}, [e]);
|
|
4681
4696
|
useEffect(() => {
|
|
4682
4697
|
if (!e) return;
|
|
4683
4698
|
let t = () => {
|
|
4684
|
-
initAllPreviewLayers(e),
|
|
4699
|
+
initAllPreviewLayers(e), De.current = !0;
|
|
4685
4700
|
};
|
|
4686
4701
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4687
4702
|
let n = () => {
|
|
4688
|
-
|
|
4703
|
+
De.current = !1;
|
|
4689
4704
|
};
|
|
4690
4705
|
return e.on("style.load", n), () => {
|
|
4691
4706
|
e.off("style.load", n);
|
|
4692
4707
|
};
|
|
4693
4708
|
}, [e]), useEffect(() => {
|
|
4694
4709
|
let e = (e) => {
|
|
4695
|
-
|
|
4710
|
+
C.current && !C.current.contains(e.target) && w.current && !w.current.contains(e.target) && d(!1);
|
|
4696
4711
|
};
|
|
4697
4712
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4698
4713
|
}, []);
|
|
4699
|
-
let
|
|
4714
|
+
let M = useCallback((t) => {
|
|
4700
4715
|
if (!e) return;
|
|
4701
|
-
let n = applyEntityConfig(t,
|
|
4716
|
+
let n = applyEntityConfig(t, A.current), r = null;
|
|
4702
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) {
|
|
4703
|
-
|
|
4718
|
+
x.current.set(n.id, r);
|
|
4704
4719
|
let e = {
|
|
4705
4720
|
entity: n,
|
|
4706
4721
|
shapeLabel: SHAPE_LABELS[n.type] || n.type,
|
|
4707
4722
|
area: computeEntityArea(n),
|
|
4708
4723
|
lengthOrRadius: computeEntityLengthOrRadius(n)
|
|
4709
4724
|
};
|
|
4710
|
-
|
|
4711
|
-
}
|
|
4712
|
-
}, [e]),
|
|
4713
|
-
let t =
|
|
4714
|
-
t && (t.destroy(),
|
|
4715
|
-
}, []),
|
|
4716
|
-
|
|
4717
|
-
}, []),
|
|
4725
|
+
b((t) => [...t, e]);
|
|
4726
|
+
}
|
|
4727
|
+
}, [e]), ke = useCallback((e) => {
|
|
4728
|
+
let t = x.current.get(e);
|
|
4729
|
+
t && (t.destroy(), x.current.delete(e)), b((t) => t.filter((t) => t.entity.id !== e));
|
|
4730
|
+
}, []), Ae = useCallback(() => {
|
|
4731
|
+
x.current.forEach((e) => e.destroy()), x.current.clear(), b([]);
|
|
4732
|
+
}, []), je = useCallback((t) => {
|
|
4718
4733
|
if (!e) return;
|
|
4719
|
-
let n =
|
|
4734
|
+
let n = x.current.get(t);
|
|
4720
4735
|
if (!n) return;
|
|
4721
4736
|
let r = n.getBounds();
|
|
4722
4737
|
e.fitBounds(r, {
|
|
@@ -4724,21 +4739,21 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4724
4739
|
maxZoom: 18,
|
|
4725
4740
|
duration: 1e3
|
|
4726
4741
|
});
|
|
4727
|
-
}, [e]),
|
|
4742
|
+
}, [e]), Me = useCallback((e, t) => {
|
|
4728
4743
|
let n = {
|
|
4729
|
-
...
|
|
4744
|
+
...A.current,
|
|
4730
4745
|
[e]: t
|
|
4731
4746
|
};
|
|
4732
|
-
|
|
4747
|
+
_ ? i?.({ ...n }) : g(n), b((t) => t.map((t) => {
|
|
4733
4748
|
let r = { ...t.entity };
|
|
4734
4749
|
r[e] = void 0;
|
|
4735
|
-
let i = applyEntityConfig(r, n), a =
|
|
4750
|
+
let i = applyEntityConfig(r, n), a = x.current.get(t.entity.id);
|
|
4736
4751
|
return a && a.update(i), {
|
|
4737
4752
|
...t,
|
|
4738
4753
|
entity: i
|
|
4739
4754
|
};
|
|
4740
4755
|
}));
|
|
4741
|
-
}, [
|
|
4756
|
+
}, [_, i]), Ne = useCallback((t, n) => {
|
|
4742
4757
|
if (!e) return;
|
|
4743
4758
|
let [r, i] = t, [a, o] = n, s = [
|
|
4744
4759
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -4757,7 +4772,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4757
4772
|
});
|
|
4758
4773
|
let l = e.getSource(`${PREVIEW_PREFIX}rect-preview-measure-source`);
|
|
4759
4774
|
if (l) {
|
|
4760
|
-
let e =
|
|
4775
|
+
let e = A.current, t = [], n = s[0], r = s[1], i = s[2];
|
|
4761
4776
|
if (e?.showArea) {
|
|
4762
4777
|
let e = distance(n, r), a = distance(r, i);
|
|
4763
4778
|
t.push({
|
|
@@ -4788,7 +4803,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4788
4803
|
features: t
|
|
4789
4804
|
});
|
|
4790
4805
|
}
|
|
4791
|
-
}, [e]),
|
|
4806
|
+
}, [e]), Pe = useCallback((t, n) => {
|
|
4792
4807
|
if (!e) return;
|
|
4793
4808
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
4794
4809
|
a && a.setData({
|
|
@@ -4799,7 +4814,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4799
4814
|
},
|
|
4800
4815
|
properties: {}
|
|
4801
4816
|
});
|
|
4802
|
-
let o =
|
|
4817
|
+
let o = A.current, s = [], c = [];
|
|
4803
4818
|
if (o?.showArea && s.push({
|
|
4804
4819
|
type: "Feature",
|
|
4805
4820
|
geometry: {
|
|
@@ -4835,7 +4850,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4835
4850
|
type: "FeatureCollection",
|
|
4836
4851
|
features: c
|
|
4837
4852
|
});
|
|
4838
|
-
}, [e]),
|
|
4853
|
+
}, [e]), Fe = useCallback((t, n) => {
|
|
4839
4854
|
if (!e) return;
|
|
4840
4855
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
4841
4856
|
a && a.setData({
|
|
@@ -4848,7 +4863,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4848
4863
|
});
|
|
4849
4864
|
let o = e.getSource(`${PREVIEW_PREFIX}square-preview-measure-source`);
|
|
4850
4865
|
if (o) {
|
|
4851
|
-
let e =
|
|
4866
|
+
let e = A.current, n = [];
|
|
4852
4867
|
if (e?.showArea && n.push({
|
|
4853
4868
|
type: "Feature",
|
|
4854
4869
|
geometry: {
|
|
@@ -4872,7 +4887,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4872
4887
|
features: n
|
|
4873
4888
|
});
|
|
4874
4889
|
}
|
|
4875
|
-
}, [e]),
|
|
4890
|
+
}, [e]), N = useCallback((t, n) => {
|
|
4876
4891
|
if (!e) return;
|
|
4877
4892
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
4878
4893
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -4907,7 +4922,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4907
4922
|
});
|
|
4908
4923
|
let o = e.getSource(`${PREVIEW_PREFIX}polygon-preview-measure-source`);
|
|
4909
4924
|
if (o) {
|
|
4910
|
-
let e =
|
|
4925
|
+
let e = A.current, t = [];
|
|
4911
4926
|
if (e?.showArea && r.length >= 3) {
|
|
4912
4927
|
let e = polygonArea([...r, r[0]]), n = 0, i = 0;
|
|
4913
4928
|
for (let e of r) n += e[0], i += e[1];
|
|
@@ -4949,7 +4964,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4949
4964
|
features: t
|
|
4950
4965
|
});
|
|
4951
4966
|
}
|
|
4952
|
-
}, [e]),
|
|
4967
|
+
}, [e]), Ie = useCallback((t, n) => {
|
|
4953
4968
|
if (!e) return;
|
|
4954
4969
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
4955
4970
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -4977,7 +4992,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4977
4992
|
});
|
|
4978
4993
|
let o = e.getSource(`${PREVIEW_PREFIX}polyline-preview-measure-source`);
|
|
4979
4994
|
if (o) {
|
|
4980
|
-
let e =
|
|
4995
|
+
let e = A.current, t = [];
|
|
4981
4996
|
if (e?.showLength && r.length >= 2) for (let e = 0; e < r.length - 1; e++) {
|
|
4982
4997
|
let n = r[e], i = r[e + 1];
|
|
4983
4998
|
t.push({
|
|
@@ -4997,117 +5012,117 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4997
5012
|
}, [e]);
|
|
4998
5013
|
useEffect(() => {
|
|
4999
5014
|
if (!e || !f) return;
|
|
5000
|
-
|
|
5015
|
+
Oe(), e.getCanvas().style.cursor = "crosshair";
|
|
5001
5016
|
let t = (t) => {
|
|
5002
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
5017
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = Ee.current;
|
|
5003
5018
|
if (r === "rectangle") {
|
|
5004
|
-
let t =
|
|
5005
|
-
if (!t)
|
|
5019
|
+
let t = T.current;
|
|
5020
|
+
if (!t) T.current = n;
|
|
5006
5021
|
else {
|
|
5007
5022
|
let r = {
|
|
5008
|
-
id:
|
|
5023
|
+
id: j(),
|
|
5009
5024
|
type: "rectangle",
|
|
5010
5025
|
bounds: [t, n]
|
|
5011
5026
|
};
|
|
5012
|
-
|
|
5027
|
+
M(r), T.current = null, clearAllPreviewSources(e), p(null);
|
|
5013
5028
|
}
|
|
5014
5029
|
} else if (r === "circle") {
|
|
5015
|
-
let t =
|
|
5016
|
-
if (!t)
|
|
5030
|
+
let t = E.current;
|
|
5031
|
+
if (!t) E.current = { center: n };
|
|
5017
5032
|
else {
|
|
5018
5033
|
let r = calculateDistance(t.center, n), i = {
|
|
5019
|
-
id:
|
|
5034
|
+
id: j(),
|
|
5020
5035
|
type: "circle",
|
|
5021
5036
|
center: t.center,
|
|
5022
5037
|
radius: r
|
|
5023
5038
|
};
|
|
5024
|
-
|
|
5039
|
+
M(i), E.current = null, clearAllPreviewSources(e), p(null);
|
|
5025
5040
|
}
|
|
5026
5041
|
} else if (r === "square") {
|
|
5027
|
-
let t =
|
|
5028
|
-
if (!t)
|
|
5042
|
+
let t = D.current;
|
|
5043
|
+
if (!t) D.current = { center: n };
|
|
5029
5044
|
else {
|
|
5030
5045
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
5031
|
-
id:
|
|
5046
|
+
id: j(),
|
|
5032
5047
|
type: "square",
|
|
5033
5048
|
center: t.center,
|
|
5034
5049
|
length: r
|
|
5035
5050
|
};
|
|
5036
|
-
|
|
5051
|
+
M(i), D.current = null, clearAllPreviewSources(e), p(null);
|
|
5037
5052
|
}
|
|
5038
5053
|
} else if (r === "polygon") {
|
|
5039
|
-
let t =
|
|
5054
|
+
let t = O.current;
|
|
5040
5055
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
5041
5056
|
let n = {
|
|
5042
|
-
id:
|
|
5057
|
+
id: j(),
|
|
5043
5058
|
type: "polygon",
|
|
5044
5059
|
coordinates: [...t]
|
|
5045
5060
|
};
|
|
5046
|
-
|
|
5061
|
+
M(n), O.current = [], clearAllPreviewSources(e), p(null);
|
|
5047
5062
|
return;
|
|
5048
5063
|
}
|
|
5049
|
-
|
|
5050
|
-
} else r === "polyline" && (
|
|
5064
|
+
O.current = [...t, n];
|
|
5065
|
+
} else r === "polyline" && (k.current = [...k.current, n]);
|
|
5051
5066
|
}, n = (e) => {
|
|
5052
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5053
|
-
if (n === "rectangle" &&
|
|
5054
|
-
else if (n === "circle" &&
|
|
5055
|
-
else if (n === "square" &&
|
|
5067
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = Ee.current;
|
|
5068
|
+
if (n === "rectangle" && T.current) Ne(T.current, t);
|
|
5069
|
+
else if (n === "circle" && E.current) Pe(E.current.center, t);
|
|
5070
|
+
else if (n === "square" && D.current) Fe(D.current.center, t);
|
|
5056
5071
|
else if (n === "polygon") {
|
|
5057
|
-
let e =
|
|
5058
|
-
e.length > 0 &&
|
|
5072
|
+
let e = O.current;
|
|
5073
|
+
e.length > 0 && N(e, t);
|
|
5059
5074
|
} else if (n === "polyline") {
|
|
5060
|
-
let e =
|
|
5061
|
-
e.length > 0 &&
|
|
5075
|
+
let e = k.current;
|
|
5076
|
+
e.length > 0 && Ie(e, t);
|
|
5062
5077
|
}
|
|
5063
5078
|
}, r = (t) => {
|
|
5064
5079
|
t.preventDefault();
|
|
5065
|
-
let n =
|
|
5080
|
+
let n = Ee.current;
|
|
5066
5081
|
if (n === "polygon") {
|
|
5067
|
-
let t =
|
|
5082
|
+
let t = O.current;
|
|
5068
5083
|
if (t.length >= 3) {
|
|
5069
5084
|
let n = {
|
|
5070
|
-
id:
|
|
5085
|
+
id: j(),
|
|
5071
5086
|
type: "polygon",
|
|
5072
5087
|
coordinates: [...t]
|
|
5073
5088
|
};
|
|
5074
|
-
|
|
5075
|
-
} else
|
|
5089
|
+
M(n), O.current = [], clearAllPreviewSources(e), p(null);
|
|
5090
|
+
} else O.current = [], clearAllPreviewSources(e);
|
|
5076
5091
|
} else if (n === "polyline") {
|
|
5077
|
-
let t =
|
|
5092
|
+
let t = k.current;
|
|
5078
5093
|
if (t.length >= 2) {
|
|
5079
5094
|
let n = {
|
|
5080
|
-
id:
|
|
5095
|
+
id: j(),
|
|
5081
5096
|
type: "polyline",
|
|
5082
5097
|
coordinates: [...t]
|
|
5083
5098
|
};
|
|
5084
|
-
|
|
5085
|
-
} else
|
|
5099
|
+
M(n), k.current = [], clearAllPreviewSources(e), p(null);
|
|
5100
|
+
} else k.current = [], clearAllPreviewSources(e);
|
|
5086
5101
|
}
|
|
5087
5102
|
}, i = (t) => {
|
|
5088
|
-
t.key === "Escape" && (
|
|
5103
|
+
t.key === "Escape" && (T.current = null, E.current = null, D.current = null, O.current = [], k.current = [], clearAllPreviewSources(e), p(null));
|
|
5089
5104
|
}, a = (t) => {
|
|
5090
5105
|
t.preventDefault();
|
|
5091
|
-
let n =
|
|
5106
|
+
let n = Ee.current;
|
|
5092
5107
|
if (n === "polygon") {
|
|
5093
|
-
let t =
|
|
5108
|
+
let t = O.current;
|
|
5094
5109
|
if (t.length >= 3) {
|
|
5095
5110
|
let n = {
|
|
5096
|
-
id:
|
|
5111
|
+
id: j(),
|
|
5097
5112
|
type: "polygon",
|
|
5098
5113
|
coordinates: [...t]
|
|
5099
5114
|
};
|
|
5100
|
-
|
|
5115
|
+
M(n), O.current = [], clearAllPreviewSources(e), p(null);
|
|
5101
5116
|
}
|
|
5102
5117
|
} else if (n === "polyline") {
|
|
5103
|
-
let t =
|
|
5118
|
+
let t = k.current;
|
|
5104
5119
|
if (t.length >= 2) {
|
|
5105
5120
|
let n = {
|
|
5106
|
-
id:
|
|
5121
|
+
id: j(),
|
|
5107
5122
|
type: "polyline",
|
|
5108
5123
|
coordinates: [...t]
|
|
5109
5124
|
};
|
|
5110
|
-
|
|
5125
|
+
M(n), k.current = [], clearAllPreviewSources(e), p(null);
|
|
5111
5126
|
}
|
|
5112
5127
|
}
|
|
5113
5128
|
};
|
|
@@ -5117,25 +5132,25 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5117
5132
|
}, [
|
|
5118
5133
|
e,
|
|
5119
5134
|
f,
|
|
5135
|
+
j,
|
|
5120
5136
|
M,
|
|
5121
|
-
|
|
5122
|
-
De,
|
|
5123
|
-
Me,
|
|
5137
|
+
Oe,
|
|
5124
5138
|
Ne,
|
|
5125
5139
|
Pe,
|
|
5126
5140
|
Fe,
|
|
5127
|
-
|
|
5141
|
+
N,
|
|
5142
|
+
Ie
|
|
5128
5143
|
]), useEffect(() => () => {
|
|
5129
|
-
|
|
5144
|
+
x.current.forEach((e) => e.destroy()), x.current.clear();
|
|
5130
5145
|
}, []);
|
|
5131
|
-
let
|
|
5132
|
-
|
|
5146
|
+
let Le = useCallback((t) => {
|
|
5147
|
+
p((e) => e === t ? null : t), T.current = null, E.current = null, D.current = null, O.current = [], k.current = [], e && clearAllPreviewSources(e);
|
|
5133
5148
|
}, [e]);
|
|
5134
5149
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
5135
5150
|
className: `mapbox-measure-control ${c}`,
|
|
5136
5151
|
style: l,
|
|
5137
5152
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5138
|
-
ref:
|
|
5153
|
+
ref: w,
|
|
5139
5154
|
className: `mapbox-control-btn mapbox-measure-control__btn ${u ? "mapbox-measure-control__btn--active" : ""}`,
|
|
5140
5155
|
onClick: () => d(!u),
|
|
5141
5156
|
title: "测量",
|
|
@@ -5146,14 +5161,14 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5146
5161
|
className: "mapbox-measure-control__btn-icon"
|
|
5147
5162
|
}),
|
|
5148
5163
|
/* @__PURE__ */ jsx("span", { children: "测量" }),
|
|
5149
|
-
|
|
5164
|
+
y.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
5150
5165
|
"(",
|
|
5151
|
-
|
|
5166
|
+
y.length,
|
|
5152
5167
|
")"
|
|
5153
5168
|
] })
|
|
5154
5169
|
]
|
|
5155
5170
|
}), u && /* @__PURE__ */ jsxs("div", {
|
|
5156
|
-
ref:
|
|
5171
|
+
ref: C,
|
|
5157
5172
|
className: "mapbox-measure-control__panel",
|
|
5158
5173
|
children: [
|
|
5159
5174
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -5164,18 +5179,18 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5164
5179
|
className: "mapbox-measure-control__settings",
|
|
5165
5180
|
children: [
|
|
5166
5181
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5167
|
-
checked:
|
|
5168
|
-
onChange: (e) =>
|
|
5182
|
+
checked: v.showArea,
|
|
5183
|
+
onChange: (e) => Me("showArea", e),
|
|
5169
5184
|
children: "面积"
|
|
5170
5185
|
}),
|
|
5171
5186
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5172
|
-
checked:
|
|
5173
|
-
onChange: (e) =>
|
|
5187
|
+
checked: v.showLength,
|
|
5188
|
+
onChange: (e) => Me("showLength", e),
|
|
5174
5189
|
children: "长度"
|
|
5175
5190
|
}),
|
|
5176
5191
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5177
|
-
checked:
|
|
5178
|
-
onChange: (e) =>
|
|
5192
|
+
checked: v.showRadius,
|
|
5193
|
+
onChange: (e) => Me("showRadius", e),
|
|
5179
5194
|
children: "半径"
|
|
5180
5195
|
})
|
|
5181
5196
|
]
|
|
@@ -5188,15 +5203,15 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5188
5203
|
className: "mapbox-measure-control__tools",
|
|
5189
5204
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
5190
5205
|
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5191
|
-
onClick: () =>
|
|
5206
|
+
onClick: () => Le(e.mode),
|
|
5192
5207
|
title: e.label,
|
|
5193
5208
|
children: /* @__PURE__ */ jsx("img", {
|
|
5194
5209
|
src: e.icon,
|
|
5195
5210
|
alt: e.label
|
|
5196
5211
|
})
|
|
5197
|
-
}, e.mode)),
|
|
5212
|
+
}, e.mode)), y.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
5198
5213
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
5199
|
-
onClick:
|
|
5214
|
+
onClick: Ae,
|
|
5200
5215
|
title: "清除全部",
|
|
5201
5216
|
children: /* @__PURE__ */ jsx("img", {
|
|
5202
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",
|
|
@@ -5204,7 +5219,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5204
5219
|
})
|
|
5205
5220
|
})]
|
|
5206
5221
|
}),
|
|
5207
|
-
|
|
5222
|
+
y.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
5208
5223
|
className: "mapbox-measure-control__list",
|
|
5209
5224
|
children: /* @__PURE__ */ jsxs("table", {
|
|
5210
5225
|
className: "mapbox-measure-control__table",
|
|
@@ -5214,9 +5229,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5214
5229
|
/* @__PURE__ */ jsx("th", { children: "面积" }),
|
|
5215
5230
|
/* @__PURE__ */ jsx("th", { children: "长度/半径" }),
|
|
5216
5231
|
/* @__PURE__ */ jsx("th", {})
|
|
5217
|
-
] }) }), /* @__PURE__ */ jsx("tbody", { children:
|
|
5232
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: y.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
5218
5233
|
className: "mapbox-measure-control__table-row",
|
|
5219
|
-
onClick: () =>
|
|
5234
|
+
onClick: () => je(e.entity.id),
|
|
5220
5235
|
children: [
|
|
5221
5236
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
5222
5237
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -5225,7 +5240,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5225
5240
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
5226
5241
|
className: "mapbox-measure-control__delete-btn",
|
|
5227
5242
|
onClick: (t) => {
|
|
5228
|
-
t.stopPropagation(),
|
|
5243
|
+
t.stopPropagation(), ke(e.entity.id);
|
|
5229
5244
|
},
|
|
5230
5245
|
title: "删除",
|
|
5231
5246
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -5280,67 +5295,67 @@ var raster_paint_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standal
|
|
|
5280
5295
|
}
|
|
5281
5296
|
];
|
|
5282
5297
|
function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds: c = [], className: l, style: u }) {
|
|
5283
|
-
let [d, f] = useState(!1), [
|
|
5298
|
+
let [d, f] = useState(!1), [p, m] = useState({ ...DEFAULT_CONFIG }), g = useRef(null), _ = useRef(null), v = r !== void 0;
|
|
5284
5299
|
useEffect(() => {
|
|
5285
5300
|
let e = (e) => {
|
|
5286
|
-
|
|
5301
|
+
g.current && !g.current.contains(e.target) && _.current && !_.current.contains(e.target) && f(!1);
|
|
5287
5302
|
};
|
|
5288
5303
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
5289
5304
|
}, []);
|
|
5290
|
-
let
|
|
5305
|
+
let y = useMemo(() => v ? {
|
|
5291
5306
|
brightness: r.brightness ?? DEFAULT_CONFIG.brightness,
|
|
5292
5307
|
saturation: r.saturation ?? DEFAULT_CONFIG.saturation,
|
|
5293
5308
|
contrast: r.contrast ?? DEFAULT_CONFIG.contrast,
|
|
5294
5309
|
hueRotate: r.hueRotate ?? DEFAULT_CONFIG.hueRotate
|
|
5295
|
-
} :
|
|
5296
|
-
|
|
5310
|
+
} : p, [
|
|
5311
|
+
v,
|
|
5297
5312
|
r,
|
|
5298
|
-
|
|
5299
|
-
]),
|
|
5313
|
+
p
|
|
5314
|
+
]), b = useRef(v);
|
|
5300
5315
|
useEffect(() => {
|
|
5301
|
-
|
|
5302
|
-
}, [
|
|
5303
|
-
let
|
|
5316
|
+
v && !b.current && m({ ...y }), b.current = v;
|
|
5317
|
+
}, [v, y]);
|
|
5318
|
+
let x = useCallback((t) => {
|
|
5304
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));
|
|
5305
|
-
}, [e, c]),
|
|
5306
|
-
if (
|
|
5307
|
-
...
|
|
5320
|
+
}, [e, c]), be = useCallback((e, t) => {
|
|
5321
|
+
if (v) s?.({
|
|
5322
|
+
...y,
|
|
5308
5323
|
[e]: t
|
|
5309
5324
|
});
|
|
5310
5325
|
else {
|
|
5311
5326
|
let n = {
|
|
5312
|
-
...
|
|
5327
|
+
...p,
|
|
5313
5328
|
[e]: t
|
|
5314
5329
|
};
|
|
5315
|
-
|
|
5330
|
+
m(n), x(n);
|
|
5316
5331
|
}
|
|
5317
5332
|
}, [
|
|
5318
|
-
|
|
5333
|
+
v,
|
|
5319
5334
|
s,
|
|
5320
|
-
b,
|
|
5321
|
-
m,
|
|
5322
|
-
S
|
|
5323
|
-
]), C = useCallback(() => {
|
|
5324
|
-
y ? s?.({ ...DEFAULT_CONFIG }) : (g({ ...DEFAULT_CONFIG }), S({ ...DEFAULT_CONFIG }));
|
|
5325
|
-
}, [
|
|
5326
5335
|
y,
|
|
5336
|
+
p,
|
|
5337
|
+
x
|
|
5338
|
+
]), S = useCallback(() => {
|
|
5339
|
+
v ? s?.({ ...DEFAULT_CONFIG }) : (m({ ...DEFAULT_CONFIG }), x({ ...DEFAULT_CONFIG }));
|
|
5340
|
+
}, [
|
|
5341
|
+
v,
|
|
5327
5342
|
s,
|
|
5328
|
-
|
|
5343
|
+
x
|
|
5329
5344
|
]);
|
|
5330
5345
|
useEffect(() => {
|
|
5331
|
-
!
|
|
5346
|
+
!v && c.length > 0 && x(p);
|
|
5332
5347
|
}, [
|
|
5333
5348
|
c,
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5349
|
+
v,
|
|
5350
|
+
x,
|
|
5351
|
+
p
|
|
5337
5352
|
]);
|
|
5338
|
-
let
|
|
5353
|
+
let C = (e, t) => e === "hueRotate" ? `${Math.round(t)}°` : t.toFixed(2);
|
|
5339
5354
|
return /* @__PURE__ */ jsxs("div", {
|
|
5340
5355
|
className: `mapbox-raster-paint-control${l ? ` ${l}` : ""}`,
|
|
5341
5356
|
style: u,
|
|
5342
5357
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5343
|
-
ref:
|
|
5358
|
+
ref: _,
|
|
5344
5359
|
className: `mapbox-control-btn mapbox-raster-paint-control__btn${d ? " mapbox-raster-paint-control__btn--active" : ""}`,
|
|
5345
5360
|
onClick: () => f(!d),
|
|
5346
5361
|
title: "栅格渲染调节",
|
|
@@ -5350,7 +5365,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5350
5365
|
alt: "raster paint"
|
|
5351
5366
|
}), /* @__PURE__ */ jsx("span", { children: "渲染" })]
|
|
5352
5367
|
}), d && /* @__PURE__ */ jsxs("div", {
|
|
5353
|
-
ref:
|
|
5368
|
+
ref: g,
|
|
5354
5369
|
className: "mapbox-raster-paint-control__panel",
|
|
5355
5370
|
children: [SLIDER_CONFIG.map(({ key: e, label: t, min: n, max: r, step: i }) => /* @__PURE__ */ jsxs("div", {
|
|
5356
5371
|
className: "mapbox-raster-paint-control__slider-row",
|
|
@@ -5364,18 +5379,18 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5364
5379
|
min: n,
|
|
5365
5380
|
max: r,
|
|
5366
5381
|
step: i,
|
|
5367
|
-
value:
|
|
5368
|
-
onChange: (t) =>
|
|
5382
|
+
value: y[e],
|
|
5383
|
+
onChange: (t) => be(e, t),
|
|
5369
5384
|
tooltipVisible: !1
|
|
5370
5385
|
}),
|
|
5371
5386
|
/* @__PURE__ */ jsx("span", {
|
|
5372
5387
|
className: "mapbox-raster-paint-control__value",
|
|
5373
|
-
children:
|
|
5388
|
+
children: C(e, y[e])
|
|
5374
5389
|
})
|
|
5375
5390
|
]
|
|
5376
5391
|
}, e)), /* @__PURE__ */ jsx("button", {
|
|
5377
5392
|
className: "mapbox-raster-paint-control__reset",
|
|
5378
|
-
onClick:
|
|
5393
|
+
onClick: S,
|
|
5379
5394
|
children: "重置"
|
|
5380
5395
|
})]
|
|
5381
5396
|
})]
|
|
@@ -5383,43 +5398,43 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5383
5398
|
}
|
|
5384
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";
|
|
5385
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 }) => {
|
|
5386
|
-
let [
|
|
5401
|
+
let [p, m] = useState(!1), h = useRef(null);
|
|
5387
5402
|
useEffect(() => {
|
|
5388
5403
|
let e = (e) => {
|
|
5389
|
-
|
|
5404
|
+
h.current && !h.current.contains(e.target) && m(!1);
|
|
5390
5405
|
};
|
|
5391
|
-
if (
|
|
5392
|
-
}, [
|
|
5393
|
-
let
|
|
5394
|
-
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")),
|
|
5395
|
-
},
|
|
5406
|
+
if (p) return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
5407
|
+
}, [p]);
|
|
5408
|
+
let g = (e) => {
|
|
5409
|
+
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")), m(!1);
|
|
5410
|
+
}, _ = () => {
|
|
5396
5411
|
i === "rectangle" ? s(null) : (r(null), s("rectangle"));
|
|
5397
|
-
},
|
|
5412
|
+
}, v = () => {
|
|
5398
5413
|
i === "circle" ? s(null) : (r(null), s("circle"));
|
|
5399
|
-
},
|
|
5414
|
+
}, y = () => {
|
|
5400
5415
|
i === "polygon" ? s(null) : (r(null), s("polygon"));
|
|
5401
|
-
},
|
|
5416
|
+
}, b = () => {
|
|
5402
5417
|
i === "square" ? s(null) : (r(null), s("square"));
|
|
5403
|
-
},
|
|
5418
|
+
}, x = () => {
|
|
5404
5419
|
i === "polyline" ? s(null) : (r(null), s("polyline"));
|
|
5405
|
-
},
|
|
5406
|
-
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null),
|
|
5407
|
-
},
|
|
5420
|
+
}, be = () => {
|
|
5421
|
+
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), m(!p);
|
|
5422
|
+
}, S = (e) => e.size ? {
|
|
5408
5423
|
width: e.size,
|
|
5409
5424
|
height: e.size
|
|
5410
5425
|
} : {
|
|
5411
5426
|
width: e.width || 32,
|
|
5412
5427
|
height: e.height || 32
|
|
5413
|
-
},
|
|
5428
|
+
}, C = p || t, w = i === "rectangle", T = i === "circle", E = i === "polygon", xe = i === "square", Se = i === "polyline";
|
|
5414
5429
|
return /* @__PURE__ */ jsxs("div", {
|
|
5415
|
-
ref:
|
|
5430
|
+
ref: h,
|
|
5416
5431
|
className: "mapbox-edit-control",
|
|
5417
5432
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
5418
5433
|
className: "mapbox-edit-control__btn-group",
|
|
5419
5434
|
children: [
|
|
5420
5435
|
/* @__PURE__ */ jsxs("button", {
|
|
5421
|
-
className: `mapbox-control-btn ${
|
|
5422
|
-
onClick:
|
|
5436
|
+
className: `mapbox-control-btn ${C ? "mapbox-control-btn--active" : ""}`,
|
|
5437
|
+
onClick: be,
|
|
5423
5438
|
title: "Marker",
|
|
5424
5439
|
children: [t ? /* @__PURE__ */ jsx("img", {
|
|
5425
5440
|
src: t.icon,
|
|
@@ -5433,7 +5448,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5433
5448
|
}),
|
|
5434
5449
|
d && /* @__PURE__ */ jsxs("button", {
|
|
5435
5450
|
className: `mapbox-control-btn ${xe ? "mapbox-control-btn--active" : ""}`,
|
|
5436
|
-
onClick:
|
|
5451
|
+
onClick: b,
|
|
5437
5452
|
title: "绘制正方形",
|
|
5438
5453
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5439
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",
|
|
@@ -5442,8 +5457,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5442
5457
|
}), /* @__PURE__ */ jsx("span", { children: "正方形" })]
|
|
5443
5458
|
}),
|
|
5444
5459
|
c && /* @__PURE__ */ jsxs("button", {
|
|
5445
|
-
className: `mapbox-control-btn ${
|
|
5446
|
-
onClick:
|
|
5460
|
+
className: `mapbox-control-btn ${w ? "mapbox-control-btn--active" : ""}`,
|
|
5461
|
+
onClick: _,
|
|
5447
5462
|
title: "绘制矩形",
|
|
5448
5463
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5449
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",
|
|
@@ -5452,8 +5467,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5452
5467
|
}), /* @__PURE__ */ jsx("span", { children: "矩形" })]
|
|
5453
5468
|
}),
|
|
5454
5469
|
l && /* @__PURE__ */ jsxs("button", {
|
|
5455
|
-
className: `mapbox-control-btn ${
|
|
5456
|
-
onClick:
|
|
5470
|
+
className: `mapbox-control-btn ${T ? "mapbox-control-btn--active" : ""}`,
|
|
5471
|
+
onClick: v,
|
|
5457
5472
|
title: "绘制圆形",
|
|
5458
5473
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5459
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",
|
|
@@ -5462,8 +5477,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5462
5477
|
}), /* @__PURE__ */ jsx("span", { children: "圆形" })]
|
|
5463
5478
|
}),
|
|
5464
5479
|
u && /* @__PURE__ */ jsxs("button", {
|
|
5465
|
-
className: `mapbox-control-btn ${
|
|
5466
|
-
onClick:
|
|
5480
|
+
className: `mapbox-control-btn ${E ? "mapbox-control-btn--active" : ""}`,
|
|
5481
|
+
onClick: y,
|
|
5467
5482
|
title: "绘制多边形",
|
|
5468
5483
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5469
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",
|
|
@@ -5472,8 +5487,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5472
5487
|
}), /* @__PURE__ */ jsx("span", { children: "多边形" })]
|
|
5473
5488
|
}),
|
|
5474
5489
|
f && /* @__PURE__ */ jsxs("button", {
|
|
5475
|
-
className: `mapbox-control-btn ${
|
|
5476
|
-
onClick:
|
|
5490
|
+
className: `mapbox-control-btn ${Se ? "mapbox-control-btn--active" : ""}`,
|
|
5491
|
+
onClick: x,
|
|
5477
5492
|
title: "绘制折线",
|
|
5478
5493
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5479
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",
|
|
@@ -5482,7 +5497,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5482
5497
|
}), /* @__PURE__ */ jsx("span", { children: "折线" })]
|
|
5483
5498
|
})
|
|
5484
5499
|
]
|
|
5485
|
-
}),
|
|
5500
|
+
}), p && /* @__PURE__ */ jsxs("div", {
|
|
5486
5501
|
className: "mapbox-edit-control__panel",
|
|
5487
5502
|
children: [/* @__PURE__ */ jsx("div", {
|
|
5488
5503
|
className: "mapbox-edit-control__panel-header",
|
|
@@ -5490,10 +5505,10 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5490
5505
|
}), /* @__PURE__ */ jsx("div", {
|
|
5491
5506
|
className: "mapbox-edit-control__template-list",
|
|
5492
5507
|
children: e.map((e) => {
|
|
5493
|
-
let n =
|
|
5508
|
+
let n = S(e), r = t?.id === e.id;
|
|
5494
5509
|
return /* @__PURE__ */ jsxs("div", {
|
|
5495
5510
|
className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
|
|
5496
|
-
onClick: () =>
|
|
5511
|
+
onClick: () => g(e),
|
|
5497
5512
|
title: e.name,
|
|
5498
5513
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5499
5514
|
src: e.icon,
|
|
@@ -5562,28 +5577,28 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5562
5577
|
};
|
|
5563
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";
|
|
5564
5579
|
const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointCountInput: c = !1, visualType: l = "marker", onSelectFinished: u, showButton: d = !0 }, f) => {
|
|
5565
|
-
let [
|
|
5580
|
+
let [p, m] = useState("idle"), [h, g] = useState(0), [_, v] = useState(i), [y, b] = useState(!1), x = useRef(null), be = useRef(null), S = useRef([]), C = useRef([]), w = useRef("idle"), T = useRef(null), E = useRef("");
|
|
5566
5581
|
useEffect(() => {
|
|
5567
|
-
|
|
5568
|
-
}, [
|
|
5569
|
-
|
|
5582
|
+
w.current = p;
|
|
5583
|
+
}, [p]), useEffect(() => {
|
|
5584
|
+
v(i);
|
|
5570
5585
|
}, [i]), useEffect(() => {
|
|
5571
|
-
if (!
|
|
5586
|
+
if (!y) return;
|
|
5572
5587
|
let e = (e) => {
|
|
5573
|
-
|
|
5588
|
+
be.current && !be.current.contains(e.target) && x.current && !x.current.contains(e.target) && b(!1);
|
|
5574
5589
|
}, t = setTimeout(() => {
|
|
5575
5590
|
document.addEventListener("mousedown", e);
|
|
5576
5591
|
}, 0);
|
|
5577
5592
|
return () => {
|
|
5578
5593
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
5579
5594
|
};
|
|
5580
|
-
}, [
|
|
5595
|
+
}, [y]);
|
|
5581
5596
|
let xe = useCallback(() => {
|
|
5582
|
-
for (let e of
|
|
5583
|
-
|
|
5584
|
-
}, [e]),
|
|
5597
|
+
for (let e of C.current) e.remove();
|
|
5598
|
+
C.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]), Se = useCallback(() => {
|
|
5585
5600
|
if (!e) return;
|
|
5586
|
-
let t =
|
|
5601
|
+
let t = S.current, n = {
|
|
5587
5602
|
type: "FeatureCollection",
|
|
5588
5603
|
features: [{
|
|
5589
5604
|
type: "Feature",
|
|
@@ -5634,24 +5649,24 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5634
5649
|
"circle-stroke-color": "#fff"
|
|
5635
5650
|
}
|
|
5636
5651
|
}));
|
|
5637
|
-
}, [e]),
|
|
5638
|
-
if (!e || !
|
|
5639
|
-
let { visualType: n } =
|
|
5652
|
+
}, [e]), D = useCallback((t) => {
|
|
5653
|
+
if (!e || !T.current) return;
|
|
5654
|
+
let { visualType: n } = T.current;
|
|
5640
5655
|
if (n === "marker") {
|
|
5641
5656
|
let n = document.createElement("div");
|
|
5642
|
-
n.className = "route-planning-temp-marker", n.textContent = String(
|
|
5657
|
+
n.className = "route-planning-temp-marker", n.textContent = String(S.current.length);
|
|
5643
5658
|
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5644
|
-
|
|
5645
|
-
} else
|
|
5646
|
-
}, [e,
|
|
5647
|
-
xe(),
|
|
5659
|
+
C.current.push(r);
|
|
5660
|
+
} else Se();
|
|
5661
|
+
}, [e, Se]), Ce = useCallback(() => {
|
|
5662
|
+
xe(), S.current = [], T.current = null, g(0), m("idle"), e && (e.getCanvas().style.cursor = E.current);
|
|
5648
5663
|
}, [xe, e]), we = useCallback(async () => {
|
|
5649
|
-
let e =
|
|
5664
|
+
let e = T.current, t = [...S.current];
|
|
5650
5665
|
if (!e || t.length < 2) {
|
|
5651
5666
|
Ce();
|
|
5652
5667
|
return;
|
|
5653
5668
|
}
|
|
5654
|
-
|
|
5669
|
+
m("planning");
|
|
5655
5670
|
try {
|
|
5656
5671
|
await e.onSelectFinished(t);
|
|
5657
5672
|
} catch (e) {
|
|
@@ -5659,79 +5674,79 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5659
5674
|
} finally {
|
|
5660
5675
|
Ce();
|
|
5661
5676
|
}
|
|
5662
|
-
}, [Ce]),
|
|
5663
|
-
if (
|
|
5677
|
+
}, [Ce]), Te = useCallback((e) => {
|
|
5678
|
+
if (w.current !== "selecting" || !T.current) return;
|
|
5664
5679
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5665
|
-
|
|
5666
|
-
let n =
|
|
5667
|
-
|
|
5668
|
-
}, [
|
|
5669
|
-
|
|
5680
|
+
S.current.push(t);
|
|
5681
|
+
let n = S.current.length;
|
|
5682
|
+
g(n), D(t), n >= T.current.pointCount && we();
|
|
5683
|
+
}, [D, we]), O = useCallback((e) => {
|
|
5684
|
+
w.current === "selecting" && (e.preventDefault(), Ce());
|
|
5670
5685
|
}, [Ce]);
|
|
5671
5686
|
useEffect(() => {
|
|
5672
|
-
if (e &&
|
|
5673
|
-
e.off("click",
|
|
5687
|
+
if (e && p === "selecting") return e.on("click", Te), e.on("contextmenu", O), () => {
|
|
5688
|
+
e.off("click", Te), e.off("contextmenu", O);
|
|
5674
5689
|
};
|
|
5675
5690
|
}, [
|
|
5676
5691
|
e,
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5692
|
+
p,
|
|
5693
|
+
Te,
|
|
5694
|
+
O
|
|
5680
5695
|
]);
|
|
5681
|
-
let
|
|
5696
|
+
let k = useCallback((t) => {
|
|
5682
5697
|
if (!e) return;
|
|
5683
|
-
|
|
5698
|
+
w.current !== "idle" && Ce();
|
|
5684
5699
|
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5685
|
-
|
|
5700
|
+
T.current = {
|
|
5686
5701
|
pointCount: n,
|
|
5687
5702
|
visualType: r,
|
|
5688
5703
|
onSelectFinished: t.onSelectFinished
|
|
5689
|
-
},
|
|
5704
|
+
}, S.current = [], g(0), v(n), b(!1), E.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", m("selecting");
|
|
5690
5705
|
}, [
|
|
5691
5706
|
e,
|
|
5692
5707
|
i,
|
|
5693
5708
|
l,
|
|
5694
5709
|
Ce
|
|
5695
5710
|
]);
|
|
5696
|
-
useImperativeHandle(f, () => ({ startPlanning:
|
|
5697
|
-
let
|
|
5698
|
-
|
|
5699
|
-
},
|
|
5700
|
-
u &&
|
|
5701
|
-
pointCount: Math.max(2,
|
|
5711
|
+
useImperativeHandle(f, () => ({ startPlanning: k }), [k]);
|
|
5712
|
+
let A = () => {
|
|
5713
|
+
p === "idle" ? b((e) => !e) : p === "selecting" && Ce();
|
|
5714
|
+
}, Ee = () => {
|
|
5715
|
+
u && k({
|
|
5716
|
+
pointCount: Math.max(2, _),
|
|
5702
5717
|
visualType: l,
|
|
5703
5718
|
onSelectFinished: u
|
|
5704
5719
|
});
|
|
5705
|
-
},
|
|
5720
|
+
}, j = (e) => {
|
|
5706
5721
|
let t = parseInt(e.target.value, 10);
|
|
5707
|
-
!isNaN(t) && t >= 2 ?
|
|
5708
|
-
},
|
|
5709
|
-
if (
|
|
5710
|
-
if (
|
|
5711
|
-
let e =
|
|
5722
|
+
!isNaN(t) && t >= 2 ? v(t) : e.target.value === "" && v(2);
|
|
5723
|
+
}, De = () => {
|
|
5724
|
+
if (p === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5725
|
+
if (p === "selecting") {
|
|
5726
|
+
let e = T.current?.pointCount ?? _;
|
|
5712
5727
|
return /* @__PURE__ */ jsxs("span", { children: [
|
|
5713
|
-
|
|
5728
|
+
h,
|
|
5714
5729
|
"/",
|
|
5715
5730
|
e
|
|
5716
5731
|
] });
|
|
5717
5732
|
}
|
|
5718
5733
|
return "路径规划";
|
|
5719
|
-
},
|
|
5720
|
-
return !d &&
|
|
5734
|
+
}, Oe = p === "selecting", M = p === "planning";
|
|
5735
|
+
return !d && p === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5721
5736
|
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5722
5737
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5723
|
-
ref:
|
|
5724
|
-
className: `mapbox-control-btn mapbox-route-planning-control__btn${
|
|
5725
|
-
onClick:
|
|
5726
|
-
disabled:
|
|
5727
|
-
title:
|
|
5738
|
+
ref: x,
|
|
5739
|
+
className: `mapbox-control-btn mapbox-route-planning-control__btn${Oe ? " mapbox-route-planning-control__btn--active" : ""}${M ? " mapbox-route-planning-control__btn--planning" : ""}${y ? " mapbox-route-planning-control__btn--active" : ""}`,
|
|
5740
|
+
onClick: A,
|
|
5741
|
+
disabled: M,
|
|
5742
|
+
title: p === "idle" ? "路径规划" : p === "selecting" ? "取消选点" : "规划中...",
|
|
5728
5743
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5729
5744
|
src: route_planning_default,
|
|
5730
5745
|
alt: "route",
|
|
5731
5746
|
className: "mapbox-route-planning-control__btn-icon"
|
|
5732
|
-
}),
|
|
5733
|
-
}),
|
|
5734
|
-
ref:
|
|
5747
|
+
}), De()]
|
|
5748
|
+
}), y && p === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5749
|
+
ref: be,
|
|
5735
5750
|
className: "mapbox-route-planning-control__panel",
|
|
5736
5751
|
children: [/* @__PURE__ */ jsx("div", {
|
|
5737
5752
|
className: "mapbox-route-planning-control__panel-header",
|
|
@@ -5750,12 +5765,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5750
5765
|
}), c ? /* @__PURE__ */ jsx("input", {
|
|
5751
5766
|
type: "number",
|
|
5752
5767
|
className: "mapbox-route-planning-control__panel-input",
|
|
5753
|
-
value:
|
|
5768
|
+
value: _,
|
|
5754
5769
|
min: 2,
|
|
5755
|
-
onChange:
|
|
5770
|
+
onChange: j
|
|
5756
5771
|
}) : /* @__PURE__ */ jsx("span", {
|
|
5757
5772
|
className: "mapbox-route-planning-control__panel-value",
|
|
5758
|
-
children:
|
|
5773
|
+
children: _
|
|
5759
5774
|
})]
|
|
5760
5775
|
}),
|
|
5761
5776
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -5764,7 +5779,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5764
5779
|
}),
|
|
5765
5780
|
/* @__PURE__ */ jsx("button", {
|
|
5766
5781
|
className: "mapbox-route-planning-control__panel-start",
|
|
5767
|
-
onClick:
|
|
5782
|
+
onClick: Ee,
|
|
5768
5783
|
disabled: !u,
|
|
5769
5784
|
children: "开始规划"
|
|
5770
5785
|
})
|
|
@@ -5921,53 +5936,53 @@ function adjustPopupForBounds(e, t) {
|
|
|
5921
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;
|
|
5922
5937
|
}
|
|
5923
5938
|
const Mapbox = forwardRef((e, c) => {
|
|
5924
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style:
|
|
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: m, mode: h = "display", editConfig: g = {}, pickerConfig: _ = {}, onPick: v, interactive: y = {}, layers: b = [], rasterPaint: x, entities: C = [], selectedIds: w = [], entityConfig: T, nameConfig: E, selectNameConfig: D, areaConfig: O, circleConfig: k, lengthConfig: A, showCoordinates: Ee = !0, showScale: j = !0, showResetView: De = !0, showRoadHighlight: Oe = !1, showMeasure: M = !1, showRasterPaint: Ae = !1, showRoutePlanning: Pe, onRasterPaintChange: Fe, popupDefaults: N, renderPopup: Le, onMapLoad: Re, onEntityClick: ze, onPopupOpen: Be, onPopupClose: Ve, className: He = "", containerStyle: Ue } = e, We = useRef(null), Ge = useRef(null), P = useRef(null), F = useRef(/* @__PURE__ */ new Map()), I = useRef(/* @__PURE__ */ new Map()), Ke = useRef(/* @__PURE__ */ new Set()), [L, qe] = useState(null), Je = useRef(null), Ye = useRef(null), Xe = useRef(null), [Ze, Qe] = useState(null), $e = useRef(null), et = useRef(null), [R, tt] = useState(null), [z, nt] = useState(h), [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([]);
|
|
5925
5940
|
yt.current = _t;
|
|
5926
5941
|
let J = useRef(null);
|
|
5927
5942
|
useEffect(() => {
|
|
5928
|
-
nt(
|
|
5929
|
-
}, [
|
|
5943
|
+
nt(h);
|
|
5944
|
+
}, [h]);
|
|
5930
5945
|
let bt = useCallback((e) => {
|
|
5931
|
-
let t =
|
|
5946
|
+
let t = F.current.get(e), n = I.current.get(e);
|
|
5932
5947
|
if (t && n) {
|
|
5933
5948
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5934
5949
|
let r = {
|
|
5935
5950
|
...n,
|
|
5936
5951
|
isAnimating: !0
|
|
5937
5952
|
};
|
|
5938
|
-
|
|
5953
|
+
I.current.set(e, r), t.startAnimation();
|
|
5939
5954
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5940
5955
|
let r = {
|
|
5941
5956
|
...n,
|
|
5942
5957
|
isAnimating: !0
|
|
5943
5958
|
};
|
|
5944
|
-
|
|
5959
|
+
I.current.set(e, r), t.startAnimation();
|
|
5945
5960
|
}
|
|
5946
5961
|
}
|
|
5947
5962
|
}, []), xt = useCallback((e) => {
|
|
5948
|
-
let t =
|
|
5963
|
+
let t = F.current.get(e), n = I.current.get(e);
|
|
5949
5964
|
if (t && n) {
|
|
5950
5965
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5951
5966
|
let r = {
|
|
5952
5967
|
...n,
|
|
5953
5968
|
isAnimating: !1
|
|
5954
5969
|
};
|
|
5955
|
-
|
|
5970
|
+
I.current.set(e, r), t.stopAnimation();
|
|
5956
5971
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5957
5972
|
let r = {
|
|
5958
5973
|
...n,
|
|
5959
5974
|
isAnimating: !1
|
|
5960
5975
|
};
|
|
5961
|
-
|
|
5976
|
+
I.current.set(e, r), t.stopAnimation();
|
|
5962
5977
|
}
|
|
5963
5978
|
}
|
|
5964
5979
|
}, []), St = useCallback((e) => {
|
|
5965
|
-
let t =
|
|
5980
|
+
let t = I.current.get(e);
|
|
5966
5981
|
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? xt(e) : bt(e));
|
|
5967
5982
|
}, [bt, xt]), Ct = useCallback((e) => {
|
|
5968
5983
|
if (e === void 0) {
|
|
5969
5984
|
let e = !1;
|
|
5970
|
-
for (let [, t] of
|
|
5985
|
+
for (let [, t] of F.current) if (t instanceof UnitRenderer) {
|
|
5971
5986
|
let n = t.getShowTrajectory();
|
|
5972
5987
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
5973
5988
|
e = !0;
|
|
@@ -5975,46 +5990,46 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5975
5990
|
}
|
|
5976
5991
|
}
|
|
5977
5992
|
let t = e ? 0 : "all";
|
|
5978
|
-
for (let [, e] of
|
|
5993
|
+
for (let [, e] of F.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
5979
5994
|
} else {
|
|
5980
5995
|
let t = new Set(e.map(String));
|
|
5981
|
-
for (let [e, n] of
|
|
5996
|
+
for (let [e, n] of F.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
5982
5997
|
}
|
|
5983
5998
|
}, []), wt = useCallback((e, t, n) => {
|
|
5984
|
-
let r =
|
|
5985
|
-
if (!r?.popup || !
|
|
5986
|
-
let i = r.popup.content ??
|
|
5999
|
+
let r = C.find((t) => String(t.id) === String(e));
|
|
6000
|
+
if (!r?.popup || !P.current) return;
|
|
6001
|
+
let i = r.popup.content ?? Le?.(r);
|
|
5987
6002
|
if (!i) return;
|
|
5988
|
-
let a = mergePopupConfig(r.popup,
|
|
5989
|
-
|
|
6003
|
+
let a = mergePopupConfig(r.popup, N, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, P.current, n);
|
|
6004
|
+
qe({
|
|
5990
6005
|
entityId: e,
|
|
5991
6006
|
position: o,
|
|
5992
6007
|
config: a,
|
|
5993
6008
|
openedBy: t,
|
|
5994
6009
|
actualPosition: s
|
|
5995
|
-
}),
|
|
6010
|
+
}), Be?.(e);
|
|
5996
6011
|
}, [
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6012
|
+
C,
|
|
6013
|
+
N,
|
|
6014
|
+
Le,
|
|
6015
|
+
Be
|
|
6001
6016
|
]), Tt = useCallback((e) => {
|
|
6002
|
-
|
|
6003
|
-
}, [
|
|
6004
|
-
|
|
6005
|
-
}, [
|
|
6006
|
-
let r =
|
|
6017
|
+
L?.entityId === e && (qe(null), Ve?.(e));
|
|
6018
|
+
}, [L, Ve]), Et = useCallback(() => {
|
|
6019
|
+
qe((e) => (e && Ve?.(e.entityId), null));
|
|
6020
|
+
}, [Ve]), Dt = useCallback((e) => L?.entityId === e, [L]), Ot = useCallback((e, t, n) => {
|
|
6021
|
+
let r = P.current;
|
|
6007
6022
|
r && r.flyTo({
|
|
6008
6023
|
center: e,
|
|
6009
6024
|
zoom: t ?? r.getZoom(),
|
|
6010
6025
|
...n
|
|
6011
6026
|
});
|
|
6012
6027
|
}, []), kt = useCallback((e, t, n) => {
|
|
6013
|
-
let r =
|
|
6028
|
+
let r = P.current;
|
|
6014
6029
|
if (!r || e.length === 0) return;
|
|
6015
6030
|
let i = [];
|
|
6016
6031
|
for (let t of e) {
|
|
6017
|
-
let e =
|
|
6032
|
+
let e = F.current.get(t);
|
|
6018
6033
|
e && i.push(e.getBounds());
|
|
6019
6034
|
}
|
|
6020
6035
|
if (i.length === 0) return;
|
|
@@ -6037,9 +6052,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6037
6052
|
};
|
|
6038
6053
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
6039
6054
|
}, []), At = useCallback((e) => {
|
|
6040
|
-
let t =
|
|
6055
|
+
let t = P.current;
|
|
6041
6056
|
if (!t || !t.getContainer()) return;
|
|
6042
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } =
|
|
6057
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = _;
|
|
6043
6058
|
if (!n) {
|
|
6044
6059
|
at.current &&= (at.current.remove(), null);
|
|
6045
6060
|
return;
|
|
@@ -6048,7 +6063,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6048
6063
|
at.current.setLngLat(e);
|
|
6049
6064
|
let t = at.current.getElement(), n = t.querySelector(".marker-label");
|
|
6050
6065
|
if (i) {
|
|
6051
|
-
let e = resolveNameConfig(a,
|
|
6066
|
+
let e = resolveNameConfig(a, E);
|
|
6052
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`;
|
|
6053
6068
|
else {
|
|
6054
6069
|
let n = document.createElement("div");
|
|
@@ -6060,7 +6075,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6060
6075
|
n.className = "mapbox-picker-marker";
|
|
6061
6076
|
let o = document.createElement("div");
|
|
6062
6077
|
if (o.className = "marker-inner", o.style.background = r, n.appendChild(o), i) {
|
|
6063
|
-
let e = resolveNameConfig(a,
|
|
6078
|
+
let e = resolveNameConfig(a, E), t = document.createElement("div");
|
|
6064
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);
|
|
6065
6080
|
}
|
|
6066
6081
|
at.current = new mapboxgl.Marker({
|
|
@@ -6068,11 +6083,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6068
6083
|
anchor: "bottom"
|
|
6069
6084
|
}).setLngLat(e).addTo(t);
|
|
6070
6085
|
}
|
|
6071
|
-
}, [
|
|
6086
|
+
}, [_, E]), jt = useCallback(() => {
|
|
6072
6087
|
at.current &&= (at.current.remove(), null);
|
|
6073
6088
|
}, []), Mt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Nt = useCallback((e) => {
|
|
6074
|
-
let t =
|
|
6075
|
-
if (
|
|
6089
|
+
let t = P.current;
|
|
6090
|
+
if (We.current) if (ht.current &&= (ht.current.remove(), null), e && t) {
|
|
6076
6091
|
t.getCanvas().style.cursor = "none";
|
|
6077
6092
|
let n = document.createElement("div");
|
|
6078
6093
|
n.className = "mapbox-custom-cursor";
|
|
@@ -6092,7 +6107,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6092
6107
|
let e = ht.current._cleanup;
|
|
6093
6108
|
e && e(), ht.current.remove(), ht.current = null;
|
|
6094
6109
|
}
|
|
6095
|
-
let e =
|
|
6110
|
+
let e = P.current;
|
|
6096
6111
|
e && (e.getCanvas().style.cursor = "");
|
|
6097
6112
|
}, []), Pt = useCallback((e, t, n) => {
|
|
6098
6113
|
if (!e.getSource(t)) {
|
|
@@ -6131,7 +6146,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6131
6146
|
});
|
|
6132
6147
|
}
|
|
6133
6148
|
}, []), Ft = useCallback(() => {
|
|
6134
|
-
let e =
|
|
6149
|
+
let e = P.current;
|
|
6135
6150
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6136
6151
|
type: "geojson",
|
|
6137
6152
|
data: {
|
|
@@ -6157,7 +6172,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6157
6172
|
}
|
|
6158
6173
|
}), Pt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6159
6174
|
}, [Pt]), It = useCallback((e, t) => {
|
|
6160
|
-
let n =
|
|
6175
|
+
let n = P.current;
|
|
6161
6176
|
if (!n) return;
|
|
6162
6177
|
let r = n.getSource("rect-preview-source");
|
|
6163
6178
|
if (!r) return;
|
|
@@ -6218,7 +6233,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6218
6233
|
});
|
|
6219
6234
|
}
|
|
6220
6235
|
}, []), Lt = useCallback(() => {
|
|
6221
|
-
let e =
|
|
6236
|
+
let e = P.current;
|
|
6222
6237
|
if (!e) return;
|
|
6223
6238
|
let t = e.getSource("rect-preview-source");
|
|
6224
6239
|
t && t.setData({
|
|
@@ -6233,7 +6248,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6233
6248
|
}, []), X = useCallback(() => {
|
|
6234
6249
|
lt(null), Lt();
|
|
6235
6250
|
}, [Lt]), Rt = useCallback(() => {
|
|
6236
|
-
let e =
|
|
6251
|
+
let e = P.current;
|
|
6237
6252
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6238
6253
|
type: "geojson",
|
|
6239
6254
|
data: {
|
|
@@ -6285,7 +6300,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6285
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);
|
|
6286
6301
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6287
6302
|
}, []), Vt = useCallback((e, t) => {
|
|
6288
|
-
let n =
|
|
6303
|
+
let n = P.current;
|
|
6289
6304
|
if (!n) return;
|
|
6290
6305
|
let r = n.getSource("circle-preview-source");
|
|
6291
6306
|
if (!r) return;
|
|
@@ -6335,13 +6350,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6335
6350
|
type: "FeatureCollection",
|
|
6336
6351
|
features: f
|
|
6337
6352
|
});
|
|
6338
|
-
let
|
|
6339
|
-
|
|
6353
|
+
let ye = n.getSource("circle-preview-radius-source");
|
|
6354
|
+
ye && ye.setData({
|
|
6340
6355
|
type: "FeatureCollection",
|
|
6341
6356
|
features: p
|
|
6342
6357
|
});
|
|
6343
6358
|
}, [Bt, zt]), Ht = useCallback(() => {
|
|
6344
|
-
let e =
|
|
6359
|
+
let e = P.current;
|
|
6345
6360
|
if (!e) return;
|
|
6346
6361
|
let t = e.getSource("circle-preview-source");
|
|
6347
6362
|
t && t.setData({
|
|
@@ -6361,7 +6376,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6361
6376
|
}, []), Ut = useCallback(() => {
|
|
6362
6377
|
dt.current = null, Ht();
|
|
6363
6378
|
}, [Ht]), Wt = useCallback(() => {
|
|
6364
|
-
let e =
|
|
6379
|
+
let e = P.current;
|
|
6365
6380
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6366
6381
|
type: "geojson",
|
|
6367
6382
|
data: {
|
|
@@ -6403,7 +6418,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6403
6418
|
}
|
|
6404
6419
|
}), Pt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6405
6420
|
}, [Pt]), Gt = useCallback((e, t) => {
|
|
6406
|
-
let n =
|
|
6421
|
+
let n = P.current;
|
|
6407
6422
|
if (!n) return;
|
|
6408
6423
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
6409
6424
|
if (!r || !i) return;
|
|
@@ -6487,7 +6502,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6487
6502
|
});
|
|
6488
6503
|
}
|
|
6489
6504
|
}, []), Kt = useCallback(() => {
|
|
6490
|
-
let e =
|
|
6505
|
+
let e = P.current;
|
|
6491
6506
|
if (!e) return;
|
|
6492
6507
|
let t = e.getSource("polygon-preview-source");
|
|
6493
6508
|
t && t.setData({
|
|
@@ -6507,7 +6522,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6507
6522
|
}, []), qt = useCallback(() => {
|
|
6508
6523
|
ft.current = [], Kt();
|
|
6509
6524
|
}, [Kt]), Jt = useCallback(() => {
|
|
6510
|
-
let e =
|
|
6525
|
+
let e = P.current;
|
|
6511
6526
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6512
6527
|
type: "geojson",
|
|
6513
6528
|
data: {
|
|
@@ -6542,7 +6557,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6542
6557
|
[n - s, r + o]
|
|
6543
6558
|
];
|
|
6544
6559
|
}, []), Xt = useCallback((e, t) => {
|
|
6545
|
-
let n =
|
|
6560
|
+
let n = P.current;
|
|
6546
6561
|
if (!n) return;
|
|
6547
6562
|
let r = n.getSource("square-preview-source");
|
|
6548
6563
|
if (!r) return;
|
|
@@ -6584,7 +6599,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6584
6599
|
});
|
|
6585
6600
|
}
|
|
6586
6601
|
}, [Bt, Yt]), Zt = useCallback(() => {
|
|
6587
|
-
let e =
|
|
6602
|
+
let e = P.current;
|
|
6588
6603
|
if (!e) return;
|
|
6589
6604
|
let t = e.getSource("square-preview-source");
|
|
6590
6605
|
t && t.setData({
|
|
@@ -6599,7 +6614,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6599
6614
|
}, []), Qt = useCallback(() => {
|
|
6600
6615
|
pt.current = null, Zt();
|
|
6601
6616
|
}, [Zt]), $t = useCallback(() => {
|
|
6602
|
-
let e =
|
|
6617
|
+
let e = P.current;
|
|
6603
6618
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6604
6619
|
type: "geojson",
|
|
6605
6620
|
data: {
|
|
@@ -6633,7 +6648,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6633
6648
|
}
|
|
6634
6649
|
}), Pt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
6635
6650
|
}, [Pt]), en = useCallback((e, t) => {
|
|
6636
|
-
let n =
|
|
6651
|
+
let n = P.current;
|
|
6637
6652
|
if (!n) return;
|
|
6638
6653
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
6639
6654
|
if (!r || !i) return;
|
|
@@ -6681,7 +6696,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6681
6696
|
});
|
|
6682
6697
|
}
|
|
6683
6698
|
}, []), tn = useCallback(() => {
|
|
6684
|
-
let e =
|
|
6699
|
+
let e = P.current;
|
|
6685
6700
|
if (!e) return;
|
|
6686
6701
|
let t = e.getSource("polyline-preview-source");
|
|
6687
6702
|
t && t.setData({
|
|
@@ -6712,23 +6727,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6712
6727
|
]), rn = useCallback((e) => {
|
|
6713
6728
|
if (V(e), e === "rectangle") {
|
|
6714
6729
|
B(null), Y(), Ut(), qt(), Qt(), Z();
|
|
6715
|
-
let e =
|
|
6730
|
+
let e = P.current;
|
|
6716
6731
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6717
6732
|
} else if (e === "circle") {
|
|
6718
6733
|
B(null), Y(), X(), qt(), Qt(), Z();
|
|
6719
|
-
let e =
|
|
6734
|
+
let e = P.current;
|
|
6720
6735
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6721
6736
|
} else if (e === "polygon") {
|
|
6722
6737
|
B(null), Y(), X(), Ut(), Qt(), Z();
|
|
6723
|
-
let e =
|
|
6738
|
+
let e = P.current;
|
|
6724
6739
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6725
6740
|
} else if (e === "square") {
|
|
6726
6741
|
B(null), Y(), X(), Ut(), qt(), Z();
|
|
6727
|
-
let e =
|
|
6742
|
+
let e = P.current;
|
|
6728
6743
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6729
6744
|
} else if (e === "polyline") {
|
|
6730
6745
|
B(null), Y(), X(), Ut(), qt(), Qt();
|
|
6731
|
-
let e =
|
|
6746
|
+
let e = P.current;
|
|
6732
6747
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6733
6748
|
} else e === "marker" ? (X(), Ut(), qt(), Qt(), Z()) : (B(null), Y(), X(), Ut(), qt(), Qt(), Z());
|
|
6734
6749
|
}, [
|
|
@@ -6740,7 +6755,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6740
6755
|
Z
|
|
6741
6756
|
]), an = useCallback((e) => {
|
|
6742
6757
|
if (e !== "picker") {
|
|
6743
|
-
let e =
|
|
6758
|
+
let e = _.value && isFinite(_.value.lng) && isFinite(_.value.lat), t = _.showMarker !== !1;
|
|
6744
6759
|
(!e || !t) && jt(), it(null);
|
|
6745
6760
|
}
|
|
6746
6761
|
e !== "edit" && (B(null), V(null), X(), Z(), Y()), nt(e);
|
|
@@ -6749,20 +6764,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6749
6764
|
Y,
|
|
6750
6765
|
X,
|
|
6751
6766
|
Z
|
|
6752
|
-
]), on = useCallback(() =>
|
|
6767
|
+
]), on = useCallback(() => z, [z]), sn = useCallback(() => rt, [rt]), cn = useCallback(() => {
|
|
6753
6768
|
jt(), it(null);
|
|
6754
6769
|
}, [jt]);
|
|
6755
6770
|
useEffect(() => {
|
|
6756
|
-
if (!
|
|
6757
|
-
let e =
|
|
6771
|
+
if (!R) return;
|
|
6772
|
+
let e = _.value;
|
|
6758
6773
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6759
6774
|
let t = [e.lng, e.lat];
|
|
6760
6775
|
it(e), At(t);
|
|
6761
6776
|
}
|
|
6762
6777
|
}, [
|
|
6763
|
-
|
|
6778
|
+
_.value,
|
|
6764
6779
|
At,
|
|
6765
|
-
|
|
6780
|
+
R
|
|
6766
6781
|
]);
|
|
6767
6782
|
let ln = (e) => "mode" in e, un = useCallback((e) => {
|
|
6768
6783
|
if (nt("edit"), jt(), it(null), H.current = !0, ln(e)) {
|
|
@@ -6774,23 +6789,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6774
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));
|
|
6775
6790
|
else if (e.mode === "rectangle") {
|
|
6776
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();
|
|
6777
|
-
let t =
|
|
6792
|
+
let t = P.current;
|
|
6778
6793
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6779
6794
|
} else if (e.mode === "circle") {
|
|
6780
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();
|
|
6781
|
-
let t =
|
|
6796
|
+
let t = P.current;
|
|
6782
6797
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6783
6798
|
} else if (e.mode === "polygon") {
|
|
6784
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();
|
|
6785
|
-
let t =
|
|
6800
|
+
let t = P.current;
|
|
6786
6801
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6787
6802
|
} else if (e.mode === "square") {
|
|
6788
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();
|
|
6789
|
-
let t =
|
|
6804
|
+
let t = P.current;
|
|
6790
6805
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6791
6806
|
} else if (e.mode === "polyline") {
|
|
6792
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();
|
|
6793
|
-
let t =
|
|
6808
|
+
let t = P.current;
|
|
6794
6809
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6795
6810
|
}
|
|
6796
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;
|
|
@@ -6803,7 +6818,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6803
6818
|
startAnimation: bt,
|
|
6804
6819
|
stopAnimation: xt,
|
|
6805
6820
|
toggleAnimation: St,
|
|
6806
|
-
getMap: () =>
|
|
6821
|
+
getMap: () => P.current,
|
|
6807
6822
|
openPopup: (e) => wt(e, "programmatic"),
|
|
6808
6823
|
closePopup: Tt,
|
|
6809
6824
|
closeAllPopups: Et,
|
|
@@ -6816,15 +6831,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6816
6831
|
getPickedLocation: sn,
|
|
6817
6832
|
clearPickedLocation: cn,
|
|
6818
6833
|
startDrawing: un,
|
|
6819
|
-
getRenderer: (e) =>
|
|
6834
|
+
getRenderer: (e) => F.current.get(e),
|
|
6820
6835
|
setEditingEntities: (e) => {
|
|
6821
|
-
for (let t of yt.current) e.map(String).includes(String(t)) ||
|
|
6822
|
-
for (let t of e)
|
|
6823
|
-
J.current &&= (
|
|
6836
|
+
for (let t of yt.current) e.map(String).includes(String(t)) || F.current.get(t)?.setEditing?.(!1);
|
|
6837
|
+
for (let t of e) F.current.get(t)?.setEditing?.(!0);
|
|
6838
|
+
J.current &&= (F.current.get(J.current.entityId)?.cancelEditPreview?.(), null), vt(e);
|
|
6824
6839
|
},
|
|
6825
6840
|
getEditingEntities: () => yt.current,
|
|
6826
6841
|
startRoutePlanning: (e) => {
|
|
6827
|
-
|
|
6842
|
+
Ge.current?.startPlanning(e);
|
|
6828
6843
|
}
|
|
6829
6844
|
}), [
|
|
6830
6845
|
bt,
|
|
@@ -6844,13 +6859,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6844
6859
|
un
|
|
6845
6860
|
]);
|
|
6846
6861
|
let dn = useCallback(() => {
|
|
6847
|
-
let e =
|
|
6862
|
+
let e = P.current;
|
|
6848
6863
|
if (!e) return;
|
|
6849
|
-
let t = new Set(
|
|
6850
|
-
for (let e of n) t.has(e) || (
|
|
6851
|
-
let r = new Set(
|
|
6852
|
-
for (let t of
|
|
6853
|
-
let n = applyEntityConfig(t,
|
|
6864
|
+
let t = new Set(C.map((e) => e.id)), n = new Set(F.current.keys());
|
|
6865
|
+
for (let e of n) t.has(e) || (F.current.get(e)?.destroy(), F.current.delete(e));
|
|
6866
|
+
let r = new Set(w.map(String));
|
|
6867
|
+
for (let t of C) {
|
|
6868
|
+
let n = applyEntityConfig(t, T), i = F.current.get(n.id);
|
|
6854
6869
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
6855
6870
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
6856
6871
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -6859,37 +6874,37 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6859
6874
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
6860
6875
|
else {
|
|
6861
6876
|
i.destroy();
|
|
6862
|
-
let t = new CanvasCircleRenderer(e, n, D, O, k
|
|
6863
|
-
|
|
6877
|
+
let t = new CanvasCircleRenderer(e, n, E, D, O, k);
|
|
6878
|
+
F.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6864
6879
|
}
|
|
6865
6880
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
6866
6881
|
else {
|
|
6867
6882
|
i.destroy();
|
|
6868
|
-
let t = new CircleRenderer(e, n, D, O, k
|
|
6869
|
-
|
|
6883
|
+
let t = new CircleRenderer(e, n, E, D, O, k);
|
|
6884
|
+
F.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6870
6885
|
}
|
|
6871
6886
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
6872
6887
|
else {
|
|
6873
6888
|
let t = null;
|
|
6874
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n,
|
|
6889
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, E, D) : n.type === "image" ? t = new CanvasImageRenderer(e, n, E, D) : n.type === "marker" ? t = new MarkerRenderer(e, n, E, D) : n.type === "unit" ? t = new UnitRenderer(e, n, E, D) : n.type === "polygon" ? t = new PolygonRenderer(e, n, E, D, O, A) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, E, D, O, k) : new CircleRenderer(e, n, E, D, O, k) : n.type === "square" ? t = new SquareRenderer(e, n, E, D, O, A) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, E, D, O, A) : n.type === "polyline" && (t = new PolylineRenderer(e, n, E, D, A)), t && (F.current.set(n.id, t), t.setSelected(r.has(String(n.id))), yt.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
6875
6890
|
}
|
|
6876
6891
|
}
|
|
6877
6892
|
for (let e of yt.current) {
|
|
6878
|
-
let t =
|
|
6893
|
+
let t = F.current.get(e);
|
|
6879
6894
|
t && t.setEditing?.(!0);
|
|
6880
6895
|
}
|
|
6881
6896
|
}, [
|
|
6897
|
+
C,
|
|
6882
6898
|
w,
|
|
6883
6899
|
T,
|
|
6884
6900
|
E,
|
|
6885
6901
|
D,
|
|
6886
6902
|
O,
|
|
6887
6903
|
k,
|
|
6888
|
-
A
|
|
6889
|
-
j
|
|
6904
|
+
A
|
|
6890
6905
|
]), fn = useCallback(() => {
|
|
6891
|
-
for (let e of
|
|
6892
|
-
|
|
6906
|
+
for (let e of F.current.values()) e.destroy();
|
|
6907
|
+
F.current.clear();
|
|
6893
6908
|
}, []), pn = useCallback((e) => {
|
|
6894
6909
|
let t = e.getStyle();
|
|
6895
6910
|
if (!t?.layers) return;
|
|
@@ -6906,9 +6921,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6906
6921
|
];
|
|
6907
6922
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6908
6923
|
}, []), mn = useCallback((e) => {
|
|
6909
|
-
let t =
|
|
6924
|
+
let t = x, 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;
|
|
6910
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;
|
|
6911
|
-
}, [
|
|
6926
|
+
}, [x]), hn = useCallback((e, t) => {
|
|
6912
6927
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6913
6928
|
type: "raster",
|
|
6914
6929
|
tiles: [t.url],
|
|
@@ -6929,7 +6944,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6929
6944
|
}, [pn, mn]), gn = useCallback(async (e, t) => {
|
|
6930
6945
|
try {
|
|
6931
6946
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6932
|
-
if (!
|
|
6947
|
+
if (!Ke.current.has(t.id)) return;
|
|
6933
6948
|
let a = n.format === "pbf" || n.vector_layers, o = pn(e);
|
|
6934
6949
|
if (a) {
|
|
6935
6950
|
let t = {
|
|
@@ -6960,7 +6975,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6960
6975
|
}, [pn, mn]), _n = useCallback(async (e, t) => {
|
|
6961
6976
|
try {
|
|
6962
6977
|
let n = await (await fetch(t.url)).json();
|
|
6963
|
-
if (!
|
|
6978
|
+
if (!Ke.current.has(t.id)) return;
|
|
6964
6979
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
6965
6980
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
6966
6981
|
e.getSource(n) || e.addSource(n, i);
|
|
@@ -6997,9 +7012,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6997
7012
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
6998
7013
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
6999
7014
|
}, []), yn = useCallback((e) => {
|
|
7000
|
-
let t =
|
|
7015
|
+
let t = P.current;
|
|
7001
7016
|
if (!t) return;
|
|
7002
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
7017
|
+
let n = new Set(e.map((e) => e.id)), r = Ke.current;
|
|
7003
7018
|
for (let e of r) n.has(e) || (vn(t, e), r.delete(e));
|
|
7004
7019
|
for (let n of e) if (r.has(n.id)) {
|
|
7005
7020
|
let e = `base-layer-${n.id}`;
|
|
@@ -7065,12 +7080,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7065
7080
|
id: n?.id ?? Mt(),
|
|
7066
7081
|
type: "rectangle",
|
|
7067
7082
|
bounds: [e, t]
|
|
7068
|
-
},
|
|
7083
|
+
}, T);
|
|
7069
7084
|
Lt();
|
|
7070
|
-
let i =
|
|
7071
|
-
if (i && !
|
|
7072
|
-
let e = new RectangleRenderer(i, r, D, O,
|
|
7073
|
-
|
|
7085
|
+
let i = P.current;
|
|
7086
|
+
if (i && !F.current.has(r.id)) {
|
|
7087
|
+
let e = new RectangleRenderer(i, r, E, D, O, A);
|
|
7088
|
+
F.current.set(r.id, e);
|
|
7074
7089
|
}
|
|
7075
7090
|
Q.current.onRectangleAdd?.(r), lt(null), U.current = null, H.current && (H.current = !1, V(null), i && (i.getCanvas().style.cursor = ""));
|
|
7076
7091
|
}
|
|
@@ -7086,12 +7101,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7086
7101
|
type: "circle",
|
|
7087
7102
|
center: e.center,
|
|
7088
7103
|
radius: n
|
|
7089
|
-
},
|
|
7104
|
+
}, T);
|
|
7090
7105
|
Ht();
|
|
7091
|
-
let a =
|
|
7092
|
-
if (a && !
|
|
7093
|
-
let e = new CircleRenderer(a, i, D, O, k
|
|
7094
|
-
|
|
7106
|
+
let a = P.current;
|
|
7107
|
+
if (a && !F.current.has(i.id)) {
|
|
7108
|
+
let e = new CircleRenderer(a, i, E, D, O, k);
|
|
7109
|
+
F.current.set(i.id, e);
|
|
7095
7110
|
}
|
|
7096
7111
|
Q.current.onCircleAdd?.(i), dt.current = null, W.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
7097
7112
|
}
|
|
@@ -7107,12 +7122,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7107
7122
|
id: t?.id ?? Mt(),
|
|
7108
7123
|
type: "polygon",
|
|
7109
7124
|
coordinates: [...e]
|
|
7110
|
-
},
|
|
7125
|
+
}, T);
|
|
7111
7126
|
Kt();
|
|
7112
|
-
let r =
|
|
7113
|
-
if (r && !
|
|
7114
|
-
let e = new PolygonRenderer(r, n, D, O,
|
|
7115
|
-
|
|
7127
|
+
let r = P.current;
|
|
7128
|
+
if (r && !F.current.has(n.id)) {
|
|
7129
|
+
let e = new PolygonRenderer(r, n, E, D, O, A);
|
|
7130
|
+
F.current.set(n.id, e);
|
|
7116
7131
|
}
|
|
7117
7132
|
Q.current.onPolygonAdd?.(n), ft.current = [], G.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7118
7133
|
return;
|
|
@@ -7131,12 +7146,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7131
7146
|
type: "square",
|
|
7132
7147
|
center: e.center,
|
|
7133
7148
|
length: n
|
|
7134
|
-
},
|
|
7149
|
+
}, T);
|
|
7135
7150
|
Zt();
|
|
7136
|
-
let a =
|
|
7137
|
-
if (a && !
|
|
7138
|
-
let e = new SquareRenderer(a, i, D, O,
|
|
7139
|
-
|
|
7151
|
+
let a = P.current;
|
|
7152
|
+
if (a && !F.current.has(i.id)) {
|
|
7153
|
+
let e = new SquareRenderer(a, i, E, D, O, A);
|
|
7154
|
+
F.current.set(i.id, e);
|
|
7140
7155
|
}
|
|
7141
7156
|
Q.current.onSquareAdd?.(i), pt.current = null, K.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
7142
7157
|
}
|
|
@@ -7174,9 +7189,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7174
7189
|
}
|
|
7175
7190
|
}
|
|
7176
7191
|
if (yt.current.length > 0) {
|
|
7177
|
-
let e =
|
|
7192
|
+
let e = P.current?.getZoom() ?? 12;
|
|
7178
7193
|
if (J.current) {
|
|
7179
|
-
let { entityId: e, activeHandle: n } = J.current, r =
|
|
7194
|
+
let { entityId: e, activeHandle: n } = J.current, r = F.current.get(e);
|
|
7180
7195
|
if (r?.applyHandleMove) {
|
|
7181
7196
|
let e = r.applyHandleMove(n, t);
|
|
7182
7197
|
Q.current.onEntityEdit?.(e);
|
|
@@ -7185,7 +7200,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7185
7200
|
return;
|
|
7186
7201
|
}
|
|
7187
7202
|
for (let n of yt.current) {
|
|
7188
|
-
let r =
|
|
7203
|
+
let r = F.current.get(n);
|
|
7189
7204
|
if (!r?.getEditHandleAt) continue;
|
|
7190
7205
|
let i = r.getEditHandleAt(t, e);
|
|
7191
7206
|
if (i) {
|
|
@@ -7212,44 +7227,44 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7212
7227
|
let e = i.find((e) => String(e.id) === s);
|
|
7213
7228
|
if (e) {
|
|
7214
7229
|
if (a?.(e), e.popup) {
|
|
7215
|
-
let t = e.popup.content ??
|
|
7216
|
-
t && mergePopupConfig(e.popup,
|
|
7230
|
+
let t = e.popup.content ?? Le?.(e);
|
|
7231
|
+
t && mergePopupConfig(e.popup, N, t).trigger === "click" && o(s, "click", n);
|
|
7217
7232
|
}
|
|
7218
7233
|
return;
|
|
7219
7234
|
}
|
|
7220
7235
|
}
|
|
7221
|
-
for (let [t, r] of
|
|
7236
|
+
for (let [t, r] of F.current) {
|
|
7222
7237
|
let s = r.getLabelLayerId();
|
|
7223
|
-
if (s &&
|
|
7238
|
+
if (s && P.current?.getLayer(s) && P.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
7224
7239
|
let e = i.find((e) => e.id === t);
|
|
7225
7240
|
if (e) {
|
|
7226
7241
|
if (a?.(e), e.popup) {
|
|
7227
|
-
let r = e.popup.content ??
|
|
7228
|
-
r && mergePopupConfig(e.popup,
|
|
7242
|
+
let r = e.popup.content ?? Le?.(e);
|
|
7243
|
+
r && mergePopupConfig(e.popup, N, r).trigger === "click" && o(t, "click", n);
|
|
7229
7244
|
}
|
|
7230
7245
|
return;
|
|
7231
7246
|
}
|
|
7232
7247
|
}
|
|
7233
7248
|
}
|
|
7234
|
-
for (let [e, r] of
|
|
7249
|
+
for (let [e, r] of F.current) if (r.isPointInEntity(t)) {
|
|
7235
7250
|
let t = i.find((t) => t.id === e);
|
|
7236
7251
|
if (t) {
|
|
7237
7252
|
if (a?.(t), t.popup) {
|
|
7238
|
-
let r = t.popup.content ??
|
|
7239
|
-
r && mergePopupConfig(t.popup,
|
|
7253
|
+
let r = t.popup.content ?? Le?.(t);
|
|
7254
|
+
r && mergePopupConfig(t.popup, N, r).trigger === "click" && o(e, "click", n);
|
|
7240
7255
|
}
|
|
7241
7256
|
return;
|
|
7242
7257
|
}
|
|
7243
7258
|
}
|
|
7244
7259
|
}, [
|
|
7245
|
-
|
|
7246
|
-
|
|
7260
|
+
N,
|
|
7261
|
+
Le,
|
|
7247
7262
|
bn
|
|
7248
7263
|
]), Sn = useCallback((e) => {
|
|
7249
7264
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7250
7265
|
if (J.current) {
|
|
7251
7266
|
let { entityId: e, activeHandle: n } = J.current;
|
|
7252
|
-
|
|
7267
|
+
F.current.get(e)?.updateEditPreview?.(n, t);
|
|
7253
7268
|
return;
|
|
7254
7269
|
}
|
|
7255
7270
|
let n = Mn.current, r = Nn.current;
|
|
@@ -7263,27 +7278,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7263
7278
|
let s = mt.current;
|
|
7264
7279
|
n === "polyline" && s.length > 0 && en(s, t);
|
|
7265
7280
|
let c = En.current, l = On.current;
|
|
7266
|
-
for (let [e, n] of
|
|
7281
|
+
for (let [e, n] of F.current) if (n.isPointInEntity(t)) {
|
|
7267
7282
|
let t = c.find((t) => t.id === e);
|
|
7268
7283
|
if (!t?.popup) continue;
|
|
7269
|
-
let n = t.popup.content ??
|
|
7284
|
+
let n = t.popup.content ?? Le?.(t);
|
|
7270
7285
|
if (!n) continue;
|
|
7271
|
-
let r = mergePopupConfig(t.popup,
|
|
7286
|
+
let r = mergePopupConfig(t.popup, N, n);
|
|
7272
7287
|
if (r.trigger === "hover") {
|
|
7273
|
-
|
|
7288
|
+
Xe.current && clearTimeout(Xe.current), Xe.current = window.setTimeout(() => {
|
|
7274
7289
|
l(e, "hover");
|
|
7275
7290
|
}, r.hoverDelay);
|
|
7276
7291
|
return;
|
|
7277
7292
|
}
|
|
7278
7293
|
}
|
|
7279
|
-
if (
|
|
7280
|
-
let e =
|
|
7281
|
-
e && !e.isPointInEntity(t) && Tt(
|
|
7294
|
+
if (Xe.current &&= (clearTimeout(Xe.current), null), L?.openedBy === "hover") {
|
|
7295
|
+
let e = F.current.get(L.entityId);
|
|
7296
|
+
e && !e.isPointInEntity(t) && Tt(L.entityId);
|
|
7282
7297
|
}
|
|
7283
7298
|
}, [
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7299
|
+
N,
|
|
7300
|
+
Le,
|
|
7301
|
+
L,
|
|
7287
7302
|
Tt,
|
|
7288
7303
|
It,
|
|
7289
7304
|
Vt,
|
|
@@ -7295,12 +7310,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7295
7310
|
if (yt.current.length > 0) {
|
|
7296
7311
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7297
7312
|
if (J.current) {
|
|
7298
|
-
|
|
7313
|
+
F.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7299
7314
|
return;
|
|
7300
7315
|
}
|
|
7301
|
-
let n =
|
|
7316
|
+
let n = P.current?.getZoom() ?? 12;
|
|
7302
7317
|
for (let e of yt.current) {
|
|
7303
|
-
let r =
|
|
7318
|
+
let r = F.current.get(e);
|
|
7304
7319
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7305
7320
|
let i = r.getEditHandleAt(t, n);
|
|
7306
7321
|
if (i && i.type === "vertex") {
|
|
@@ -7320,7 +7335,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7320
7335
|
if (Nn.current) lt(null), Lt();
|
|
7321
7336
|
else {
|
|
7322
7337
|
V(null);
|
|
7323
|
-
let e =
|
|
7338
|
+
let e = P.current;
|
|
7324
7339
|
e && (e.getCanvas().style.cursor = "");
|
|
7325
7340
|
}
|
|
7326
7341
|
return;
|
|
@@ -7329,7 +7344,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7329
7344
|
if (dt.current) dt.current = null, Ht();
|
|
7330
7345
|
else {
|
|
7331
7346
|
V(null);
|
|
7332
|
-
let e =
|
|
7347
|
+
let e = P.current;
|
|
7333
7348
|
e && (e.getCanvas().style.cursor = "");
|
|
7334
7349
|
}
|
|
7335
7350
|
return;
|
|
@@ -7342,18 +7357,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7342
7357
|
id: t?.id ?? Mt(),
|
|
7343
7358
|
type: "polygon",
|
|
7344
7359
|
coordinates: [...e]
|
|
7345
|
-
},
|
|
7360
|
+
}, T);
|
|
7346
7361
|
Kt();
|
|
7347
|
-
let r =
|
|
7348
|
-
if (r && !
|
|
7349
|
-
let e = new PolygonRenderer(r, n, D, O,
|
|
7350
|
-
|
|
7362
|
+
let r = P.current;
|
|
7363
|
+
if (r && !F.current.has(n.id)) {
|
|
7364
|
+
let e = new PolygonRenderer(r, n, E, D, O, A);
|
|
7365
|
+
F.current.set(n.id, e);
|
|
7351
7366
|
}
|
|
7352
7367
|
Q.current.onPolygonAdd?.(n), ft.current = [], G.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7353
7368
|
} else if (e.length > 0) ft.current = [], Kt();
|
|
7354
7369
|
else {
|
|
7355
7370
|
V(null);
|
|
7356
|
-
let e =
|
|
7371
|
+
let e = P.current;
|
|
7357
7372
|
e && (e.getCanvas().style.cursor = "");
|
|
7358
7373
|
}
|
|
7359
7374
|
return;
|
|
@@ -7362,7 +7377,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7362
7377
|
if (pt.current) pt.current = null, Zt();
|
|
7363
7378
|
else {
|
|
7364
7379
|
V(null);
|
|
7365
|
-
let e =
|
|
7380
|
+
let e = P.current;
|
|
7366
7381
|
e && (e.getCanvas().style.cursor = "");
|
|
7367
7382
|
}
|
|
7368
7383
|
return;
|
|
@@ -7375,18 +7390,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7375
7390
|
id: t?.id ?? Mt(),
|
|
7376
7391
|
type: "polyline",
|
|
7377
7392
|
coordinates: [...e]
|
|
7378
|
-
},
|
|
7393
|
+
}, T);
|
|
7379
7394
|
tn();
|
|
7380
|
-
let r =
|
|
7381
|
-
if (r && !
|
|
7382
|
-
let e = new PolylineRenderer(r, n,
|
|
7383
|
-
|
|
7395
|
+
let r = P.current;
|
|
7396
|
+
if (r && !F.current.has(n.id)) {
|
|
7397
|
+
let e = new PolylineRenderer(r, n, E, D, A);
|
|
7398
|
+
F.current.set(n.id, e);
|
|
7384
7399
|
}
|
|
7385
7400
|
Q.current.onPolylineAdd?.(n), mt.current = [], q.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7386
7401
|
} else if (e.length > 0) mt.current = [], tn();
|
|
7387
7402
|
else {
|
|
7388
7403
|
V(null);
|
|
7389
|
-
let e =
|
|
7404
|
+
let e = P.current;
|
|
7390
7405
|
e && (e.getCanvas().style.cursor = "");
|
|
7391
7406
|
}
|
|
7392
7407
|
return;
|
|
@@ -7402,9 +7417,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7402
7417
|
return;
|
|
7403
7418
|
}
|
|
7404
7419
|
}
|
|
7405
|
-
for (let [t, a] of
|
|
7420
|
+
for (let [t, a] of F.current) {
|
|
7406
7421
|
let o = a.getLabelLayerId();
|
|
7407
|
-
if (o &&
|
|
7422
|
+
if (o && P.current?.getLayer(o) && P.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7408
7423
|
let e = i.find((e) => e.id === t);
|
|
7409
7424
|
if (e) {
|
|
7410
7425
|
wn(e, r, n);
|
|
@@ -7412,7 +7427,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7412
7427
|
}
|
|
7413
7428
|
}
|
|
7414
7429
|
}
|
|
7415
|
-
for (let [e, t] of
|
|
7430
|
+
for (let [e, t] of F.current) if (t.isPointInEntity(n)) {
|
|
7416
7431
|
let t = i.find((t) => t.id === e);
|
|
7417
7432
|
if (t) {
|
|
7418
7433
|
wn(t, r, n);
|
|
@@ -7428,11 +7443,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7428
7443
|
Zt,
|
|
7429
7444
|
tn
|
|
7430
7445
|
]), wn = useCallback((e, t, n) => {
|
|
7431
|
-
let r =
|
|
7446
|
+
let r = We.current?.getBoundingClientRect(), i = r ? {
|
|
7432
7447
|
x: t.x + r.left,
|
|
7433
7448
|
y: t.y + r.top
|
|
7434
7449
|
} : t;
|
|
7435
|
-
|
|
7450
|
+
Qe({
|
|
7436
7451
|
position: i,
|
|
7437
7452
|
lngLat: n,
|
|
7438
7453
|
items: [{
|
|
@@ -7453,7 +7468,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7453
7468
|
}]
|
|
7454
7469
|
});
|
|
7455
7470
|
}, []), Tn = useCallback(() => {
|
|
7456
|
-
|
|
7471
|
+
Qe(null);
|
|
7457
7472
|
}, []);
|
|
7458
7473
|
useEffect(() => {
|
|
7459
7474
|
let e = document.createElement("div");
|
|
@@ -7464,11 +7479,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7464
7479
|
width: 100%;
|
|
7465
7480
|
pointer-events: none;
|
|
7466
7481
|
height: 100%;
|
|
7467
|
-
z-index: ${
|
|
7468
|
-
`, document.body.appendChild(e),
|
|
7482
|
+
z-index: ${N?.zIndex ?? 1e3};
|
|
7483
|
+
`, document.body.appendChild(e), Je.current = e, () => {
|
|
7469
7484
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7470
7485
|
};
|
|
7471
|
-
}, [
|
|
7486
|
+
}, [N?.zIndex]), useEffect(() => {
|
|
7472
7487
|
let e = document.createElement("div");
|
|
7473
7488
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
7474
7489
|
position: fixed;
|
|
@@ -7477,65 +7492,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7477
7492
|
width: 100%;
|
|
7478
7493
|
pointer-events: none;
|
|
7479
7494
|
height: 100%;
|
|
7480
|
-
z-index: ${(
|
|
7481
|
-
`, document.body.appendChild(e),
|
|
7495
|
+
z-index: ${(N?.zIndex ?? 1e3) + 100};
|
|
7496
|
+
`, document.body.appendChild(e), $e.current = e, () => {
|
|
7482
7497
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7483
7498
|
};
|
|
7484
|
-
}, [
|
|
7485
|
-
let En = useRef(
|
|
7486
|
-
En.current =
|
|
7487
|
-
let Dn = useRef(
|
|
7488
|
-
Dn.current =
|
|
7499
|
+
}, [N?.zIndex]);
|
|
7500
|
+
let En = useRef(C);
|
|
7501
|
+
En.current = C;
|
|
7502
|
+
let Dn = useRef(ze);
|
|
7503
|
+
Dn.current = ze;
|
|
7489
7504
|
let On = useRef(wt);
|
|
7490
7505
|
On.current = wt;
|
|
7491
|
-
let kn = useRef(
|
|
7492
|
-
kn.current =
|
|
7493
|
-
let An = useRef(
|
|
7494
|
-
An.current =
|
|
7506
|
+
let kn = useRef(z);
|
|
7507
|
+
kn.current = z;
|
|
7508
|
+
let An = useRef(v);
|
|
7509
|
+
An.current = v;
|
|
7495
7510
|
let jn = useRef(ot);
|
|
7496
7511
|
jn.current = ot;
|
|
7497
7512
|
let Mn = useRef(st);
|
|
7498
7513
|
Mn.current = st;
|
|
7499
7514
|
let Nn = useRef(ct);
|
|
7500
7515
|
Nn.current = ct;
|
|
7501
|
-
let Q = useRef(
|
|
7502
|
-
Q.current =
|
|
7503
|
-
let Pn = useRef(
|
|
7504
|
-
Pn.current =
|
|
7516
|
+
let Q = useRef(g);
|
|
7517
|
+
Q.current = g;
|
|
7518
|
+
let Pn = useRef(T);
|
|
7519
|
+
Pn.current = T, useEffect(() => {
|
|
7505
7520
|
let e = (e) => {
|
|
7506
7521
|
if (e.key === "Escape" && J.current) {
|
|
7507
|
-
|
|
7522
|
+
F.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7508
7523
|
return;
|
|
7509
7524
|
}
|
|
7510
|
-
if (e.key === "Escape" &&
|
|
7525
|
+
if (e.key === "Escape" && z === "edit") {
|
|
7511
7526
|
if (ot && (B(null), V(null), Y()), st === "rectangle") if (ct) lt(null), Lt();
|
|
7512
7527
|
else {
|
|
7513
7528
|
V(null);
|
|
7514
|
-
let e =
|
|
7529
|
+
let e = P.current;
|
|
7515
7530
|
e && (e.getCanvas().style.cursor = "");
|
|
7516
7531
|
}
|
|
7517
7532
|
if (st === "circle") if (dt.current) dt.current = null, Ht();
|
|
7518
7533
|
else {
|
|
7519
7534
|
V(null);
|
|
7520
|
-
let e =
|
|
7535
|
+
let e = P.current;
|
|
7521
7536
|
e && (e.getCanvas().style.cursor = "");
|
|
7522
7537
|
}
|
|
7523
7538
|
if (st === "polygon") if (ft.current.length > 0) ft.current = [], Kt();
|
|
7524
7539
|
else {
|
|
7525
7540
|
V(null);
|
|
7526
|
-
let e =
|
|
7541
|
+
let e = P.current;
|
|
7527
7542
|
e && (e.getCanvas().style.cursor = "");
|
|
7528
7543
|
}
|
|
7529
7544
|
if (st === "square") if (pt.current) pt.current = null, Zt();
|
|
7530
7545
|
else {
|
|
7531
7546
|
V(null);
|
|
7532
|
-
let e =
|
|
7547
|
+
let e = P.current;
|
|
7533
7548
|
e && (e.getCanvas().style.cursor = "");
|
|
7534
7549
|
}
|
|
7535
7550
|
if (st === "polyline") if (mt.current.length > 0) mt.current = [], tn();
|
|
7536
7551
|
else {
|
|
7537
7552
|
V(null);
|
|
7538
|
-
let e =
|
|
7553
|
+
let e = P.current;
|
|
7539
7554
|
e && (e.getCanvas().style.cursor = "");
|
|
7540
7555
|
}
|
|
7541
7556
|
}
|
|
@@ -7544,7 +7559,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7544
7559
|
document.removeEventListener("keydown", e);
|
|
7545
7560
|
};
|
|
7546
7561
|
}, [
|
|
7547
|
-
|
|
7562
|
+
z,
|
|
7548
7563
|
ot,
|
|
7549
7564
|
st,
|
|
7550
7565
|
ct,
|
|
@@ -7555,51 +7570,51 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7555
7570
|
Zt,
|
|
7556
7571
|
tn
|
|
7557
7572
|
]), useEffect(() => {
|
|
7558
|
-
let e =
|
|
7559
|
-
if (!e || !
|
|
7560
|
-
let t =
|
|
7573
|
+
let e = P.current;
|
|
7574
|
+
if (!e || !L) return;
|
|
7575
|
+
let t = L.entityId, n = L.config, r = () => {
|
|
7561
7576
|
let r = En.current.find((e) => e.id === t);
|
|
7562
7577
|
if (!r) {
|
|
7563
7578
|
Et();
|
|
7564
7579
|
return;
|
|
7565
7580
|
}
|
|
7566
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7567
|
-
|
|
7581
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Ye.current);
|
|
7582
|
+
Ye.current && (Ye.current.style.left = `${i.x}px`, Ye.current.style.top = `${i.y}px`);
|
|
7568
7583
|
}, i = setTimeout(() => {
|
|
7569
7584
|
r();
|
|
7570
7585
|
}, 50);
|
|
7571
7586
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7572
7587
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7573
7588
|
};
|
|
7574
|
-
}, [
|
|
7575
|
-
let e =
|
|
7576
|
-
if (!e || !
|
|
7577
|
-
let n =
|
|
7589
|
+
}, [L?.entityId, Et]), useEffect(() => {
|
|
7590
|
+
let e = P.current, t = We.current;
|
|
7591
|
+
if (!e || !Ze || !t) return;
|
|
7592
|
+
let n = Ze.lngLat, r = () => {
|
|
7578
7593
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7579
7594
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7580
7595
|
Tn();
|
|
7581
7596
|
return;
|
|
7582
7597
|
}
|
|
7583
7598
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7584
|
-
|
|
7599
|
+
et.current && (et.current.style.left = `${s}px`, et.current.style.top = `${c}px`);
|
|
7585
7600
|
};
|
|
7586
7601
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7587
7602
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7588
7603
|
};
|
|
7589
|
-
}, [
|
|
7590
|
-
if (!
|
|
7604
|
+
}, [Ze?.lngLat, Tn]), useEffect(() => {
|
|
7605
|
+
if (!We.current) return;
|
|
7591
7606
|
let e = {
|
|
7592
7607
|
version: 8,
|
|
7593
7608
|
sources: {},
|
|
7594
7609
|
layers: []
|
|
7595
|
-
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch:
|
|
7596
|
-
container:
|
|
7597
|
-
style:
|
|
7610
|
+
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: ve = !0, boxZoom: ye = !0 } = y, h = new mapboxgl.Map({
|
|
7611
|
+
container: We.current,
|
|
7612
|
+
style: p || e,
|
|
7598
7613
|
center: l,
|
|
7599
7614
|
zoom: u,
|
|
7600
7615
|
pitch: d,
|
|
7601
7616
|
bearing: f,
|
|
7602
|
-
maxBounds:
|
|
7617
|
+
maxBounds: m,
|
|
7603
7618
|
dragPan: t,
|
|
7604
7619
|
scrollZoom: n,
|
|
7605
7620
|
doubleClickZoom: r,
|
|
@@ -7607,8 +7622,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7607
7622
|
keyboard: a,
|
|
7608
7623
|
dragRotate: o,
|
|
7609
7624
|
pitchWithRotate: c,
|
|
7610
|
-
touchPitch:
|
|
7611
|
-
boxZoom:
|
|
7625
|
+
touchPitch: ve,
|
|
7626
|
+
boxZoom: ye,
|
|
7612
7627
|
transformRequest: (e, t) => {
|
|
7613
7628
|
if (t === "Glyphs") {
|
|
7614
7629
|
let t = e.match(/\/fonts\/([^/]+)\/(\d+-\d+)\.pbf/);
|
|
@@ -7620,54 +7635,54 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7620
7635
|
return { url: e };
|
|
7621
7636
|
}
|
|
7622
7637
|
});
|
|
7623
|
-
return
|
|
7624
|
-
if (!
|
|
7625
|
-
let e =
|
|
7638
|
+
return P.current = h, h.on("load", () => {
|
|
7639
|
+
if (!h.getStyle().glyphs) {
|
|
7640
|
+
let e = h.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7626
7641
|
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
7627
7642
|
}
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
}), yn(
|
|
7631
|
-
}),
|
|
7632
|
-
|
|
7643
|
+
I.current.clear(), C.forEach((e) => {
|
|
7644
|
+
I.current.set(e.id, e);
|
|
7645
|
+
}), yn(b), dn(), Ft(), Rt(), Wt(), Jt(), $t(), tt(h), Re?.(h);
|
|
7646
|
+
}), h.on("click", xn), h.on("mousemove", Sn), h.on("contextmenu", Cn), () => {
|
|
7647
|
+
h.off("click", xn), h.off("mousemove", Sn), h.off("contextmenu", Cn), fn(), jt(), Y(), X(), Z(), h.remove(), P.current = null;
|
|
7633
7648
|
};
|
|
7634
7649
|
}, []), useEffect(() => {
|
|
7635
|
-
if (
|
|
7636
|
-
if (!
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7650
|
+
if (P.current) {
|
|
7651
|
+
if (!P.current.isStyleLoaded()) {
|
|
7652
|
+
P.current.once("load", () => {
|
|
7653
|
+
I.current.clear(), C.forEach((e) => {
|
|
7654
|
+
I.current.set(e.id, e);
|
|
7640
7655
|
}), dn();
|
|
7641
7656
|
});
|
|
7642
7657
|
return;
|
|
7643
7658
|
}
|
|
7644
|
-
|
|
7645
|
-
|
|
7659
|
+
I.current.clear(), C.forEach((e) => {
|
|
7660
|
+
I.current.set(e.id, e);
|
|
7646
7661
|
}), dn();
|
|
7647
7662
|
}
|
|
7648
|
-
}, [
|
|
7649
|
-
!
|
|
7663
|
+
}, [C, dn]), useEffect(() => {
|
|
7664
|
+
!P.current || !P.current.isStyleLoaded() || (fn(), dn());
|
|
7650
7665
|
}, [
|
|
7666
|
+
E,
|
|
7651
7667
|
D,
|
|
7652
7668
|
O,
|
|
7653
7669
|
k,
|
|
7654
7670
|
A,
|
|
7655
|
-
j,
|
|
7656
7671
|
fn,
|
|
7657
7672
|
dn
|
|
7658
7673
|
]), useEffect(() => {
|
|
7659
|
-
if (
|
|
7660
|
-
if (!
|
|
7661
|
-
|
|
7662
|
-
yn(
|
|
7674
|
+
if (P.current) {
|
|
7675
|
+
if (!P.current.isStyleLoaded()) {
|
|
7676
|
+
P.current.once("load", () => {
|
|
7677
|
+
yn(b);
|
|
7663
7678
|
});
|
|
7664
7679
|
return;
|
|
7665
7680
|
}
|
|
7666
|
-
yn(
|
|
7681
|
+
yn(b);
|
|
7667
7682
|
}
|
|
7668
|
-
}, [
|
|
7669
|
-
let Fn = useRef(void 0), In = useRef(!0), Ln = useRef(
|
|
7670
|
-
Ln.current =
|
|
7683
|
+
}, [b, yn]);
|
|
7684
|
+
let Fn = useRef(void 0), In = useRef(!0), Ln = useRef(b);
|
|
7685
|
+
Ln.current = b;
|
|
7671
7686
|
let Rn = useRef(yn);
|
|
7672
7687
|
Rn.current = yn;
|
|
7673
7688
|
let zn = useRef(fn);
|
|
@@ -7684,31 +7699,31 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7684
7699
|
Wn.current = Jt;
|
|
7685
7700
|
let Gn = useRef($t);
|
|
7686
7701
|
Gn.current = $t, useEffect(() => {
|
|
7687
|
-
let e =
|
|
7702
|
+
let e = P.current;
|
|
7688
7703
|
if (!e) return;
|
|
7689
|
-
let t =
|
|
7704
|
+
let t = p || {
|
|
7690
7705
|
version: 8,
|
|
7691
7706
|
sources: {},
|
|
7692
7707
|
layers: []
|
|
7693
7708
|
};
|
|
7694
7709
|
if (In.current) {
|
|
7695
|
-
In.current = !1, Fn.current =
|
|
7710
|
+
In.current = !1, Fn.current = p;
|
|
7696
7711
|
return;
|
|
7697
7712
|
}
|
|
7698
|
-
Fn.current !==
|
|
7713
|
+
Fn.current !== p && (Fn.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7699
7714
|
if (!e.getStyle().glyphs) {
|
|
7700
7715
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7701
7716
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7702
7717
|
}
|
|
7703
|
-
|
|
7718
|
+
Ke.current.clear(), Rn.current(Ln.current), zn.current(), Bn.current(), Vn.current(), Hn.current(), Un.current(), Wn.current(), Gn.current();
|
|
7704
7719
|
}));
|
|
7705
|
-
}, [
|
|
7706
|
-
let e = new Set(
|
|
7707
|
-
for (let [t, n] of
|
|
7708
|
-
}, [
|
|
7720
|
+
}, [p]), useEffect(() => {
|
|
7721
|
+
let e = new Set(w.map(String));
|
|
7722
|
+
for (let [t, n] of F.current) n.setSelected(e.has(String(t)));
|
|
7723
|
+
}, [w]);
|
|
7709
7724
|
let Kn = useRef({});
|
|
7710
7725
|
useEffect(() => {
|
|
7711
|
-
let e =
|
|
7726
|
+
let e = P.current;
|
|
7712
7727
|
if (!e) return;
|
|
7713
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;
|
|
7714
7729
|
!n && !r && !i && !a || (Kn.current = {
|
|
@@ -7728,13 +7743,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7728
7743
|
d,
|
|
7729
7744
|
f
|
|
7730
7745
|
]);
|
|
7731
|
-
let qn = (() =>
|
|
7732
|
-
if (
|
|
7746
|
+
let qn = (() => Ee === !1 ? null : Ee === !0 ? { enabled: !0 } : Ee)(), Jn = (() => j === !1 ? null : j === !0 ? { enabled: !0 } : j)(), Yn = (() => De === !1 ? null : De === !0 ? { enabled: !0 } : De)(), $ = (() => {
|
|
7747
|
+
if (Oe === !1) return null;
|
|
7733
7748
|
let e, t, n;
|
|
7734
|
-
if (
|
|
7735
|
-
let r =
|
|
7749
|
+
if (b && b.length > 0) {
|
|
7750
|
+
let r = b.find((e) => e.hasRoadNetwork === !0) || b[0];
|
|
7736
7751
|
if (r.type === "style") {
|
|
7737
|
-
let t =
|
|
7752
|
+
let t = P.current?.getStyle();
|
|
7738
7753
|
if (t?.sources) {
|
|
7739
7754
|
let n = `base-layer-source-${r.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(n));
|
|
7740
7755
|
i && (e = i);
|
|
@@ -7742,63 +7757,63 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7742
7757
|
} else e = `base-layer-source-${r.id}`;
|
|
7743
7758
|
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7744
7759
|
}
|
|
7745
|
-
return
|
|
7760
|
+
return Oe === !0 ? {
|
|
7746
7761
|
enabled: !0,
|
|
7747
7762
|
source: e,
|
|
7748
7763
|
sourceLayer: t,
|
|
7749
7764
|
classField: n
|
|
7750
7765
|
} : {
|
|
7751
|
-
...
|
|
7752
|
-
source:
|
|
7753
|
-
sourceLayer:
|
|
7754
|
-
classField:
|
|
7766
|
+
...Oe,
|
|
7767
|
+
source: Oe.source || e,
|
|
7768
|
+
sourceLayer: Oe.sourceLayer || t,
|
|
7769
|
+
classField: Oe.classField || n
|
|
7755
7770
|
};
|
|
7756
|
-
})(), Xn = (() =>
|
|
7771
|
+
})(), Xn = (() => M ? M === !0 ? { enabled: !0 } : M : null)(), Zn = (() => Ae ? Ae === !0 ? { enabled: !0 } : Ae : null)(), Qn = (() => Pe || null)(), $n = useMemo(() => {
|
|
7757
7772
|
let e = [];
|
|
7758
|
-
for (let t of
|
|
7759
|
-
let n =
|
|
7773
|
+
for (let t of b) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7774
|
+
let n = P.current;
|
|
7760
7775
|
if (n) {
|
|
7761
7776
|
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
7762
7777
|
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
7763
7778
|
}
|
|
7764
7779
|
} else e.push(`base-layer-${t.id}`);
|
|
7765
7780
|
return e;
|
|
7766
|
-
}, [
|
|
7781
|
+
}, [b, R]);
|
|
7767
7782
|
return /* @__PURE__ */ jsxs("div", {
|
|
7768
|
-
className: `comp-mapbox ${
|
|
7769
|
-
style:
|
|
7783
|
+
className: `comp-mapbox ${z === "picker" ? "comp-mapbox--picker-mode" : ""} ${He}`,
|
|
7784
|
+
style: Ue,
|
|
7770
7785
|
children: [
|
|
7771
7786
|
/* @__PURE__ */ jsx("div", {
|
|
7772
|
-
ref:
|
|
7787
|
+
ref: We,
|
|
7773
7788
|
className: "comp-mapbox__map"
|
|
7774
7789
|
}),
|
|
7775
|
-
|
|
7790
|
+
z === "picker" && _.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
7776
7791
|
className: "comp-mapbox__crosshair",
|
|
7777
7792
|
children: [/* @__PURE__ */ jsx("div", {
|
|
7778
7793
|
className: "comp-mapbox__crosshair-h",
|
|
7779
|
-
style:
|
|
7794
|
+
style: _.crosshairColor ? { backgroundColor: _.crosshairColor } : void 0
|
|
7780
7795
|
}), /* @__PURE__ */ jsx("div", {
|
|
7781
7796
|
className: "comp-mapbox__crosshair-v",
|
|
7782
|
-
style:
|
|
7797
|
+
style: _.crosshairColor ? { backgroundColor: _.crosshairColor } : void 0
|
|
7783
7798
|
})]
|
|
7784
7799
|
}),
|
|
7785
|
-
|
|
7800
|
+
z === "edit" && g.showEditTools !== !1 && (g.markerTemplates && g.markerTemplates.length > 0 || g.showRectangleTool || g.showCircleTool || g.showPolygonTool || g.showSquareTool || g.showPolylineTool) || $ && $.enabled !== !1 || Qn && Qn.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
|
|
7786
7801
|
className: "comp-mapbox__edit-controls",
|
|
7787
7802
|
children: [
|
|
7788
|
-
|
|
7789
|
-
markerTemplates:
|
|
7803
|
+
z === "edit" && g.showEditTools !== !1 && (g.markerTemplates && g.markerTemplates.length > 0 || g.showRectangleTool || g.showCircleTool || g.showPolygonTool || g.showSquareTool || g.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7804
|
+
markerTemplates: g.markerTemplates || [],
|
|
7790
7805
|
selectedTemplate: ot,
|
|
7791
7806
|
onTemplateSelect: nn,
|
|
7792
7807
|
drawMode: st,
|
|
7793
7808
|
onDrawModeChange: rn,
|
|
7794
|
-
showRectangleTool:
|
|
7795
|
-
showCircleTool:
|
|
7796
|
-
showPolygonTool:
|
|
7797
|
-
showSquareTool:
|
|
7798
|
-
showPolylineTool:
|
|
7809
|
+
showRectangleTool: g.showRectangleTool,
|
|
7810
|
+
showCircleTool: g.showCircleTool,
|
|
7811
|
+
showPolygonTool: g.showPolygonTool,
|
|
7812
|
+
showSquareTool: g.showSquareTool,
|
|
7813
|
+
showPolylineTool: g.showPolylineTool
|
|
7799
7814
|
}),
|
|
7800
7815
|
$ && $.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7801
|
-
map:
|
|
7816
|
+
map: R,
|
|
7802
7817
|
highlightWidth: $.highlightWidth,
|
|
7803
7818
|
defaultRoadTypes: $.defaultRoadTypes,
|
|
7804
7819
|
defaultMinWidth: $.defaultMinWidth,
|
|
@@ -7809,8 +7824,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7809
7824
|
style: $.style
|
|
7810
7825
|
}),
|
|
7811
7826
|
Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7812
|
-
ref:
|
|
7813
|
-
map:
|
|
7827
|
+
ref: Ge,
|
|
7828
|
+
map: R,
|
|
7814
7829
|
pointCount: Qn.pointCount,
|
|
7815
7830
|
showPointCountInput: Qn.showPointCountInput,
|
|
7816
7831
|
visualType: Qn.visualType,
|
|
@@ -7822,21 +7837,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7822
7837
|
className: "comp-mapbox__controls",
|
|
7823
7838
|
children: [
|
|
7824
7839
|
qn && qn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7825
|
-
map:
|
|
7840
|
+
map: R,
|
|
7826
7841
|
precision: qn.precision,
|
|
7827
7842
|
className: qn.className,
|
|
7828
7843
|
style: qn.style
|
|
7829
7844
|
}),
|
|
7830
7845
|
Jn && Jn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7831
|
-
map:
|
|
7846
|
+
map: R,
|
|
7832
7847
|
maxWidth: Jn.maxWidth,
|
|
7833
7848
|
unit: Jn.unit,
|
|
7834
7849
|
className: Jn.className,
|
|
7835
7850
|
style: Jn.style
|
|
7836
7851
|
}),
|
|
7837
7852
|
Xn && Xn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7838
|
-
map:
|
|
7839
|
-
entityConfig:
|
|
7853
|
+
map: R,
|
|
7854
|
+
entityConfig: T,
|
|
7840
7855
|
onDrawModeChange: (e) => {
|
|
7841
7856
|
gt.current = e;
|
|
7842
7857
|
},
|
|
@@ -7844,15 +7859,15 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7844
7859
|
style: Xn.style
|
|
7845
7860
|
}),
|
|
7846
7861
|
Zn && Zn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7847
|
-
map:
|
|
7848
|
-
value:
|
|
7849
|
-
onChange:
|
|
7862
|
+
map: R,
|
|
7863
|
+
value: x,
|
|
7864
|
+
onChange: Fe,
|
|
7850
7865
|
rasterPaintLayerIds: $n,
|
|
7851
7866
|
className: Zn.className,
|
|
7852
7867
|
style: Zn.style
|
|
7853
7868
|
}),
|
|
7854
7869
|
Yn && Yn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7855
|
-
map:
|
|
7870
|
+
map: R,
|
|
7856
7871
|
initialCenter: l,
|
|
7857
7872
|
initialZoom: u,
|
|
7858
7873
|
initialPitch: d,
|
|
@@ -7864,21 +7879,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7864
7879
|
]
|
|
7865
7880
|
}),
|
|
7866
7881
|
!(Qn && Qn.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7867
|
-
ref:
|
|
7868
|
-
map:
|
|
7882
|
+
ref: Ge,
|
|
7883
|
+
map: R,
|
|
7869
7884
|
showButton: !1
|
|
7870
7885
|
}),
|
|
7871
|
-
|
|
7872
|
-
popupState:
|
|
7873
|
-
onClose: () => Tt(
|
|
7874
|
-
portalContainer:
|
|
7875
|
-
popupRef:
|
|
7886
|
+
L && Je.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7887
|
+
popupState: L,
|
|
7888
|
+
onClose: () => Tt(L.entityId),
|
|
7889
|
+
portalContainer: Je.current,
|
|
7890
|
+
popupRef: Ye
|
|
7876
7891
|
}),
|
|
7877
|
-
|
|
7878
|
-
menuState:
|
|
7892
|
+
Ze && $e.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7893
|
+
menuState: Ze,
|
|
7879
7894
|
onClose: Tn,
|
|
7880
|
-
portalContainer:
|
|
7881
|
-
menuRef:
|
|
7895
|
+
portalContainer: $e.current,
|
|
7896
|
+
menuRef: et
|
|
7882
7897
|
})
|
|
7883
7898
|
]
|
|
7884
7899
|
});
|