bbl-mapbox-react 0.0.18 → 0.0.20
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/RoadHighlightControl.d.ts +3 -1
- package/dist/components/RoutePlanningControl.d.ts +1 -1
- package/dist/index.cjs +21 -21
- package/dist/index.mjs +973 -966
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1781,8 +1781,8 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
1781
1781
|
if (d === 0) return Math.sqrt((r - a) * (r - a) + (i - o) * (i - o));
|
|
1782
1782
|
let f = ((r - a) * l + (i - o) * u) / d;
|
|
1783
1783
|
f = Math.max(0, Math.min(1, f));
|
|
1784
|
-
let p = a + f * l,
|
|
1785
|
-
return Math.sqrt((r - p) * (r - p) + (i -
|
|
1784
|
+
let p = a + f * l, ve = o + f * u;
|
|
1785
|
+
return Math.sqrt((r - p) * (r - p) + (i - ve) * (i - ve));
|
|
1786
1786
|
}
|
|
1787
1787
|
update(t) {
|
|
1788
1788
|
let n = this.entity;
|
|
@@ -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, m] = useState(!1), h = useRef(e.position), g = useRef(!1), _ = s || c;
|
|
3936
|
+
g.current || (h.current = e.position), useEffect(() => {
|
|
3937
3937
|
let e = setTimeout(() => {
|
|
3938
|
-
|
|
3938
|
+
m(!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 v = useCallback(() => {
|
|
3948
|
+
e.config.animation === "none" ? r() : (g.current = !0, u("exiting"), setTimeout(() => r(), 200));
|
|
3949
3949
|
}, [e.config.animation, r]);
|
|
3950
3950
|
useEffect(() => {
|
|
3951
3951
|
if (!e.config.closeOnEscape) return;
|
|
3952
3952
|
let t = (e) => {
|
|
3953
|
-
e.key === "Escape" &&
|
|
3953
|
+
e.key === "Escape" && v();
|
|
3954
3954
|
};
|
|
3955
3955
|
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
3956
|
-
}, [e.config.closeOnEscape,
|
|
3956
|
+
}, [e.config.closeOnEscape, v]), useEffect(() => {
|
|
3957
3957
|
if (!e.config.closeOnClickOutside) return;
|
|
3958
3958
|
let t = (e) => {
|
|
3959
|
-
|
|
3959
|
+
_.current && !_.current.contains(e.target) && v();
|
|
3960
3960
|
}, n = setTimeout(() => {
|
|
3961
3961
|
document.addEventListener("click", t, !0);
|
|
3962
3962
|
}, 0);
|
|
@@ -3965,10 +3965,10 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
3965
3965
|
};
|
|
3966
3966
|
}, [
|
|
3967
3967
|
e.config.closeOnClickOutside,
|
|
3968
|
-
|
|
3969
|
-
|
|
3968
|
+
v,
|
|
3969
|
+
_
|
|
3970
3970
|
]);
|
|
3971
|
-
let
|
|
3971
|
+
let y = () => {
|
|
3972
3972
|
switch (e.actualPosition) {
|
|
3973
3973
|
case "top": return "center bottom";
|
|
3974
3974
|
case "bottom": return "center top";
|
|
@@ -3977,25 +3977,25 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
3977
3977
|
case "center":
|
|
3978
3978
|
default: return "center center";
|
|
3979
3979
|
}
|
|
3980
|
-
},
|
|
3981
|
-
ref:
|
|
3980
|
+
}, b = h.current, x = /* @__PURE__ */ jsxs("div", {
|
|
3981
|
+
ref: _,
|
|
3982
3982
|
className: `entity-popup ${d ? `entity-popup--${l} animation-${e.config.animation}` : ""} ${e.config.className || ""}`,
|
|
3983
3983
|
style: {
|
|
3984
3984
|
position: "fixed",
|
|
3985
|
-
left: `${
|
|
3986
|
-
top: `${
|
|
3985
|
+
left: `${b.x}px`,
|
|
3986
|
+
top: `${b.y}px`,
|
|
3987
3987
|
maxWidth: e.config.maxWidth,
|
|
3988
3988
|
zIndex: e.config.zIndex,
|
|
3989
3989
|
pointerEvents: "all",
|
|
3990
3990
|
opacity: d ? void 0 : 0,
|
|
3991
|
-
transformOrigin:
|
|
3991
|
+
transformOrigin: y(),
|
|
3992
3992
|
...e.config.style
|
|
3993
3993
|
},
|
|
3994
3994
|
role: "dialog",
|
|
3995
3995
|
"aria-modal": "true",
|
|
3996
3996
|
children: [e.config.showCloseButton && /* @__PURE__ */ jsx("button", {
|
|
3997
3997
|
className: "entity-popup__close",
|
|
3998
|
-
onClick:
|
|
3998
|
+
onClick: v,
|
|
3999
3999
|
"aria-label": "Close popup",
|
|
4000
4000
|
children: "×"
|
|
4001
4001
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -4003,7 +4003,7 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef:
|
|
|
4003
4003
|
children: e.config.content
|
|
4004
4004
|
})]
|
|
4005
4005
|
});
|
|
4006
|
-
return createPortal(
|
|
4006
|
+
return createPortal(x, i);
|
|
4007
4007
|
};
|
|
4008
4008
|
var location_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768373933818'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='30344'%20width='200'%20height='200'%3e%3cpath%20d='M400.440142%201024h-0.073136a48.781895%2048.781895%200%200%201-45.490763-31.448598L3.383306%2066.061072a48.781895%2048.781895%200%200%201%2062.897196-62.897197l926.563466%20351.419801a48.928168%2048.928168%200%200%201%200.219409%2091.127799L597.761811%20597.688654l-151.904042%20395.082157a48.781895%2048.781895%200%200%201-45.490763%2031.229189zM133.053921%20132.907627l267.678766%20705.691916%20113.87318-296.201913a48.855032%2048.855032%200%200%201%2028.011193-27.938057l296.201913-113.87318-705.765052-267.678766z'%20p-id='30345'%20fill='%23ffffff'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e";
|
|
4009
4009
|
function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style: a }) {
|
|
@@ -4167,9 +4167,9 @@ function detectVectorSource(e) {
|
|
|
4167
4167
|
};
|
|
4168
4168
|
return null;
|
|
4169
4169
|
}
|
|
4170
|
-
function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u,
|
|
4171
|
-
let [g, _] = useState(!1), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(null), C = useRef(null), w = useRef(null), T = useCallback((e, t, n) => {
|
|
4172
|
-
if (!e.isStyleLoaded()) return !1;
|
|
4170
|
+
function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u, classField: d = "class", className: f = "", style: h }) {
|
|
4171
|
+
let [g, _] = useState(!1), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(!1), ye = useRef(null), C = useRef(null), w = useRef(null), T = useCallback((e, t, n) => {
|
|
4172
|
+
if (!e.isStyleLoaded() || !e.getSource(t)) return !1;
|
|
4173
4173
|
let i = !0;
|
|
4174
4174
|
return ROAD_TYPE_OPTIONS.forEach((a) => {
|
|
4175
4175
|
let o = `${LAYER_ID_PREFIX}${a.class}`;
|
|
@@ -4181,7 +4181,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4181
4181
|
"source-layer": n,
|
|
4182
4182
|
filter: [
|
|
4183
4183
|
"==",
|
|
4184
|
-
["get",
|
|
4184
|
+
["get", d],
|
|
4185
4185
|
a.class
|
|
4186
4186
|
],
|
|
4187
4187
|
paint: {
|
|
@@ -4195,7 +4195,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4195
4195
|
console.error(`Failed to add road highlight layer for ${a.class}:`, e), i = !1;
|
|
4196
4196
|
}
|
|
4197
4197
|
}), i;
|
|
4198
|
-
}, [r]);
|
|
4198
|
+
}, [r, d]);
|
|
4199
4199
|
useEffect(() => {
|
|
4200
4200
|
if (!e) return;
|
|
4201
4201
|
let t = () => {
|
|
@@ -4204,14 +4204,16 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4204
4204
|
let r = detectVectorSource(e);
|
|
4205
4205
|
r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
|
|
4206
4206
|
}
|
|
4207
|
-
t && n ? T(e, t, n) && x(!0) : console.warn("No vector source found for road highlighting");
|
|
4207
|
+
t && n ? T(e, t, n) && (S.current = !0, x(!0)) : console.warn("No vector source found for road highlighting");
|
|
4208
4208
|
};
|
|
4209
4209
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4210
4210
|
let n = () => {
|
|
4211
4211
|
e.isStyleLoaded() && t();
|
|
4212
|
+
}, r = () => {
|
|
4213
|
+
S.current || t();
|
|
4212
4214
|
};
|
|
4213
|
-
return e.on("styledata", n), () => {
|
|
4214
|
-
e.off("styledata", n);
|
|
4215
|
+
return e.on("styledata", n), e.on("sourcedata", r), () => {
|
|
4216
|
+
e.off("styledata", n), e.off("sourcedata", r);
|
|
4215
4217
|
};
|
|
4216
4218
|
}, [
|
|
4217
4219
|
e,
|
|
@@ -4235,7 +4237,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4235
4237
|
]), useEffect(() => {
|
|
4236
4238
|
if (!g) return;
|
|
4237
4239
|
let e = (e) => {
|
|
4238
|
-
|
|
4240
|
+
ye.current && !ye.current.contains(e.target) && C.current && !C.current.contains(e.target) && _(!1);
|
|
4239
4241
|
}, t = setTimeout(() => {
|
|
4240
4242
|
document.addEventListener("mousedown", e);
|
|
4241
4243
|
}, 0);
|
|
@@ -4250,18 +4252,18 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4250
4252
|
} catch {}
|
|
4251
4253
|
}), w.current &&= (w.current.remove(), null);
|
|
4252
4254
|
}, [e]);
|
|
4253
|
-
let
|
|
4255
|
+
let be = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), xe = useCallback((t) => {
|
|
4254
4256
|
if (!e || v.length === 0) {
|
|
4255
4257
|
w.current && w.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
|
|
4256
4258
|
return;
|
|
4257
4259
|
}
|
|
4258
4260
|
let n = v.map((e) => `${LAYER_ID_PREFIX}${e}`), r = [[t.point.x - 10, t.point.y - 10], [t.point.x + 10, t.point.y + 10]], i = e.queryRenderedFeatures(r, { layers: n.filter((t) => e.getLayer(t)) });
|
|
4259
4261
|
if (i.length > 0) {
|
|
4260
|
-
let n = i[0].properties || {}, r = t.lngLat, a = n.name || n.name_en || n.name_local || "", o = n
|
|
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 || "", m = (e) => !(e == null || e === "" || typeof e == "string" && e.toLowerCase() === "none"), h = [];
|
|
4261
4263
|
m(o) && h.push(`
|
|
4262
4264
|
<div class="road-highlight-popup__row">
|
|
4263
4265
|
<span>道路类型:</span>
|
|
4264
|
-
<span class="road-highlight-popup__value">${
|
|
4266
|
+
<span class="road-highlight-popup__value">${be(o)}</span>
|
|
4265
4267
|
</div>
|
|
4266
4268
|
`), h.push(`
|
|
4267
4269
|
<div class="road-highlight-popup__row">
|
|
@@ -4288,20 +4290,20 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4288
4290
|
<span>单行道:</span>
|
|
4289
4291
|
<span class="road-highlight-popup__value">${u ? "是" : "否"}</span>
|
|
4290
4292
|
</div>
|
|
4291
|
-
`), m(
|
|
4293
|
+
`), m(f) && h.push(`
|
|
4292
4294
|
<div class="road-highlight-popup__row">
|
|
4293
4295
|
<span>层级:</span>
|
|
4294
|
-
<span class="road-highlight-popup__value">${
|
|
4296
|
+
<span class="road-highlight-popup__value">${f}</span>
|
|
4295
4297
|
</div>
|
|
4296
|
-
`), m(
|
|
4298
|
+
`), m(p) && h.push(`
|
|
4297
4299
|
<div class="road-highlight-popup__row">
|
|
4298
4300
|
<span>国家代码:</span>
|
|
4299
|
-
<span class="road-highlight-popup__value">${
|
|
4301
|
+
<span class="road-highlight-popup__value">${p}</span>
|
|
4300
4302
|
</div>
|
|
4301
|
-
`), m(
|
|
4303
|
+
`), m(ve) && h.push(`
|
|
4302
4304
|
<div class="road-highlight-popup__row">
|
|
4303
4305
|
<span>地区代码:</span>
|
|
4304
|
-
<span class="road-highlight-popup__value">${
|
|
4306
|
+
<span class="road-highlight-popup__value">${ve}</span>
|
|
4305
4307
|
</div>
|
|
4306
4308
|
`);
|
|
4307
4309
|
let g = `
|
|
@@ -4320,28 +4322,29 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4320
4322
|
}, [
|
|
4321
4323
|
e,
|
|
4322
4324
|
v,
|
|
4323
|
-
|
|
4325
|
+
be,
|
|
4326
|
+
d
|
|
4324
4327
|
]);
|
|
4325
4328
|
useEffect(() => {
|
|
4326
|
-
if (!(!e || !b)) return e.on("mousemove",
|
|
4327
|
-
e.off("mousemove",
|
|
4329
|
+
if (!(!e || !b)) return e.on("mousemove", xe), () => {
|
|
4330
|
+
e.off("mousemove", xe), w.current && w.current.remove(), e.getCanvas().style.cursor = "";
|
|
4328
4331
|
};
|
|
4329
4332
|
}, [
|
|
4330
4333
|
e,
|
|
4331
4334
|
b,
|
|
4332
|
-
|
|
4335
|
+
xe
|
|
4333
4336
|
]);
|
|
4334
|
-
let
|
|
4337
|
+
let D = (e, t) => {
|
|
4335
4338
|
y((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
4336
|
-
},
|
|
4339
|
+
}, Se = (e) => {
|
|
4337
4340
|
y(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
|
|
4338
|
-
},
|
|
4341
|
+
}, Ce = v.length > 0;
|
|
4339
4342
|
return /* @__PURE__ */ jsxs("div", {
|
|
4340
|
-
className: `mapbox-road-highlight-control ${
|
|
4341
|
-
style:
|
|
4343
|
+
className: `mapbox-road-highlight-control ${f}`,
|
|
4344
|
+
style: h,
|
|
4342
4345
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
4343
4346
|
ref: C,
|
|
4344
|
-
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${
|
|
4347
|
+
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${Ce ? "mapbox-road-highlight-control__btn--active" : ""}`,
|
|
4345
4348
|
onClick: () => _(!g),
|
|
4346
4349
|
title: `路网高亮${v.length > 0 ? ` (已选 ${v.length})` : ""}`,
|
|
4347
4350
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -4350,7 +4353,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4350
4353
|
className: "mapbox-road-highlight-control__btn-icon"
|
|
4351
4354
|
}), /* @__PURE__ */ jsxs("span", { children: ["路网", v.length > 0 ? ` (${v.length})` : ""] })]
|
|
4352
4355
|
}), g && /* @__PURE__ */ jsxs("div", {
|
|
4353
|
-
ref:
|
|
4356
|
+
ref: ye,
|
|
4354
4357
|
className: "mapbox-road-highlight-control__panel",
|
|
4355
4358
|
children: [
|
|
4356
4359
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -4361,7 +4364,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4361
4364
|
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
4362
4365
|
checked: v.length === ROAD_TYPE_OPTIONS.length,
|
|
4363
4366
|
indeterminate: v.length > 0 && v.length < ROAD_TYPE_OPTIONS.length,
|
|
4364
|
-
onChange:
|
|
4367
|
+
onChange: Se,
|
|
4365
4368
|
style: {
|
|
4366
4369
|
"--color-text-1": "#fff",
|
|
4367
4370
|
"--color-border-2": "rgba(255, 255, 255, 0.3)"
|
|
@@ -4378,11 +4381,11 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
4378
4381
|
className: "mapbox-road-highlight-control__type-list",
|
|
4379
4382
|
children: ROAD_TYPE_OPTIONS.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
4380
4383
|
className: "mapbox-road-highlight-control__type-item",
|
|
4381
|
-
onClick: () =>
|
|
4384
|
+
onClick: () => D(e.class, !v.includes(e.class)),
|
|
4382
4385
|
children: [
|
|
4383
4386
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4384
4387
|
checked: v.includes(e.class),
|
|
4385
|
-
onChange: (t) =>
|
|
4388
|
+
onChange: (t) => D(e.class, t),
|
|
4386
4389
|
onClick: (e) => e.stopPropagation(),
|
|
4387
4390
|
style: {
|
|
4388
4391
|
"--color-text-1": "#fff",
|
|
@@ -4656,64 +4659,64 @@ function clearAllPreviewSources(e) {
|
|
|
4656
4659
|
]) clearPreviewSource(e, `${PREVIEW_PREFIX}${t}`);
|
|
4657
4660
|
}
|
|
4658
4661
|
function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDrawModeChange: s, className: c = "", style: l }) {
|
|
4659
|
-
let [u, d] = useState(!1), [f,
|
|
4662
|
+
let [u, d] = useState(!1), [f, h] = useState(null), [g, _] = useState({
|
|
4660
4663
|
showArea: !0,
|
|
4661
4664
|
showLength: !0,
|
|
4662
4665
|
showRadius: !0
|
|
4663
|
-
}),
|
|
4666
|
+
}), v = r !== void 0, y = v ? {
|
|
4664
4667
|
showArea: r.showArea ?? !0,
|
|
4665
4668
|
showLength: r.showLength ?? !0,
|
|
4666
4669
|
showRadius: r.showRadius ?? !0
|
|
4667
|
-
} :
|
|
4668
|
-
|
|
4669
|
-
let
|
|
4670
|
-
|
|
4671
|
-
let
|
|
4670
|
+
} : g, [b, x] = useState([]), S = useRef(/* @__PURE__ */ new Map()), C = useRef(0), w = useRef(null), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef([]), A = useRef([]), j = useRef(y);
|
|
4671
|
+
j.current = y;
|
|
4672
|
+
let Te = useRef(f);
|
|
4673
|
+
Te.current = f;
|
|
4674
|
+
let M = useCallback(() => `measure-${++C.current}`, []);
|
|
4672
4675
|
useEffect(() => {
|
|
4673
4676
|
s?.(f !== null);
|
|
4674
4677
|
}, [f, s]);
|
|
4675
|
-
let
|
|
4676
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
4678
|
+
let Ee = useRef(!1), De = useCallback(() => {
|
|
4679
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), Ee.current = !0);
|
|
4677
4680
|
}, [e]);
|
|
4678
4681
|
useEffect(() => {
|
|
4679
4682
|
if (!e) return;
|
|
4680
4683
|
let t = () => {
|
|
4681
|
-
initAllPreviewLayers(e),
|
|
4684
|
+
initAllPreviewLayers(e), Ee.current = !0;
|
|
4682
4685
|
};
|
|
4683
4686
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4684
4687
|
let n = () => {
|
|
4685
|
-
|
|
4688
|
+
Ee.current = !1;
|
|
4686
4689
|
};
|
|
4687
4690
|
return e.on("style.load", n), () => {
|
|
4688
4691
|
e.off("style.load", n);
|
|
4689
4692
|
};
|
|
4690
4693
|
}, [e]), useEffect(() => {
|
|
4691
4694
|
let e = (e) => {
|
|
4692
|
-
|
|
4695
|
+
w.current && !w.current.contains(e.target) && T.current && !T.current.contains(e.target) && d(!1);
|
|
4693
4696
|
};
|
|
4694
4697
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4695
4698
|
}, []);
|
|
4696
|
-
let
|
|
4699
|
+
let N = useCallback((t) => {
|
|
4697
4700
|
if (!e) return;
|
|
4698
|
-
let n = applyEntityConfig(t,
|
|
4701
|
+
let n = applyEntityConfig(t, j.current), r = null;
|
|
4699
4702
|
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) {
|
|
4700
|
-
|
|
4703
|
+
S.current.set(n.id, r);
|
|
4701
4704
|
let e = {
|
|
4702
4705
|
entity: n,
|
|
4703
4706
|
shapeLabel: SHAPE_LABELS[n.type] || n.type,
|
|
4704
4707
|
area: computeEntityArea(n),
|
|
4705
4708
|
lengthOrRadius: computeEntityLengthOrRadius(n)
|
|
4706
4709
|
};
|
|
4707
|
-
|
|
4708
|
-
}
|
|
4709
|
-
}, [e]),
|
|
4710
|
-
let t =
|
|
4711
|
-
t && (t.destroy(),
|
|
4712
|
-
}, []),
|
|
4713
|
-
|
|
4714
|
-
}, []),
|
|
4710
|
+
x((t) => [...t, e]);
|
|
4711
|
+
}
|
|
4712
|
+
}, [e]), Oe = useCallback((e) => {
|
|
4713
|
+
let t = S.current.get(e);
|
|
4714
|
+
t && (t.destroy(), S.current.delete(e)), x((t) => t.filter((t) => t.entity.id !== e));
|
|
4715
|
+
}, []), ke = useCallback(() => {
|
|
4716
|
+
S.current.forEach((e) => e.destroy()), S.current.clear(), x([]);
|
|
4717
|
+
}, []), Ae = useCallback((t) => {
|
|
4715
4718
|
if (!e) return;
|
|
4716
|
-
let n =
|
|
4719
|
+
let n = S.current.get(t);
|
|
4717
4720
|
if (!n) return;
|
|
4718
4721
|
let r = n.getBounds();
|
|
4719
4722
|
e.fitBounds(r, {
|
|
@@ -4721,21 +4724,21 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4721
4724
|
maxZoom: 18,
|
|
4722
4725
|
duration: 1e3
|
|
4723
4726
|
});
|
|
4724
|
-
}, [e]),
|
|
4727
|
+
}, [e]), je = useCallback((e, t) => {
|
|
4725
4728
|
let n = {
|
|
4726
|
-
...
|
|
4729
|
+
...j.current,
|
|
4727
4730
|
[e]: t
|
|
4728
4731
|
};
|
|
4729
|
-
|
|
4732
|
+
v ? i?.({ ...n }) : _(n), x((t) => t.map((t) => {
|
|
4730
4733
|
let r = { ...t.entity };
|
|
4731
4734
|
r[e] = void 0;
|
|
4732
|
-
let i = applyEntityConfig(r, n), a =
|
|
4735
|
+
let i = applyEntityConfig(r, n), a = S.current.get(t.entity.id);
|
|
4733
4736
|
return a && a.update(i), {
|
|
4734
4737
|
...t,
|
|
4735
4738
|
entity: i
|
|
4736
4739
|
};
|
|
4737
4740
|
}));
|
|
4738
|
-
}, [
|
|
4741
|
+
}, [v, i]), Me = useCallback((t, n) => {
|
|
4739
4742
|
if (!e) return;
|
|
4740
4743
|
let [r, i] = t, [a, o] = n, s = [
|
|
4741
4744
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -4754,7 +4757,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4754
4757
|
});
|
|
4755
4758
|
let l = e.getSource(`${PREVIEW_PREFIX}rect-preview-measure-source`);
|
|
4756
4759
|
if (l) {
|
|
4757
|
-
let e =
|
|
4760
|
+
let e = j.current, t = [], n = s[0], r = s[1], i = s[2];
|
|
4758
4761
|
if (e?.showArea) {
|
|
4759
4762
|
let e = distance(n, r), a = distance(r, i);
|
|
4760
4763
|
t.push({
|
|
@@ -4785,7 +4788,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4785
4788
|
features: t
|
|
4786
4789
|
});
|
|
4787
4790
|
}
|
|
4788
|
-
}, [e]),
|
|
4791
|
+
}, [e]), Ne = useCallback((t, n) => {
|
|
4789
4792
|
if (!e) return;
|
|
4790
4793
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
4791
4794
|
a && a.setData({
|
|
@@ -4796,7 +4799,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4796
4799
|
},
|
|
4797
4800
|
properties: {}
|
|
4798
4801
|
});
|
|
4799
|
-
let o =
|
|
4802
|
+
let o = j.current, s = [], c = [];
|
|
4800
4803
|
if (o?.showArea && s.push({
|
|
4801
4804
|
type: "Feature",
|
|
4802
4805
|
geometry: {
|
|
@@ -4832,7 +4835,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4832
4835
|
type: "FeatureCollection",
|
|
4833
4836
|
features: c
|
|
4834
4837
|
});
|
|
4835
|
-
}, [e]),
|
|
4838
|
+
}, [e]), Pe = useCallback((t, n) => {
|
|
4836
4839
|
if (!e) return;
|
|
4837
4840
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
4838
4841
|
a && a.setData({
|
|
@@ -4845,7 +4848,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4845
4848
|
});
|
|
4846
4849
|
let o = e.getSource(`${PREVIEW_PREFIX}square-preview-measure-source`);
|
|
4847
4850
|
if (o) {
|
|
4848
|
-
let e =
|
|
4851
|
+
let e = j.current, n = [];
|
|
4849
4852
|
if (e?.showArea && n.push({
|
|
4850
4853
|
type: "Feature",
|
|
4851
4854
|
geometry: {
|
|
@@ -4869,7 +4872,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4869
4872
|
features: n
|
|
4870
4873
|
});
|
|
4871
4874
|
}
|
|
4872
|
-
}, [e]),
|
|
4875
|
+
}, [e]), Fe = useCallback((t, n) => {
|
|
4873
4876
|
if (!e) return;
|
|
4874
4877
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
4875
4878
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -4904,7 +4907,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4904
4907
|
});
|
|
4905
4908
|
let o = e.getSource(`${PREVIEW_PREFIX}polygon-preview-measure-source`);
|
|
4906
4909
|
if (o) {
|
|
4907
|
-
let e =
|
|
4910
|
+
let e = j.current, t = [];
|
|
4908
4911
|
if (e?.showArea && r.length >= 3) {
|
|
4909
4912
|
let e = polygonArea([...r, r[0]]), n = 0, i = 0;
|
|
4910
4913
|
for (let e of r) n += e[0], i += e[1];
|
|
@@ -4946,7 +4949,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4946
4949
|
features: t
|
|
4947
4950
|
});
|
|
4948
4951
|
}
|
|
4949
|
-
}, [e]),
|
|
4952
|
+
}, [e]), P = useCallback((t, n) => {
|
|
4950
4953
|
if (!e) return;
|
|
4951
4954
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
4952
4955
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -4974,7 +4977,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4974
4977
|
});
|
|
4975
4978
|
let o = e.getSource(`${PREVIEW_PREFIX}polyline-preview-measure-source`);
|
|
4976
4979
|
if (o) {
|
|
4977
|
-
let e =
|
|
4980
|
+
let e = j.current, t = [];
|
|
4978
4981
|
if (e?.showLength && r.length >= 2) for (let e = 0; e < r.length - 1; e++) {
|
|
4979
4982
|
let n = r[e], i = r[e + 1];
|
|
4980
4983
|
t.push({
|
|
@@ -4994,117 +4997,117 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4994
4997
|
}, [e]);
|
|
4995
4998
|
useEffect(() => {
|
|
4996
4999
|
if (!e || !f) return;
|
|
4997
|
-
|
|
5000
|
+
De(), e.getCanvas().style.cursor = "crosshair";
|
|
4998
5001
|
let t = (t) => {
|
|
4999
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
5002
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = Te.current;
|
|
5000
5003
|
if (r === "rectangle") {
|
|
5001
|
-
let t =
|
|
5002
|
-
if (!t)
|
|
5004
|
+
let t = E.current;
|
|
5005
|
+
if (!t) E.current = n;
|
|
5003
5006
|
else {
|
|
5004
5007
|
let r = {
|
|
5005
|
-
id:
|
|
5008
|
+
id: M(),
|
|
5006
5009
|
type: "rectangle",
|
|
5007
5010
|
bounds: [t, n]
|
|
5008
5011
|
};
|
|
5009
|
-
|
|
5012
|
+
N(r), E.current = null, clearAllPreviewSources(e), h(null);
|
|
5010
5013
|
}
|
|
5011
5014
|
} else if (r === "circle") {
|
|
5012
|
-
let t =
|
|
5013
|
-
if (!t)
|
|
5015
|
+
let t = D.current;
|
|
5016
|
+
if (!t) D.current = { center: n };
|
|
5014
5017
|
else {
|
|
5015
5018
|
let r = calculateDistance(t.center, n), i = {
|
|
5016
|
-
id:
|
|
5019
|
+
id: M(),
|
|
5017
5020
|
type: "circle",
|
|
5018
5021
|
center: t.center,
|
|
5019
5022
|
radius: r
|
|
5020
5023
|
};
|
|
5021
|
-
|
|
5024
|
+
N(i), D.current = null, clearAllPreviewSources(e), h(null);
|
|
5022
5025
|
}
|
|
5023
5026
|
} else if (r === "square") {
|
|
5024
|
-
let t =
|
|
5025
|
-
if (!t)
|
|
5027
|
+
let t = O.current;
|
|
5028
|
+
if (!t) O.current = { center: n };
|
|
5026
5029
|
else {
|
|
5027
5030
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
5028
|
-
id:
|
|
5031
|
+
id: M(),
|
|
5029
5032
|
type: "square",
|
|
5030
5033
|
center: t.center,
|
|
5031
5034
|
length: r
|
|
5032
5035
|
};
|
|
5033
|
-
|
|
5036
|
+
N(i), O.current = null, clearAllPreviewSources(e), h(null);
|
|
5034
5037
|
}
|
|
5035
5038
|
} else if (r === "polygon") {
|
|
5036
|
-
let t =
|
|
5039
|
+
let t = k.current;
|
|
5037
5040
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
5038
5041
|
let n = {
|
|
5039
|
-
id:
|
|
5042
|
+
id: M(),
|
|
5040
5043
|
type: "polygon",
|
|
5041
5044
|
coordinates: [...t]
|
|
5042
5045
|
};
|
|
5043
|
-
|
|
5046
|
+
N(n), k.current = [], clearAllPreviewSources(e), h(null);
|
|
5044
5047
|
return;
|
|
5045
5048
|
}
|
|
5046
|
-
|
|
5047
|
-
} else r === "polyline" && (
|
|
5049
|
+
k.current = [...t, n];
|
|
5050
|
+
} else r === "polyline" && (A.current = [...A.current, n]);
|
|
5048
5051
|
}, n = (e) => {
|
|
5049
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5050
|
-
if (n === "rectangle" &&
|
|
5051
|
-
else if (n === "circle" &&
|
|
5052
|
-
else if (n === "square" &&
|
|
5052
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = Te.current;
|
|
5053
|
+
if (n === "rectangle" && E.current) Me(E.current, t);
|
|
5054
|
+
else if (n === "circle" && D.current) Ne(D.current.center, t);
|
|
5055
|
+
else if (n === "square" && O.current) Pe(O.current.center, t);
|
|
5053
5056
|
else if (n === "polygon") {
|
|
5054
|
-
let e =
|
|
5055
|
-
e.length > 0 &&
|
|
5057
|
+
let e = k.current;
|
|
5058
|
+
e.length > 0 && Fe(e, t);
|
|
5056
5059
|
} else if (n === "polyline") {
|
|
5057
|
-
let e =
|
|
5058
|
-
e.length > 0 &&
|
|
5060
|
+
let e = A.current;
|
|
5061
|
+
e.length > 0 && P(e, t);
|
|
5059
5062
|
}
|
|
5060
5063
|
}, r = (t) => {
|
|
5061
5064
|
t.preventDefault();
|
|
5062
|
-
let n =
|
|
5065
|
+
let n = Te.current;
|
|
5063
5066
|
if (n === "polygon") {
|
|
5064
|
-
let t =
|
|
5067
|
+
let t = k.current;
|
|
5065
5068
|
if (t.length >= 3) {
|
|
5066
5069
|
let n = {
|
|
5067
|
-
id:
|
|
5070
|
+
id: M(),
|
|
5068
5071
|
type: "polygon",
|
|
5069
5072
|
coordinates: [...t]
|
|
5070
5073
|
};
|
|
5071
|
-
|
|
5072
|
-
} else
|
|
5074
|
+
N(n), k.current = [], clearAllPreviewSources(e), h(null);
|
|
5075
|
+
} else k.current = [], clearAllPreviewSources(e);
|
|
5073
5076
|
} else if (n === "polyline") {
|
|
5074
|
-
let t =
|
|
5077
|
+
let t = A.current;
|
|
5075
5078
|
if (t.length >= 2) {
|
|
5076
5079
|
let n = {
|
|
5077
|
-
id:
|
|
5080
|
+
id: M(),
|
|
5078
5081
|
type: "polyline",
|
|
5079
5082
|
coordinates: [...t]
|
|
5080
5083
|
};
|
|
5081
|
-
|
|
5082
|
-
} else
|
|
5084
|
+
N(n), A.current = [], clearAllPreviewSources(e), h(null);
|
|
5085
|
+
} else A.current = [], clearAllPreviewSources(e);
|
|
5083
5086
|
}
|
|
5084
5087
|
}, i = (t) => {
|
|
5085
|
-
t.key === "Escape" && (
|
|
5088
|
+
t.key === "Escape" && (E.current = null, D.current = null, O.current = null, k.current = [], A.current = [], clearAllPreviewSources(e), h(null));
|
|
5086
5089
|
}, a = (t) => {
|
|
5087
5090
|
t.preventDefault();
|
|
5088
|
-
let n =
|
|
5091
|
+
let n = Te.current;
|
|
5089
5092
|
if (n === "polygon") {
|
|
5090
|
-
let t =
|
|
5093
|
+
let t = k.current;
|
|
5091
5094
|
if (t.length >= 3) {
|
|
5092
5095
|
let n = {
|
|
5093
|
-
id:
|
|
5096
|
+
id: M(),
|
|
5094
5097
|
type: "polygon",
|
|
5095
5098
|
coordinates: [...t]
|
|
5096
5099
|
};
|
|
5097
|
-
|
|
5100
|
+
N(n), k.current = [], clearAllPreviewSources(e), h(null);
|
|
5098
5101
|
}
|
|
5099
5102
|
} else if (n === "polyline") {
|
|
5100
|
-
let t =
|
|
5103
|
+
let t = A.current;
|
|
5101
5104
|
if (t.length >= 2) {
|
|
5102
5105
|
let n = {
|
|
5103
|
-
id:
|
|
5106
|
+
id: M(),
|
|
5104
5107
|
type: "polyline",
|
|
5105
5108
|
coordinates: [...t]
|
|
5106
5109
|
};
|
|
5107
|
-
|
|
5110
|
+
N(n), A.current = [], clearAllPreviewSources(e), h(null);
|
|
5108
5111
|
}
|
|
5109
5112
|
}
|
|
5110
5113
|
};
|
|
@@ -5114,25 +5117,25 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5114
5117
|
}, [
|
|
5115
5118
|
e,
|
|
5116
5119
|
f,
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
Ae,
|
|
5121
|
-
je,
|
|
5120
|
+
M,
|
|
5121
|
+
N,
|
|
5122
|
+
De,
|
|
5122
5123
|
Me,
|
|
5123
5124
|
Ne,
|
|
5124
|
-
|
|
5125
|
+
Pe,
|
|
5126
|
+
Fe,
|
|
5127
|
+
P
|
|
5125
5128
|
]), useEffect(() => () => {
|
|
5126
|
-
|
|
5129
|
+
S.current.forEach((e) => e.destroy()), S.current.clear();
|
|
5127
5130
|
}, []);
|
|
5128
|
-
let
|
|
5129
|
-
|
|
5131
|
+
let Ie = useCallback((t) => {
|
|
5132
|
+
h((e) => e === t ? null : t), E.current = null, D.current = null, O.current = null, k.current = [], A.current = [], e && clearAllPreviewSources(e);
|
|
5130
5133
|
}, [e]);
|
|
5131
5134
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
5132
5135
|
className: `mapbox-measure-control ${c}`,
|
|
5133
5136
|
style: l,
|
|
5134
5137
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5135
|
-
ref:
|
|
5138
|
+
ref: T,
|
|
5136
5139
|
className: `mapbox-control-btn mapbox-measure-control__btn ${u ? "mapbox-measure-control__btn--active" : ""}`,
|
|
5137
5140
|
onClick: () => d(!u),
|
|
5138
5141
|
title: "测量",
|
|
@@ -5143,14 +5146,14 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5143
5146
|
className: "mapbox-measure-control__btn-icon"
|
|
5144
5147
|
}),
|
|
5145
5148
|
/* @__PURE__ */ jsx("span", { children: "测量" }),
|
|
5146
|
-
|
|
5149
|
+
b.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
5147
5150
|
"(",
|
|
5148
|
-
|
|
5151
|
+
b.length,
|
|
5149
5152
|
")"
|
|
5150
5153
|
] })
|
|
5151
5154
|
]
|
|
5152
5155
|
}), u && /* @__PURE__ */ jsxs("div", {
|
|
5153
|
-
ref:
|
|
5156
|
+
ref: w,
|
|
5154
5157
|
className: "mapbox-measure-control__panel",
|
|
5155
5158
|
children: [
|
|
5156
5159
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -5161,18 +5164,18 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5161
5164
|
className: "mapbox-measure-control__settings",
|
|
5162
5165
|
children: [
|
|
5163
5166
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5164
|
-
checked:
|
|
5165
|
-
onChange: (e) =>
|
|
5167
|
+
checked: y.showArea,
|
|
5168
|
+
onChange: (e) => je("showArea", e),
|
|
5166
5169
|
children: "面积"
|
|
5167
5170
|
}),
|
|
5168
5171
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5169
|
-
checked:
|
|
5170
|
-
onChange: (e) =>
|
|
5172
|
+
checked: y.showLength,
|
|
5173
|
+
onChange: (e) => je("showLength", e),
|
|
5171
5174
|
children: "长度"
|
|
5172
5175
|
}),
|
|
5173
5176
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5174
|
-
checked:
|
|
5175
|
-
onChange: (e) =>
|
|
5177
|
+
checked: y.showRadius,
|
|
5178
|
+
onChange: (e) => je("showRadius", e),
|
|
5176
5179
|
children: "半径"
|
|
5177
5180
|
})
|
|
5178
5181
|
]
|
|
@@ -5185,15 +5188,15 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5185
5188
|
className: "mapbox-measure-control__tools",
|
|
5186
5189
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
5187
5190
|
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5188
|
-
onClick: () =>
|
|
5191
|
+
onClick: () => Ie(e.mode),
|
|
5189
5192
|
title: e.label,
|
|
5190
5193
|
children: /* @__PURE__ */ jsx("img", {
|
|
5191
5194
|
src: e.icon,
|
|
5192
5195
|
alt: e.label
|
|
5193
5196
|
})
|
|
5194
|
-
}, e.mode)),
|
|
5197
|
+
}, e.mode)), b.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
5195
5198
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
5196
|
-
onClick:
|
|
5199
|
+
onClick: ke,
|
|
5197
5200
|
title: "清除全部",
|
|
5198
5201
|
children: /* @__PURE__ */ jsx("img", {
|
|
5199
5202
|
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",
|
|
@@ -5201,7 +5204,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5201
5204
|
})
|
|
5202
5205
|
})]
|
|
5203
5206
|
}),
|
|
5204
|
-
|
|
5207
|
+
b.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
5205
5208
|
className: "mapbox-measure-control__list",
|
|
5206
5209
|
children: /* @__PURE__ */ jsxs("table", {
|
|
5207
5210
|
className: "mapbox-measure-control__table",
|
|
@@ -5211,9 +5214,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5211
5214
|
/* @__PURE__ */ jsx("th", { children: "面积" }),
|
|
5212
5215
|
/* @__PURE__ */ jsx("th", { children: "长度/半径" }),
|
|
5213
5216
|
/* @__PURE__ */ jsx("th", {})
|
|
5214
|
-
] }) }), /* @__PURE__ */ jsx("tbody", { children:
|
|
5217
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: b.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
5215
5218
|
className: "mapbox-measure-control__table-row",
|
|
5216
|
-
onClick: () =>
|
|
5219
|
+
onClick: () => Ae(e.entity.id),
|
|
5217
5220
|
children: [
|
|
5218
5221
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
5219
5222
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -5222,7 +5225,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5222
5225
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
5223
5226
|
className: "mapbox-measure-control__delete-btn",
|
|
5224
5227
|
onClick: (t) => {
|
|
5225
|
-
t.stopPropagation(),
|
|
5228
|
+
t.stopPropagation(), Oe(e.entity.id);
|
|
5226
5229
|
},
|
|
5227
5230
|
title: "删除",
|
|
5228
5231
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -5277,67 +5280,67 @@ var raster_paint_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standal
|
|
|
5277
5280
|
}
|
|
5278
5281
|
];
|
|
5279
5282
|
function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds: c = [], className: l, style: u }) {
|
|
5280
|
-
let [d, f] = useState(!1), [
|
|
5283
|
+
let [d, f] = useState(!1), [m, g] = useState({ ...DEFAULT_CONFIG }), _ = useRef(null), v = useRef(null), y = r !== void 0;
|
|
5281
5284
|
useEffect(() => {
|
|
5282
5285
|
let e = (e) => {
|
|
5283
|
-
|
|
5286
|
+
_.current && !_.current.contains(e.target) && v.current && !v.current.contains(e.target) && f(!1);
|
|
5284
5287
|
};
|
|
5285
5288
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
5286
5289
|
}, []);
|
|
5287
|
-
let
|
|
5290
|
+
let b = useMemo(() => y ? {
|
|
5288
5291
|
brightness: r.brightness ?? DEFAULT_CONFIG.brightness,
|
|
5289
5292
|
saturation: r.saturation ?? DEFAULT_CONFIG.saturation,
|
|
5290
5293
|
contrast: r.contrast ?? DEFAULT_CONFIG.contrast,
|
|
5291
5294
|
hueRotate: r.hueRotate ?? DEFAULT_CONFIG.hueRotate
|
|
5292
|
-
} :
|
|
5293
|
-
|
|
5295
|
+
} : m, [
|
|
5296
|
+
y,
|
|
5294
5297
|
r,
|
|
5295
|
-
|
|
5296
|
-
]),
|
|
5298
|
+
m
|
|
5299
|
+
]), x = useRef(y);
|
|
5297
5300
|
useEffect(() => {
|
|
5298
|
-
|
|
5299
|
-
}, [
|
|
5300
|
-
let
|
|
5301
|
+
y && !x.current && g({ ...b }), x.current = y;
|
|
5302
|
+
}, [y, b]);
|
|
5303
|
+
let S = useCallback((t) => {
|
|
5301
5304
|
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));
|
|
5302
|
-
}, [e, c]),
|
|
5303
|
-
if (
|
|
5304
|
-
...
|
|
5305
|
+
}, [e, c]), ye = useCallback((e, t) => {
|
|
5306
|
+
if (y) s?.({
|
|
5307
|
+
...b,
|
|
5305
5308
|
[e]: t
|
|
5306
5309
|
});
|
|
5307
5310
|
else {
|
|
5308
5311
|
let n = {
|
|
5309
|
-
...
|
|
5312
|
+
...m,
|
|
5310
5313
|
[e]: t
|
|
5311
5314
|
};
|
|
5312
|
-
|
|
5315
|
+
g(n), S(n);
|
|
5313
5316
|
}
|
|
5314
5317
|
}, [
|
|
5315
|
-
|
|
5318
|
+
y,
|
|
5316
5319
|
s,
|
|
5317
|
-
x,
|
|
5318
|
-
h,
|
|
5319
|
-
C
|
|
5320
|
-
]), T = useCallback(() => {
|
|
5321
|
-
b ? s?.({ ...DEFAULT_CONFIG }) : (_({ ...DEFAULT_CONFIG }), C({ ...DEFAULT_CONFIG }));
|
|
5322
|
-
}, [
|
|
5323
5320
|
b,
|
|
5321
|
+
m,
|
|
5322
|
+
S
|
|
5323
|
+
]), C = useCallback(() => {
|
|
5324
|
+
y ? s?.({ ...DEFAULT_CONFIG }) : (g({ ...DEFAULT_CONFIG }), S({ ...DEFAULT_CONFIG }));
|
|
5325
|
+
}, [
|
|
5326
|
+
y,
|
|
5324
5327
|
s,
|
|
5325
|
-
|
|
5328
|
+
S
|
|
5326
5329
|
]);
|
|
5327
5330
|
useEffect(() => {
|
|
5328
|
-
!
|
|
5331
|
+
!y && c.length > 0 && S(m);
|
|
5329
5332
|
}, [
|
|
5330
5333
|
c,
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
+
y,
|
|
5335
|
+
S,
|
|
5336
|
+
m
|
|
5334
5337
|
]);
|
|
5335
|
-
let
|
|
5338
|
+
let w = (e, t) => e === "hueRotate" ? `${Math.round(t)}°` : t.toFixed(2);
|
|
5336
5339
|
return /* @__PURE__ */ jsxs("div", {
|
|
5337
5340
|
className: `mapbox-raster-paint-control${l ? ` ${l}` : ""}`,
|
|
5338
5341
|
style: u,
|
|
5339
5342
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5340
|
-
ref:
|
|
5343
|
+
ref: v,
|
|
5341
5344
|
className: `mapbox-control-btn mapbox-raster-paint-control__btn${d ? " mapbox-raster-paint-control__btn--active" : ""}`,
|
|
5342
5345
|
onClick: () => f(!d),
|
|
5343
5346
|
title: "栅格渲染调节",
|
|
@@ -5347,7 +5350,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5347
5350
|
alt: "raster paint"
|
|
5348
5351
|
}), /* @__PURE__ */ jsx("span", { children: "渲染" })]
|
|
5349
5352
|
}), d && /* @__PURE__ */ jsxs("div", {
|
|
5350
|
-
ref:
|
|
5353
|
+
ref: _,
|
|
5351
5354
|
className: "mapbox-raster-paint-control__panel",
|
|
5352
5355
|
children: [SLIDER_CONFIG.map(({ key: e, label: t, min: n, max: r, step: i }) => /* @__PURE__ */ jsxs("div", {
|
|
5353
5356
|
className: "mapbox-raster-paint-control__slider-row",
|
|
@@ -5361,18 +5364,18 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5361
5364
|
min: n,
|
|
5362
5365
|
max: r,
|
|
5363
5366
|
step: i,
|
|
5364
|
-
value:
|
|
5365
|
-
onChange: (t) =>
|
|
5367
|
+
value: b[e],
|
|
5368
|
+
onChange: (t) => ye(e, t),
|
|
5366
5369
|
tooltipVisible: !1
|
|
5367
5370
|
}),
|
|
5368
5371
|
/* @__PURE__ */ jsx("span", {
|
|
5369
5372
|
className: "mapbox-raster-paint-control__value",
|
|
5370
|
-
children:
|
|
5373
|
+
children: w(e, b[e])
|
|
5371
5374
|
})
|
|
5372
5375
|
]
|
|
5373
5376
|
}, e)), /* @__PURE__ */ jsx("button", {
|
|
5374
5377
|
className: "mapbox-raster-paint-control__reset",
|
|
5375
|
-
onClick:
|
|
5378
|
+
onClick: C,
|
|
5376
5379
|
children: "重置"
|
|
5377
5380
|
})]
|
|
5378
5381
|
})]
|
|
@@ -5380,43 +5383,43 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5380
5383
|
}
|
|
5381
5384
|
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";
|
|
5382
5385
|
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 }) => {
|
|
5383
|
-
let [
|
|
5386
|
+
let [m, h] = useState(!1), g = useRef(null);
|
|
5384
5387
|
useEffect(() => {
|
|
5385
5388
|
let e = (e) => {
|
|
5386
|
-
|
|
5389
|
+
g.current && !g.current.contains(e.target) && h(!1);
|
|
5387
5390
|
};
|
|
5388
|
-
if (
|
|
5389
|
-
}, [
|
|
5390
|
-
let
|
|
5391
|
-
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")),
|
|
5392
|
-
},
|
|
5391
|
+
if (m) return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
5392
|
+
}, [m]);
|
|
5393
|
+
let _ = (e) => {
|
|
5394
|
+
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")), h(!1);
|
|
5395
|
+
}, v = () => {
|
|
5393
5396
|
i === "rectangle" ? s(null) : (r(null), s("rectangle"));
|
|
5394
|
-
},
|
|
5397
|
+
}, y = () => {
|
|
5395
5398
|
i === "circle" ? s(null) : (r(null), s("circle"));
|
|
5396
|
-
},
|
|
5399
|
+
}, b = () => {
|
|
5397
5400
|
i === "polygon" ? s(null) : (r(null), s("polygon"));
|
|
5398
|
-
},
|
|
5401
|
+
}, x = () => {
|
|
5399
5402
|
i === "square" ? s(null) : (r(null), s("square"));
|
|
5400
|
-
},
|
|
5403
|
+
}, S = () => {
|
|
5401
5404
|
i === "polyline" ? s(null) : (r(null), s("polyline"));
|
|
5402
|
-
},
|
|
5403
|
-
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null),
|
|
5404
|
-
},
|
|
5405
|
+
}, ye = () => {
|
|
5406
|
+
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), h(!m);
|
|
5407
|
+
}, C = (e) => e.size ? {
|
|
5405
5408
|
width: e.size,
|
|
5406
5409
|
height: e.size
|
|
5407
5410
|
} : {
|
|
5408
5411
|
width: e.width || 32,
|
|
5409
5412
|
height: e.height || 32
|
|
5410
|
-
},
|
|
5413
|
+
}, w = m || t, T = i === "rectangle", E = i === "circle", be = i === "polygon", xe = i === "square", D = i === "polyline";
|
|
5411
5414
|
return /* @__PURE__ */ jsxs("div", {
|
|
5412
|
-
ref:
|
|
5415
|
+
ref: g,
|
|
5413
5416
|
className: "mapbox-edit-control",
|
|
5414
5417
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
5415
5418
|
className: "mapbox-edit-control__btn-group",
|
|
5416
5419
|
children: [
|
|
5417
5420
|
/* @__PURE__ */ jsxs("button", {
|
|
5418
|
-
className: `mapbox-control-btn ${
|
|
5419
|
-
onClick:
|
|
5421
|
+
className: `mapbox-control-btn ${w ? "mapbox-control-btn--active" : ""}`,
|
|
5422
|
+
onClick: ye,
|
|
5420
5423
|
title: "Marker",
|
|
5421
5424
|
children: [t ? /* @__PURE__ */ jsx("img", {
|
|
5422
5425
|
src: t.icon,
|
|
@@ -5429,8 +5432,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5429
5432
|
}), /* @__PURE__ */ jsx("span", { children: t ? t.name : "Marker" })]
|
|
5430
5433
|
}),
|
|
5431
5434
|
d && /* @__PURE__ */ jsxs("button", {
|
|
5432
|
-
className: `mapbox-control-btn ${
|
|
5433
|
-
onClick:
|
|
5435
|
+
className: `mapbox-control-btn ${xe ? "mapbox-control-btn--active" : ""}`,
|
|
5436
|
+
onClick: x,
|
|
5434
5437
|
title: "绘制正方形",
|
|
5435
5438
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5436
5439
|
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",
|
|
@@ -5439,8 +5442,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5439
5442
|
}), /* @__PURE__ */ jsx("span", { children: "正方形" })]
|
|
5440
5443
|
}),
|
|
5441
5444
|
c && /* @__PURE__ */ jsxs("button", {
|
|
5442
|
-
className: `mapbox-control-btn ${
|
|
5443
|
-
onClick:
|
|
5445
|
+
className: `mapbox-control-btn ${T ? "mapbox-control-btn--active" : ""}`,
|
|
5446
|
+
onClick: v,
|
|
5444
5447
|
title: "绘制矩形",
|
|
5445
5448
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5446
5449
|
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",
|
|
@@ -5449,8 +5452,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5449
5452
|
}), /* @__PURE__ */ jsx("span", { children: "矩形" })]
|
|
5450
5453
|
}),
|
|
5451
5454
|
l && /* @__PURE__ */ jsxs("button", {
|
|
5452
|
-
className: `mapbox-control-btn ${
|
|
5453
|
-
onClick:
|
|
5455
|
+
className: `mapbox-control-btn ${E ? "mapbox-control-btn--active" : ""}`,
|
|
5456
|
+
onClick: y,
|
|
5454
5457
|
title: "绘制圆形",
|
|
5455
5458
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5456
5459
|
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",
|
|
@@ -5459,8 +5462,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5459
5462
|
}), /* @__PURE__ */ jsx("span", { children: "圆形" })]
|
|
5460
5463
|
}),
|
|
5461
5464
|
u && /* @__PURE__ */ jsxs("button", {
|
|
5462
|
-
className: `mapbox-control-btn ${
|
|
5463
|
-
onClick:
|
|
5465
|
+
className: `mapbox-control-btn ${be ? "mapbox-control-btn--active" : ""}`,
|
|
5466
|
+
onClick: b,
|
|
5464
5467
|
title: "绘制多边形",
|
|
5465
5468
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5466
5469
|
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",
|
|
@@ -5469,8 +5472,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5469
5472
|
}), /* @__PURE__ */ jsx("span", { children: "多边形" })]
|
|
5470
5473
|
}),
|
|
5471
5474
|
f && /* @__PURE__ */ jsxs("button", {
|
|
5472
|
-
className: `mapbox-control-btn ${
|
|
5473
|
-
onClick:
|
|
5475
|
+
className: `mapbox-control-btn ${D ? "mapbox-control-btn--active" : ""}`,
|
|
5476
|
+
onClick: S,
|
|
5474
5477
|
title: "绘制折线",
|
|
5475
5478
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5476
5479
|
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",
|
|
@@ -5479,7 +5482,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5479
5482
|
}), /* @__PURE__ */ jsx("span", { children: "折线" })]
|
|
5480
5483
|
})
|
|
5481
5484
|
]
|
|
5482
|
-
}),
|
|
5485
|
+
}), m && /* @__PURE__ */ jsxs("div", {
|
|
5483
5486
|
className: "mapbox-edit-control__panel",
|
|
5484
5487
|
children: [/* @__PURE__ */ jsx("div", {
|
|
5485
5488
|
className: "mapbox-edit-control__panel-header",
|
|
@@ -5487,10 +5490,10 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5487
5490
|
}), /* @__PURE__ */ jsx("div", {
|
|
5488
5491
|
className: "mapbox-edit-control__template-list",
|
|
5489
5492
|
children: e.map((e) => {
|
|
5490
|
-
let n =
|
|
5493
|
+
let n = C(e), r = t?.id === e.id;
|
|
5491
5494
|
return /* @__PURE__ */ jsxs("div", {
|
|
5492
5495
|
className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
|
|
5493
|
-
onClick: () =>
|
|
5496
|
+
onClick: () => _(e),
|
|
5494
5497
|
title: e.name,
|
|
5495
5498
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5496
5499
|
src: e.icon,
|
|
@@ -5559,28 +5562,28 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5559
5562
|
};
|
|
5560
5563
|
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";
|
|
5561
5564
|
const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointCountInput: c = !1, visualType: l = "marker", onSelectFinished: u, showButton: d = !0 }, f) => {
|
|
5562
|
-
let [
|
|
5565
|
+
let [m, h] = useState("idle"), [g, _] = useState(0), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(null), ye = useRef(null), C = useRef([]), w = useRef([]), T = useRef("idle"), E = useRef(null), be = useRef("");
|
|
5563
5566
|
useEffect(() => {
|
|
5564
|
-
|
|
5565
|
-
}, [
|
|
5566
|
-
|
|
5567
|
+
T.current = m;
|
|
5568
|
+
}, [m]), useEffect(() => {
|
|
5569
|
+
y(i);
|
|
5567
5570
|
}, [i]), useEffect(() => {
|
|
5568
|
-
if (!
|
|
5571
|
+
if (!b) return;
|
|
5569
5572
|
let e = (e) => {
|
|
5570
|
-
|
|
5573
|
+
ye.current && !ye.current.contains(e.target) && S.current && !S.current.contains(e.target) && x(!1);
|
|
5571
5574
|
}, t = setTimeout(() => {
|
|
5572
5575
|
document.addEventListener("mousedown", e);
|
|
5573
5576
|
}, 0);
|
|
5574
5577
|
return () => {
|
|
5575
5578
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
5576
5579
|
};
|
|
5577
|
-
}, [
|
|
5578
|
-
let
|
|
5579
|
-
for (let e of
|
|
5580
|
-
|
|
5581
|
-
}, [e]),
|
|
5580
|
+
}, [b]);
|
|
5581
|
+
let xe = useCallback(() => {
|
|
5582
|
+
for (let e of w.current) e.remove();
|
|
5583
|
+
w.current = [], e && (e.getLayer(LINE_LAYER_ID) && e.removeLayer(LINE_LAYER_ID), e.getLayer(POINT_LAYER_ID) && e.removeLayer(POINT_LAYER_ID), e.getSource(SOURCE_ID) && e.removeSource(SOURCE_ID));
|
|
5584
|
+
}, [e]), D = useCallback(() => {
|
|
5582
5585
|
if (!e) return;
|
|
5583
|
-
let t =
|
|
5586
|
+
let t = C.current, n = {
|
|
5584
5587
|
type: "FeatureCollection",
|
|
5585
5588
|
features: [{
|
|
5586
5589
|
type: "Feature",
|
|
@@ -5631,104 +5634,104 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5631
5634
|
"circle-stroke-color": "#fff"
|
|
5632
5635
|
}
|
|
5633
5636
|
}));
|
|
5634
|
-
}, [e]),
|
|
5635
|
-
if (!e || !
|
|
5636
|
-
let { visualType: n } =
|
|
5637
|
+
}, [e]), Se = useCallback((t) => {
|
|
5638
|
+
if (!e || !E.current) return;
|
|
5639
|
+
let { visualType: n } = E.current;
|
|
5637
5640
|
if (n === "marker") {
|
|
5638
5641
|
let n = document.createElement("div");
|
|
5639
|
-
n.className = "route-planning-temp-marker", n.textContent = String(
|
|
5642
|
+
n.className = "route-planning-temp-marker", n.textContent = String(C.current.length);
|
|
5640
5643
|
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5641
|
-
|
|
5642
|
-
} else
|
|
5643
|
-
}, [e,
|
|
5644
|
-
|
|
5645
|
-
}, [
|
|
5646
|
-
let e =
|
|
5644
|
+
w.current.push(r);
|
|
5645
|
+
} else D();
|
|
5646
|
+
}, [e, D]), Ce = useCallback(() => {
|
|
5647
|
+
xe(), C.current = [], E.current = null, _(0), h("idle"), e && (e.getCanvas().style.cursor = be.current);
|
|
5648
|
+
}, [xe, e]), we = useCallback(async () => {
|
|
5649
|
+
let e = E.current, t = [...C.current];
|
|
5647
5650
|
if (!e || t.length < 2) {
|
|
5648
|
-
|
|
5651
|
+
Ce();
|
|
5649
5652
|
return;
|
|
5650
5653
|
}
|
|
5651
|
-
|
|
5654
|
+
h("planning");
|
|
5652
5655
|
try {
|
|
5653
5656
|
await e.onSelectFinished(t);
|
|
5654
5657
|
} catch (e) {
|
|
5655
5658
|
console.error("Route planning onSelectFinished failed:", e);
|
|
5656
5659
|
} finally {
|
|
5657
|
-
|
|
5660
|
+
Ce();
|
|
5658
5661
|
}
|
|
5659
|
-
}, [
|
|
5660
|
-
if (
|
|
5662
|
+
}, [Ce]), O = useCallback((e) => {
|
|
5663
|
+
if (T.current !== "selecting" || !E.current) return;
|
|
5661
5664
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5662
|
-
|
|
5663
|
-
let n =
|
|
5664
|
-
|
|
5665
|
-
}, [
|
|
5666
|
-
|
|
5667
|
-
}, [
|
|
5665
|
+
C.current.push(t);
|
|
5666
|
+
let n = C.current.length;
|
|
5667
|
+
_(n), Se(t), n >= E.current.pointCount && we();
|
|
5668
|
+
}, [Se, we]), k = useCallback((e) => {
|
|
5669
|
+
T.current === "selecting" && (e.preventDefault(), Ce());
|
|
5670
|
+
}, [Ce]);
|
|
5668
5671
|
useEffect(() => {
|
|
5669
|
-
if (e &&
|
|
5670
|
-
e.off("click",
|
|
5672
|
+
if (e && m === "selecting") return e.on("click", O), e.on("contextmenu", k), () => {
|
|
5673
|
+
e.off("click", O), e.off("contextmenu", k);
|
|
5671
5674
|
};
|
|
5672
5675
|
}, [
|
|
5673
5676
|
e,
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
+
m,
|
|
5678
|
+
O,
|
|
5679
|
+
k
|
|
5677
5680
|
]);
|
|
5678
|
-
let
|
|
5681
|
+
let A = useCallback((t) => {
|
|
5679
5682
|
if (!e) return;
|
|
5680
|
-
|
|
5683
|
+
T.current !== "idle" && Ce();
|
|
5681
5684
|
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5682
|
-
|
|
5685
|
+
E.current = {
|
|
5683
5686
|
pointCount: n,
|
|
5684
5687
|
visualType: r,
|
|
5685
5688
|
onSelectFinished: t.onSelectFinished
|
|
5686
|
-
},
|
|
5689
|
+
}, C.current = [], _(0), y(n), x(!1), be.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", h("selecting");
|
|
5687
5690
|
}, [
|
|
5688
5691
|
e,
|
|
5689
5692
|
i,
|
|
5690
5693
|
l,
|
|
5691
|
-
|
|
5694
|
+
Ce
|
|
5692
5695
|
]);
|
|
5693
|
-
useImperativeHandle(f, () => ({ startPlanning:
|
|
5694
|
-
let
|
|
5695
|
-
|
|
5696
|
-
},
|
|
5697
|
-
u &&
|
|
5698
|
-
pointCount: Math.max(2,
|
|
5696
|
+
useImperativeHandle(f, () => ({ startPlanning: A }), [A]);
|
|
5697
|
+
let j = () => {
|
|
5698
|
+
m === "idle" ? x((e) => !e) : m === "selecting" && Ce();
|
|
5699
|
+
}, Te = () => {
|
|
5700
|
+
u && A({
|
|
5701
|
+
pointCount: Math.max(2, v),
|
|
5699
5702
|
visualType: l,
|
|
5700
5703
|
onSelectFinished: u
|
|
5701
5704
|
});
|
|
5702
|
-
},
|
|
5705
|
+
}, M = (e) => {
|
|
5703
5706
|
let t = parseInt(e.target.value, 10);
|
|
5704
|
-
!isNaN(t) && t >= 2 ?
|
|
5705
|
-
},
|
|
5706
|
-
if (
|
|
5707
|
-
if (
|
|
5708
|
-
let e =
|
|
5707
|
+
!isNaN(t) && t >= 2 ? y(t) : e.target.value === "" && y(2);
|
|
5708
|
+
}, Ee = () => {
|
|
5709
|
+
if (m === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5710
|
+
if (m === "selecting") {
|
|
5711
|
+
let e = E.current?.pointCount ?? v;
|
|
5709
5712
|
return /* @__PURE__ */ jsxs("span", { children: [
|
|
5710
|
-
|
|
5713
|
+
g,
|
|
5711
5714
|
"/",
|
|
5712
5715
|
e
|
|
5713
5716
|
] });
|
|
5714
5717
|
}
|
|
5715
5718
|
return "路径规划";
|
|
5716
|
-
},
|
|
5717
|
-
return !d &&
|
|
5719
|
+
}, De = m === "selecting", N = m === "planning";
|
|
5720
|
+
return !d && m === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5718
5721
|
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5719
5722
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5720
|
-
ref:
|
|
5721
|
-
className: `mapbox-control-btn mapbox-route-planning-control__btn${
|
|
5722
|
-
onClick:
|
|
5723
|
-
disabled:
|
|
5724
|
-
title:
|
|
5723
|
+
ref: S,
|
|
5724
|
+
className: `mapbox-control-btn mapbox-route-planning-control__btn${De ? " mapbox-route-planning-control__btn--active" : ""}${N ? " mapbox-route-planning-control__btn--planning" : ""}${b ? " mapbox-route-planning-control__btn--active" : ""}`,
|
|
5725
|
+
onClick: j,
|
|
5726
|
+
disabled: N,
|
|
5727
|
+
title: m === "idle" ? "路径规划" : m === "selecting" ? "取消选点" : "规划中...",
|
|
5725
5728
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5726
5729
|
src: route_planning_default,
|
|
5727
5730
|
alt: "route",
|
|
5728
5731
|
className: "mapbox-route-planning-control__btn-icon"
|
|
5729
|
-
}),
|
|
5730
|
-
}),
|
|
5731
|
-
ref:
|
|
5732
|
+
}), Ee()]
|
|
5733
|
+
}), b && m === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5734
|
+
ref: ye,
|
|
5732
5735
|
className: "mapbox-route-planning-control__panel",
|
|
5733
5736
|
children: [/* @__PURE__ */ jsx("div", {
|
|
5734
5737
|
className: "mapbox-route-planning-control__panel-header",
|
|
@@ -5747,12 +5750,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5747
5750
|
}), c ? /* @__PURE__ */ jsx("input", {
|
|
5748
5751
|
type: "number",
|
|
5749
5752
|
className: "mapbox-route-planning-control__panel-input",
|
|
5750
|
-
value:
|
|
5753
|
+
value: v,
|
|
5751
5754
|
min: 2,
|
|
5752
|
-
onChange:
|
|
5755
|
+
onChange: M
|
|
5753
5756
|
}) : /* @__PURE__ */ jsx("span", {
|
|
5754
5757
|
className: "mapbox-route-planning-control__panel-value",
|
|
5755
|
-
children:
|
|
5758
|
+
children: v
|
|
5756
5759
|
})]
|
|
5757
5760
|
}),
|
|
5758
5761
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -5761,7 +5764,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5761
5764
|
}),
|
|
5762
5765
|
/* @__PURE__ */ jsx("button", {
|
|
5763
5766
|
className: "mapbox-route-planning-control__panel-start",
|
|
5764
|
-
onClick:
|
|
5767
|
+
onClick: Te,
|
|
5765
5768
|
disabled: !u,
|
|
5766
5769
|
children: "开始规划"
|
|
5767
5770
|
})
|
|
@@ -5918,53 +5921,53 @@ function adjustPopupForBounds(e, t) {
|
|
|
5918
5921
|
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;
|
|
5919
5922
|
}
|
|
5920
5923
|
const Mapbox = forwardRef((e, c) => {
|
|
5921
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style:
|
|
5922
|
-
|
|
5923
|
-
let
|
|
5924
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: m = "mapbox://styles/mapbox/dark-v11", maxBounds: h, mode: g = "display", editConfig: _ = {}, pickerConfig: v = {}, onPick: y, interactive: b = {}, layers: x = [], rasterPaint: C, entities: w = [], selectedIds: T = [], entityConfig: E, nameConfig: D, selectNameConfig: O, areaConfig: k, circleConfig: A, lengthConfig: j, showCoordinates: Te = !0, showScale: M = !0, showResetView: Ee = !0, showRoadHighlight: De = !1, showMeasure: Oe = !1, showRasterPaint: Me = !1, showRoutePlanning: Ne, onRasterPaintChange: Pe, popupDefaults: P, renderPopup: Ie, onMapLoad: Le, onEntityClick: Re, onPopupOpen: ze, onPopupClose: Be, className: Ve = "", containerStyle: He } = e, Ue = useRef(null), We = useRef(null), F = useRef(null), I = useRef(/* @__PURE__ */ new Map()), L = useRef(/* @__PURE__ */ new Map()), Ge = useRef(/* @__PURE__ */ new Set()), [R, Ke] = useState(null), qe = useRef(null), Je = useRef(null), Ye = useRef(null), [Xe, Ze] = useState(null), Qe = useRef(null), $e = useRef(null), [z, et] = useState(null), [tt, nt] = useState(g), [rt, it] = useState(null), at = useRef(null), [ot, B] = useState(null), [st, V] = useState(null), [ct, lt] = useState(null), H = useRef(!1), U = useRef(null), ut = useRef(null), W = useRef(null), dt = useRef(null), G = useRef(null), ft = useRef([]), K = useRef(null), pt = useRef(null), q = useRef(null), mt = useRef([]), ht = useRef(null), gt = useRef(!1), [_t, vt] = useState([]), yt = useRef([]);
|
|
5925
|
+
yt.current = _t;
|
|
5926
|
+
let J = useRef(null);
|
|
5924
5927
|
useEffect(() => {
|
|
5925
|
-
|
|
5926
|
-
}, [
|
|
5927
|
-
let
|
|
5928
|
-
let t =
|
|
5928
|
+
nt(g);
|
|
5929
|
+
}, [g]);
|
|
5930
|
+
let bt = useCallback((e) => {
|
|
5931
|
+
let t = I.current.get(e), n = L.current.get(e);
|
|
5929
5932
|
if (t && n) {
|
|
5930
5933
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5931
5934
|
let r = {
|
|
5932
5935
|
...n,
|
|
5933
5936
|
isAnimating: !0
|
|
5934
5937
|
};
|
|
5935
|
-
|
|
5938
|
+
L.current.set(e, r), t.startAnimation();
|
|
5936
5939
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5937
5940
|
let r = {
|
|
5938
5941
|
...n,
|
|
5939
5942
|
isAnimating: !0
|
|
5940
5943
|
};
|
|
5941
|
-
|
|
5944
|
+
L.current.set(e, r), t.startAnimation();
|
|
5942
5945
|
}
|
|
5943
5946
|
}
|
|
5944
|
-
}, []),
|
|
5945
|
-
let t =
|
|
5947
|
+
}, []), xt = useCallback((e) => {
|
|
5948
|
+
let t = I.current.get(e), n = L.current.get(e);
|
|
5946
5949
|
if (t && n) {
|
|
5947
5950
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5948
5951
|
let r = {
|
|
5949
5952
|
...n,
|
|
5950
5953
|
isAnimating: !1
|
|
5951
5954
|
};
|
|
5952
|
-
|
|
5955
|
+
L.current.set(e, r), t.stopAnimation();
|
|
5953
5956
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5954
5957
|
let r = {
|
|
5955
5958
|
...n,
|
|
5956
5959
|
isAnimating: !1
|
|
5957
5960
|
};
|
|
5958
|
-
|
|
5961
|
+
L.current.set(e, r), t.stopAnimation();
|
|
5959
5962
|
}
|
|
5960
5963
|
}
|
|
5961
|
-
}, []),
|
|
5962
|
-
let t =
|
|
5963
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
5964
|
-
}, [
|
|
5964
|
+
}, []), St = useCallback((e) => {
|
|
5965
|
+
let t = L.current.get(e);
|
|
5966
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? xt(e) : bt(e));
|
|
5967
|
+
}, [bt, xt]), Ct = useCallback((e) => {
|
|
5965
5968
|
if (e === void 0) {
|
|
5966
5969
|
let e = !1;
|
|
5967
|
-
for (let [, t] of
|
|
5970
|
+
for (let [, t] of I.current) if (t instanceof UnitRenderer) {
|
|
5968
5971
|
let n = t.getShowTrajectory();
|
|
5969
5972
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
5970
5973
|
e = !0;
|
|
@@ -5972,46 +5975,46 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5972
5975
|
}
|
|
5973
5976
|
}
|
|
5974
5977
|
let t = e ? 0 : "all";
|
|
5975
|
-
for (let [, e] of
|
|
5978
|
+
for (let [, e] of I.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
5976
5979
|
} else {
|
|
5977
5980
|
let t = new Set(e.map(String));
|
|
5978
|
-
for (let [e, n] of
|
|
5981
|
+
for (let [e, n] of I.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
5979
5982
|
}
|
|
5980
|
-
}, []),
|
|
5981
|
-
let r =
|
|
5982
|
-
if (!r?.popup || !
|
|
5983
|
-
let i = r.popup.content ??
|
|
5983
|
+
}, []), wt = useCallback((e, t, n) => {
|
|
5984
|
+
let r = w.find((t) => String(t.id) === String(e));
|
|
5985
|
+
if (!r?.popup || !F.current) return;
|
|
5986
|
+
let i = r.popup.content ?? Ie?.(r);
|
|
5984
5987
|
if (!i) return;
|
|
5985
|
-
let a = mergePopupConfig(r.popup,
|
|
5986
|
-
|
|
5988
|
+
let a = mergePopupConfig(r.popup, P, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, F.current, n);
|
|
5989
|
+
Ke({
|
|
5987
5990
|
entityId: e,
|
|
5988
5991
|
position: o,
|
|
5989
5992
|
config: a,
|
|
5990
5993
|
openedBy: t,
|
|
5991
5994
|
actualPosition: s
|
|
5992
|
-
}),
|
|
5995
|
+
}), ze?.(e);
|
|
5993
5996
|
}, [
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
]),
|
|
5999
|
-
|
|
6000
|
-
}, [
|
|
6001
|
-
|
|
6002
|
-
}, [
|
|
6003
|
-
let r =
|
|
5997
|
+
w,
|
|
5998
|
+
P,
|
|
5999
|
+
Ie,
|
|
6000
|
+
ze
|
|
6001
|
+
]), Tt = useCallback((e) => {
|
|
6002
|
+
R?.entityId === e && (Ke(null), Be?.(e));
|
|
6003
|
+
}, [R, Be]), Et = useCallback(() => {
|
|
6004
|
+
Ke((e) => (e && Be?.(e.entityId), null));
|
|
6005
|
+
}, [Be]), Dt = useCallback((e) => R?.entityId === e, [R]), Ot = useCallback((e, t, n) => {
|
|
6006
|
+
let r = F.current;
|
|
6004
6007
|
r && r.flyTo({
|
|
6005
6008
|
center: e,
|
|
6006
6009
|
zoom: t ?? r.getZoom(),
|
|
6007
6010
|
...n
|
|
6008
6011
|
});
|
|
6009
|
-
}, []),
|
|
6010
|
-
let r =
|
|
6012
|
+
}, []), kt = useCallback((e, t, n) => {
|
|
6013
|
+
let r = F.current;
|
|
6011
6014
|
if (!r || e.length === 0) return;
|
|
6012
6015
|
let i = [];
|
|
6013
6016
|
for (let t of e) {
|
|
6014
|
-
let e =
|
|
6017
|
+
let e = I.current.get(t);
|
|
6015
6018
|
e && i.push(e.getBounds());
|
|
6016
6019
|
}
|
|
6017
6020
|
if (i.length === 0) return;
|
|
@@ -6033,19 +6036,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6033
6036
|
pitch: n?.pitch ?? r.getPitch()
|
|
6034
6037
|
};
|
|
6035
6038
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
6036
|
-
}, []),
|
|
6037
|
-
let t =
|
|
6039
|
+
}, []), At = useCallback((e) => {
|
|
6040
|
+
let t = F.current;
|
|
6038
6041
|
if (!t || !t.getContainer()) return;
|
|
6039
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } =
|
|
6042
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = v;
|
|
6040
6043
|
if (!n) {
|
|
6041
|
-
|
|
6044
|
+
at.current &&= (at.current.remove(), null);
|
|
6042
6045
|
return;
|
|
6043
6046
|
}
|
|
6044
|
-
if (
|
|
6045
|
-
|
|
6046
|
-
let t =
|
|
6047
|
+
if (at.current) {
|
|
6048
|
+
at.current.setLngLat(e);
|
|
6049
|
+
let t = at.current.getElement(), n = t.querySelector(".marker-label");
|
|
6047
6050
|
if (i) {
|
|
6048
|
-
let e = resolveNameConfig(a,
|
|
6051
|
+
let e = resolveNameConfig(a, D);
|
|
6049
6052
|
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`;
|
|
6050
6053
|
else {
|
|
6051
6054
|
let n = document.createElement("div");
|
|
@@ -6057,41 +6060,41 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6057
6060
|
n.className = "mapbox-picker-marker";
|
|
6058
6061
|
let o = document.createElement("div");
|
|
6059
6062
|
if (o.className = "marker-inner", o.style.background = r, n.appendChild(o), i) {
|
|
6060
|
-
let e = resolveNameConfig(a,
|
|
6063
|
+
let e = resolveNameConfig(a, D), t = document.createElement("div");
|
|
6061
6064
|
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);
|
|
6062
6065
|
}
|
|
6063
|
-
|
|
6066
|
+
at.current = new mapboxgl.Marker({
|
|
6064
6067
|
element: n,
|
|
6065
6068
|
anchor: "bottom"
|
|
6066
6069
|
}).setLngLat(e).addTo(t);
|
|
6067
6070
|
}
|
|
6068
|
-
}, [
|
|
6069
|
-
|
|
6070
|
-
}, []),
|
|
6071
|
-
let t =
|
|
6072
|
-
if (
|
|
6071
|
+
}, [v, D]), jt = useCallback(() => {
|
|
6072
|
+
at.current &&= (at.current.remove(), null);
|
|
6073
|
+
}, []), Mt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Nt = useCallback((e) => {
|
|
6074
|
+
let t = F.current;
|
|
6075
|
+
if (Ue.current) if (ht.current &&= (ht.current.remove(), null), e && t) {
|
|
6073
6076
|
t.getCanvas().style.cursor = "none";
|
|
6074
6077
|
let n = document.createElement("div");
|
|
6075
6078
|
n.className = "mapbox-custom-cursor";
|
|
6076
6079
|
let r = e.size || e.width || 32;
|
|
6077
6080
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
6078
6081
|
let i = document.createElement("img");
|
|
6079
|
-
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n),
|
|
6082
|
+
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n), ht.current = n;
|
|
6080
6083
|
let a = (e) => {
|
|
6081
|
-
|
|
6084
|
+
ht.current && (ht.current.style.left = `${e.clientX}px`, ht.current.style.top = `${e.clientY}px`);
|
|
6082
6085
|
};
|
|
6083
6086
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
6084
6087
|
document.removeEventListener("mousemove", a);
|
|
6085
6088
|
};
|
|
6086
6089
|
} else t && (t.getCanvas().style.cursor = "");
|
|
6087
|
-
}, []),
|
|
6088
|
-
if (
|
|
6089
|
-
let e =
|
|
6090
|
-
e && e(),
|
|
6090
|
+
}, []), Y = useCallback(() => {
|
|
6091
|
+
if (ht.current) {
|
|
6092
|
+
let e = ht.current._cleanup;
|
|
6093
|
+
e && e(), ht.current.remove(), ht.current = null;
|
|
6091
6094
|
}
|
|
6092
|
-
let e =
|
|
6095
|
+
let e = F.current;
|
|
6093
6096
|
e && (e.getCanvas().style.cursor = "");
|
|
6094
|
-
}, []),
|
|
6097
|
+
}, []), Pt = useCallback((e, t, n) => {
|
|
6095
6098
|
if (!e.getSource(t)) {
|
|
6096
6099
|
if (!e.getStyle().glyphs) {
|
|
6097
6100
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -6127,8 +6130,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6127
6130
|
}
|
|
6128
6131
|
});
|
|
6129
6132
|
}
|
|
6130
|
-
}, []),
|
|
6131
|
-
let e =
|
|
6133
|
+
}, []), Ft = useCallback(() => {
|
|
6134
|
+
let e = F.current;
|
|
6132
6135
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6133
6136
|
type: "geojson",
|
|
6134
6137
|
data: {
|
|
@@ -6152,9 +6155,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6152
6155
|
"line-width": 2,
|
|
6153
6156
|
"line-dasharray": [4, 4]
|
|
6154
6157
|
}
|
|
6155
|
-
}),
|
|
6156
|
-
}, [
|
|
6157
|
-
let n =
|
|
6158
|
+
}), Pt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6159
|
+
}, [Pt]), It = useCallback((e, t) => {
|
|
6160
|
+
let n = F.current;
|
|
6158
6161
|
if (!n) return;
|
|
6159
6162
|
let r = n.getSource("rect-preview-source");
|
|
6160
6163
|
if (!r) return;
|
|
@@ -6173,11 +6176,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6173
6176
|
},
|
|
6174
6177
|
properties: {}
|
|
6175
6178
|
});
|
|
6176
|
-
let l =
|
|
6179
|
+
let l = U.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6177
6180
|
n.getLayer("rect-preview-line") && (n.setPaintProperty("rect-preview-line", "line-color", u), n.setPaintProperty("rect-preview-line", "line-width", d)), n.getLayer("rect-preview-fill") && (n.setPaintProperty("rect-preview-fill", "fill-color", f), n.setPaintProperty("rect-preview-fill", "fill-opacity", p));
|
|
6178
|
-
let
|
|
6179
|
-
if (
|
|
6180
|
-
let e =
|
|
6181
|
+
let ve = n.getSource("rect-preview-measure-source");
|
|
6182
|
+
if (ve) {
|
|
6183
|
+
let e = Pn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6181
6184
|
if (e?.showArea) {
|
|
6182
6185
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6183
6186
|
t.push({
|
|
@@ -6209,13 +6212,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6209
6212
|
properties: { label: formatLength(distance(r, i)) }
|
|
6210
6213
|
});
|
|
6211
6214
|
}
|
|
6212
|
-
|
|
6215
|
+
ve.setData({
|
|
6213
6216
|
type: "FeatureCollection",
|
|
6214
6217
|
features: t
|
|
6215
6218
|
});
|
|
6216
6219
|
}
|
|
6217
|
-
}, []),
|
|
6218
|
-
let e =
|
|
6220
|
+
}, []), Lt = useCallback(() => {
|
|
6221
|
+
let e = F.current;
|
|
6219
6222
|
if (!e) return;
|
|
6220
6223
|
let t = e.getSource("rect-preview-source");
|
|
6221
6224
|
t && t.setData({
|
|
@@ -6227,10 +6230,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6227
6230
|
type: "FeatureCollection",
|
|
6228
6231
|
features: []
|
|
6229
6232
|
});
|
|
6230
|
-
}, []),
|
|
6231
|
-
|
|
6232
|
-
}, [
|
|
6233
|
-
let e =
|
|
6233
|
+
}, []), X = useCallback(() => {
|
|
6234
|
+
lt(null), Lt();
|
|
6235
|
+
}, [Lt]), Rt = useCallback(() => {
|
|
6236
|
+
let e = F.current;
|
|
6234
6237
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6235
6238
|
type: "geojson",
|
|
6236
6239
|
data: {
|
|
@@ -6254,7 +6257,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6254
6257
|
"line-width": 2,
|
|
6255
6258
|
"line-dasharray": [4, 4]
|
|
6256
6259
|
}
|
|
6257
|
-
}),
|
|
6260
|
+
}), Pt(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
6258
6261
|
type: "geojson",
|
|
6259
6262
|
data: {
|
|
6260
6263
|
type: "FeatureCollection",
|
|
@@ -6271,22 +6274,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6271
6274
|
"line-dasharray": [4, 4]
|
|
6272
6275
|
}
|
|
6273
6276
|
}))));
|
|
6274
|
-
}, [
|
|
6277
|
+
}, [Pt]), zt = useCallback((e, t, n = 64) => {
|
|
6275
6278
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
6276
6279
|
for (let e = 0; e <= n; e++) {
|
|
6277
6280
|
let t = e / n * 2 * Math.PI, c = o * Math.cos(t), l = o * Math.sin(t) / Math.cos(s), u = i + c * 180 / Math.PI, d = r + l * 180 / Math.PI;
|
|
6278
6281
|
a.push([d, u]);
|
|
6279
6282
|
}
|
|
6280
6283
|
return a;
|
|
6281
|
-
}, []),
|
|
6284
|
+
}, []), Bt = useCallback((e, t) => {
|
|
6282
6285
|
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);
|
|
6283
6286
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6284
|
-
}, []),
|
|
6285
|
-
let n =
|
|
6287
|
+
}, []), Vt = useCallback((e, t) => {
|
|
6288
|
+
let n = F.current;
|
|
6286
6289
|
if (!n) return;
|
|
6287
6290
|
let r = n.getSource("circle-preview-source");
|
|
6288
6291
|
if (!r) return;
|
|
6289
|
-
let i =
|
|
6292
|
+
let i = Bt(e, t), a = zt(e, i);
|
|
6290
6293
|
r.setData({
|
|
6291
6294
|
type: "Feature",
|
|
6292
6295
|
geometry: {
|
|
@@ -6295,9 +6298,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6295
6298
|
},
|
|
6296
6299
|
properties: {}
|
|
6297
6300
|
});
|
|
6298
|
-
let o =
|
|
6301
|
+
let o = W.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6299
6302
|
n.getLayer("circle-preview-line") && (n.setPaintProperty("circle-preview-line", "line-color", s), n.setPaintProperty("circle-preview-line", "line-width", c)), n.getLayer("circle-preview-fill") && (n.setPaintProperty("circle-preview-fill", "fill-color", l), n.setPaintProperty("circle-preview-fill", "fill-opacity", u));
|
|
6300
|
-
let d =
|
|
6303
|
+
let d = Pn.current, f = [], p = [];
|
|
6301
6304
|
if (d?.showArea) {
|
|
6302
6305
|
let t = Math.PI * i * i;
|
|
6303
6306
|
f.push({
|
|
@@ -6310,7 +6313,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6310
6313
|
});
|
|
6311
6314
|
}
|
|
6312
6315
|
if (d?.showRadius) {
|
|
6313
|
-
let t =
|
|
6316
|
+
let t = W.current?.radiusAngle ?? 90, n = destinationPoint(e, i, t), r = [(e[0] + n[0]) / 2, (e[1] + n[1]) / 2];
|
|
6314
6317
|
p.push({
|
|
6315
6318
|
type: "Feature",
|
|
6316
6319
|
geometry: {
|
|
@@ -6327,18 +6330,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6327
6330
|
properties: { label: formatLength(i) }
|
|
6328
6331
|
});
|
|
6329
6332
|
}
|
|
6330
|
-
let
|
|
6331
|
-
|
|
6333
|
+
let ve = n.getSource("circle-preview-measure-source");
|
|
6334
|
+
ve && ve.setData({
|
|
6332
6335
|
type: "FeatureCollection",
|
|
6333
6336
|
features: f
|
|
6334
6337
|
});
|
|
6335
|
-
let
|
|
6336
|
-
|
|
6338
|
+
let m = n.getSource("circle-preview-radius-source");
|
|
6339
|
+
m && m.setData({
|
|
6337
6340
|
type: "FeatureCollection",
|
|
6338
6341
|
features: p
|
|
6339
6342
|
});
|
|
6340
|
-
}, [
|
|
6341
|
-
let e =
|
|
6343
|
+
}, [Bt, zt]), Ht = useCallback(() => {
|
|
6344
|
+
let e = F.current;
|
|
6342
6345
|
if (!e) return;
|
|
6343
6346
|
let t = e.getSource("circle-preview-source");
|
|
6344
6347
|
t && t.setData({
|
|
@@ -6355,10 +6358,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6355
6358
|
type: "FeatureCollection",
|
|
6356
6359
|
features: []
|
|
6357
6360
|
});
|
|
6358
|
-
}, []),
|
|
6359
|
-
|
|
6360
|
-
}, [
|
|
6361
|
-
let e =
|
|
6361
|
+
}, []), Ut = useCallback(() => {
|
|
6362
|
+
dt.current = null, Ht();
|
|
6363
|
+
}, [Ht]), Wt = useCallback(() => {
|
|
6364
|
+
let e = F.current;
|
|
6362
6365
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6363
6366
|
type: "geojson",
|
|
6364
6367
|
data: {
|
|
@@ -6398,9 +6401,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6398
6401
|
"circle-stroke-color": "#ffffff",
|
|
6399
6402
|
"circle-stroke-width": 2
|
|
6400
6403
|
}
|
|
6401
|
-
}),
|
|
6402
|
-
}, [
|
|
6403
|
-
let n =
|
|
6404
|
+
}), Pt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6405
|
+
}, [Pt]), Gt = useCallback((e, t) => {
|
|
6406
|
+
let n = F.current;
|
|
6404
6407
|
if (!n) return;
|
|
6405
6408
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
6406
6409
|
if (!r || !i) return;
|
|
@@ -6437,11 +6440,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6437
6440
|
properties: {}
|
|
6438
6441
|
}))
|
|
6439
6442
|
});
|
|
6440
|
-
let o =
|
|
6443
|
+
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6441
6444
|
n.getLayer("polygon-preview-line") && (n.setPaintProperty("polygon-preview-line", "line-color", s), n.setPaintProperty("polygon-preview-line", "line-width", c)), n.getLayer("polygon-preview-fill") && (n.setPaintProperty("polygon-preview-fill", "fill-color", l), n.setPaintProperty("polygon-preview-fill", "fill-opacity", u)), n.getLayer("polygon-vertices") && n.setPaintProperty("polygon-vertices", "circle-color", s);
|
|
6442
6445
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6443
6446
|
if (d) {
|
|
6444
|
-
let e =
|
|
6447
|
+
let e = Pn.current, t = [];
|
|
6445
6448
|
if (e?.showArea && a.length >= 3) {
|
|
6446
6449
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6447
6450
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6483,8 +6486,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6483
6486
|
features: t
|
|
6484
6487
|
});
|
|
6485
6488
|
}
|
|
6486
|
-
}, []),
|
|
6487
|
-
let e =
|
|
6489
|
+
}, []), Kt = useCallback(() => {
|
|
6490
|
+
let e = F.current;
|
|
6488
6491
|
if (!e) return;
|
|
6489
6492
|
let t = e.getSource("polygon-preview-source");
|
|
6490
6493
|
t && t.setData({
|
|
@@ -6501,10 +6504,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6501
6504
|
type: "FeatureCollection",
|
|
6502
6505
|
features: []
|
|
6503
6506
|
});
|
|
6504
|
-
}, []),
|
|
6505
|
-
|
|
6506
|
-
}, [
|
|
6507
|
-
let e =
|
|
6507
|
+
}, []), qt = useCallback(() => {
|
|
6508
|
+
ft.current = [], Kt();
|
|
6509
|
+
}, [Kt]), Jt = useCallback(() => {
|
|
6510
|
+
let e = F.current;
|
|
6508
6511
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6509
6512
|
type: "geojson",
|
|
6510
6513
|
data: {
|
|
@@ -6528,8 +6531,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6528
6531
|
"line-width": 2,
|
|
6529
6532
|
"line-dasharray": [4, 4]
|
|
6530
6533
|
}
|
|
6531
|
-
}),
|
|
6532
|
-
}, [
|
|
6534
|
+
}), Pt(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6535
|
+
}, [Pt]), Yt = useCallback((e, t) => {
|
|
6533
6536
|
let [n, r] = e, i = t / 2 / 6371e3, a = r * Math.PI / 180, o = i * 180 / Math.PI, s = i * 180 / Math.PI / Math.cos(a);
|
|
6534
6537
|
return [
|
|
6535
6538
|
[n - s, r + o],
|
|
@@ -6538,12 +6541,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6538
6541
|
[n - s, r - o],
|
|
6539
6542
|
[n - s, r + o]
|
|
6540
6543
|
];
|
|
6541
|
-
}, []),
|
|
6542
|
-
let n =
|
|
6544
|
+
}, []), Xt = useCallback((e, t) => {
|
|
6545
|
+
let n = F.current;
|
|
6543
6546
|
if (!n) return;
|
|
6544
6547
|
let r = n.getSource("square-preview-source");
|
|
6545
6548
|
if (!r) return;
|
|
6546
|
-
let i =
|
|
6549
|
+
let i = Bt(e, t) * 2, a = Yt(e, i);
|
|
6547
6550
|
r.setData({
|
|
6548
6551
|
type: "Feature",
|
|
6549
6552
|
geometry: {
|
|
@@ -6552,11 +6555,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6552
6555
|
},
|
|
6553
6556
|
properties: {}
|
|
6554
6557
|
});
|
|
6555
|
-
let o =
|
|
6558
|
+
let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6556
6559
|
n.getLayer("square-preview-line") && (n.setPaintProperty("square-preview-line", "line-color", s), n.setPaintProperty("square-preview-line", "line-width", c)), n.getLayer("square-preview-fill") && (n.setPaintProperty("square-preview-fill", "fill-color", l), n.setPaintProperty("square-preview-fill", "fill-opacity", u));
|
|
6557
6560
|
let d = n.getSource("square-preview-measure-source");
|
|
6558
6561
|
if (d) {
|
|
6559
|
-
let t =
|
|
6562
|
+
let t = Pn.current, n = [];
|
|
6560
6563
|
if (t?.showArea && n.push({
|
|
6561
6564
|
type: "Feature",
|
|
6562
6565
|
geometry: {
|
|
@@ -6580,8 +6583,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6580
6583
|
features: n
|
|
6581
6584
|
});
|
|
6582
6585
|
}
|
|
6583
|
-
}, [
|
|
6584
|
-
let e =
|
|
6586
|
+
}, [Bt, Yt]), Zt = useCallback(() => {
|
|
6587
|
+
let e = F.current;
|
|
6585
6588
|
if (!e) return;
|
|
6586
6589
|
let t = e.getSource("square-preview-source");
|
|
6587
6590
|
t && t.setData({
|
|
@@ -6593,10 +6596,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6593
6596
|
type: "FeatureCollection",
|
|
6594
6597
|
features: []
|
|
6595
6598
|
});
|
|
6596
|
-
}, []),
|
|
6597
|
-
|
|
6598
|
-
}, [
|
|
6599
|
-
let e =
|
|
6599
|
+
}, []), Qt = useCallback(() => {
|
|
6600
|
+
pt.current = null, Zt();
|
|
6601
|
+
}, [Zt]), $t = useCallback(() => {
|
|
6602
|
+
let e = F.current;
|
|
6600
6603
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6601
6604
|
type: "geojson",
|
|
6602
6605
|
data: {
|
|
@@ -6628,9 +6631,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6628
6631
|
"circle-stroke-color": "#ffffff",
|
|
6629
6632
|
"circle-stroke-width": 2
|
|
6630
6633
|
}
|
|
6631
|
-
}),
|
|
6632
|
-
}, [
|
|
6633
|
-
let n =
|
|
6634
|
+
}), Pt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
6635
|
+
}, [Pt]), en = useCallback((e, t) => {
|
|
6636
|
+
let n = F.current;
|
|
6634
6637
|
if (!n) return;
|
|
6635
6638
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
6636
6639
|
if (!r || !i) return;
|
|
@@ -6656,11 +6659,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6656
6659
|
properties: {}
|
|
6657
6660
|
}))
|
|
6658
6661
|
});
|
|
6659
|
-
let o =
|
|
6662
|
+
let o = q.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
6660
6663
|
n.getLayer("polyline-preview-line") && (n.setPaintProperty("polyline-preview-line", "line-color", s), n.setPaintProperty("polyline-preview-line", "line-width", c)), n.getLayer("polyline-vertices") && n.setPaintProperty("polyline-vertices", "circle-color", s);
|
|
6661
6664
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6662
6665
|
if (l) {
|
|
6663
|
-
let e =
|
|
6666
|
+
let e = Pn.current, t = [];
|
|
6664
6667
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6665
6668
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6666
6669
|
t.push({
|
|
@@ -6677,8 +6680,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6677
6680
|
features: t
|
|
6678
6681
|
});
|
|
6679
6682
|
}
|
|
6680
|
-
}, []),
|
|
6681
|
-
let e =
|
|
6683
|
+
}, []), tn = useCallback(() => {
|
|
6684
|
+
let e = F.current;
|
|
6682
6685
|
if (!e) return;
|
|
6683
6686
|
let t = e.getSource("polyline-preview-source");
|
|
6684
6687
|
t && t.setData({
|
|
@@ -6695,159 +6698,159 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6695
6698
|
type: "FeatureCollection",
|
|
6696
6699
|
features: []
|
|
6697
6700
|
});
|
|
6698
|
-
}, []),
|
|
6699
|
-
|
|
6700
|
-
}, [
|
|
6701
|
-
|
|
6701
|
+
}, []), Z = useCallback(() => {
|
|
6702
|
+
mt.current = [], tn();
|
|
6703
|
+
}, [tn]), nn = useCallback((e) => {
|
|
6704
|
+
B(e), Nt(e), e ? (V("marker"), X(), Ut(), qt(), Qt(), Z()) : V(null);
|
|
6702
6705
|
}, [
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
]),
|
|
6710
|
-
if (
|
|
6711
|
-
|
|
6712
|
-
let e =
|
|
6706
|
+
Nt,
|
|
6707
|
+
X,
|
|
6708
|
+
Ut,
|
|
6709
|
+
qt,
|
|
6710
|
+
Qt,
|
|
6711
|
+
Z
|
|
6712
|
+
]), rn = useCallback((e) => {
|
|
6713
|
+
if (V(e), e === "rectangle") {
|
|
6714
|
+
B(null), Y(), Ut(), qt(), Qt(), Z();
|
|
6715
|
+
let e = F.current;
|
|
6713
6716
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6714
6717
|
} else if (e === "circle") {
|
|
6715
|
-
|
|
6716
|
-
let e =
|
|
6718
|
+
B(null), Y(), X(), qt(), Qt(), Z();
|
|
6719
|
+
let e = F.current;
|
|
6717
6720
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6718
6721
|
} else if (e === "polygon") {
|
|
6719
|
-
|
|
6720
|
-
let e =
|
|
6722
|
+
B(null), Y(), X(), Ut(), Qt(), Z();
|
|
6723
|
+
let e = F.current;
|
|
6721
6724
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6722
6725
|
} else if (e === "square") {
|
|
6723
|
-
|
|
6724
|
-
let e =
|
|
6726
|
+
B(null), Y(), X(), Ut(), qt(), Z();
|
|
6727
|
+
let e = F.current;
|
|
6725
6728
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6726
6729
|
} else if (e === "polyline") {
|
|
6727
|
-
|
|
6728
|
-
let e =
|
|
6730
|
+
B(null), Y(), X(), Ut(), qt(), Qt();
|
|
6731
|
+
let e = F.current;
|
|
6729
6732
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6730
|
-
} else e === "marker" ? (
|
|
6733
|
+
} else e === "marker" ? (X(), Ut(), qt(), Qt(), Z()) : (B(null), Y(), X(), Ut(), qt(), Qt(), Z());
|
|
6731
6734
|
}, [
|
|
6735
|
+
Y,
|
|
6732
6736
|
X,
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
]), rn = useCallback((e) => {
|
|
6737
|
+
Ut,
|
|
6738
|
+
qt,
|
|
6739
|
+
Qt,
|
|
6740
|
+
Z
|
|
6741
|
+
]), an = useCallback((e) => {
|
|
6739
6742
|
if (e !== "picker") {
|
|
6740
|
-
let e =
|
|
6741
|
-
(!e || !t) &&
|
|
6743
|
+
let e = v.value && isFinite(v.value.lng) && isFinite(v.value.lat), t = v.showMarker !== !1;
|
|
6744
|
+
(!e || !t) && jt(), it(null);
|
|
6742
6745
|
}
|
|
6743
|
-
e !== "edit" && (
|
|
6746
|
+
e !== "edit" && (B(null), V(null), X(), Z(), Y()), nt(e);
|
|
6744
6747
|
}, [
|
|
6745
|
-
|
|
6748
|
+
jt,
|
|
6749
|
+
Y,
|
|
6746
6750
|
X,
|
|
6747
|
-
Z
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
}, [At]);
|
|
6751
|
+
Z
|
|
6752
|
+
]), on = useCallback(() => tt, [tt]), sn = useCallback(() => rt, [rt]), cn = useCallback(() => {
|
|
6753
|
+
jt(), it(null);
|
|
6754
|
+
}, [jt]);
|
|
6752
6755
|
useEffect(() => {
|
|
6753
|
-
if (!
|
|
6754
|
-
let e =
|
|
6756
|
+
if (!z) return;
|
|
6757
|
+
let e = v.value;
|
|
6755
6758
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6756
6759
|
let t = [e.lng, e.lat];
|
|
6757
|
-
|
|
6760
|
+
it(e), At(t);
|
|
6758
6761
|
}
|
|
6759
6762
|
}, [
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
+
v.value,
|
|
6764
|
+
At,
|
|
6765
|
+
z
|
|
6763
6766
|
]);
|
|
6764
|
-
let
|
|
6765
|
-
if (
|
|
6766
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
6767
|
+
let ln = (e) => "mode" in e, un = useCallback((e) => {
|
|
6768
|
+
if (nt("edit"), jt(), it(null), H.current = !0, ln(e)) {
|
|
6769
|
+
if (e.mode === "marker") e.markerStyle ? (ut.current = e.markerStyle, U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, B(null), V("marker"), e.markerStyle.src && e.markerStyle.width ? Nt({
|
|
6767
6770
|
id: "custom",
|
|
6768
6771
|
name: e.markerStyle.name || "Marker",
|
|
6769
6772
|
icon: e.markerStyle.src,
|
|
6770
6773
|
width: e.markerStyle.width
|
|
6771
|
-
}) :
|
|
6774
|
+
}) : 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));
|
|
6772
6775
|
else if (e.mode === "rectangle") {
|
|
6773
|
-
|
|
6774
|
-
let t =
|
|
6776
|
+
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 = F.current;
|
|
6775
6778
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6776
6779
|
} else if (e.mode === "circle") {
|
|
6777
|
-
|
|
6778
|
-
let t =
|
|
6780
|
+
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 = F.current;
|
|
6779
6782
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6780
6783
|
} else if (e.mode === "polygon") {
|
|
6781
|
-
|
|
6782
|
-
let t =
|
|
6784
|
+
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 = F.current;
|
|
6783
6786
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6784
6787
|
} else if (e.mode === "square") {
|
|
6785
|
-
|
|
6786
|
-
let t =
|
|
6788
|
+
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 = F.current;
|
|
6787
6790
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6788
6791
|
} else if (e.mode === "polyline") {
|
|
6789
|
-
|
|
6790
|
-
let t =
|
|
6792
|
+
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 = F.current;
|
|
6791
6794
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6792
6795
|
}
|
|
6793
|
-
} else
|
|
6796
|
+
} 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;
|
|
6794
6797
|
}, [
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
+
jt,
|
|
6799
|
+
Nt,
|
|
6800
|
+
Y
|
|
6798
6801
|
]);
|
|
6799
6802
|
useImperativeHandle(c, () => ({
|
|
6800
|
-
startAnimation:
|
|
6801
|
-
stopAnimation:
|
|
6802
|
-
toggleAnimation:
|
|
6803
|
-
getMap: () =>
|
|
6804
|
-
openPopup: (e) =>
|
|
6805
|
-
closePopup:
|
|
6806
|
-
closeAllPopups:
|
|
6807
|
-
isPopupOpen:
|
|
6808
|
-
toggleUnitTrajectory:
|
|
6809
|
-
flyTo:
|
|
6810
|
-
flyToEntities:
|
|
6811
|
-
getMode:
|
|
6812
|
-
setMode:
|
|
6813
|
-
getPickedLocation:
|
|
6814
|
-
clearPickedLocation:
|
|
6815
|
-
startDrawing:
|
|
6816
|
-
getRenderer: (e) =>
|
|
6803
|
+
startAnimation: bt,
|
|
6804
|
+
stopAnimation: xt,
|
|
6805
|
+
toggleAnimation: St,
|
|
6806
|
+
getMap: () => F.current,
|
|
6807
|
+
openPopup: (e) => wt(e, "programmatic"),
|
|
6808
|
+
closePopup: Tt,
|
|
6809
|
+
closeAllPopups: Et,
|
|
6810
|
+
isPopupOpen: Dt,
|
|
6811
|
+
toggleUnitTrajectory: Ct,
|
|
6812
|
+
flyTo: Ot,
|
|
6813
|
+
flyToEntities: kt,
|
|
6814
|
+
getMode: on,
|
|
6815
|
+
setMode: an,
|
|
6816
|
+
getPickedLocation: sn,
|
|
6817
|
+
clearPickedLocation: cn,
|
|
6818
|
+
startDrawing: un,
|
|
6819
|
+
getRenderer: (e) => I.current.get(e),
|
|
6817
6820
|
setEditingEntities: (e) => {
|
|
6818
|
-
for (let t of
|
|
6819
|
-
for (let t of e)
|
|
6820
|
-
|
|
6821
|
+
for (let t of yt.current) e.map(String).includes(String(t)) || I.current.get(t)?.setEditing?.(!1);
|
|
6822
|
+
for (let t of e) I.current.get(t)?.setEditing?.(!0);
|
|
6823
|
+
J.current &&= (I.current.get(J.current.entityId)?.cancelEditPreview?.(), null), vt(e);
|
|
6821
6824
|
},
|
|
6822
|
-
getEditingEntities: () =>
|
|
6825
|
+
getEditingEntities: () => yt.current,
|
|
6823
6826
|
startRoutePlanning: (e) => {
|
|
6824
|
-
|
|
6827
|
+
We.current?.startPlanning(e);
|
|
6825
6828
|
}
|
|
6826
6829
|
}), [
|
|
6827
|
-
yt,
|
|
6828
6830
|
bt,
|
|
6829
6831
|
xt,
|
|
6830
|
-
|
|
6832
|
+
St,
|
|
6831
6833
|
wt,
|
|
6832
6834
|
Tt,
|
|
6833
6835
|
Et,
|
|
6834
|
-
St,
|
|
6835
6836
|
Dt,
|
|
6837
|
+
Ct,
|
|
6836
6838
|
Ot,
|
|
6837
|
-
|
|
6838
|
-
rn,
|
|
6839
|
+
kt,
|
|
6839
6840
|
on,
|
|
6841
|
+
an,
|
|
6840
6842
|
sn,
|
|
6841
|
-
|
|
6843
|
+
cn,
|
|
6844
|
+
un
|
|
6842
6845
|
]);
|
|
6843
|
-
let
|
|
6844
|
-
let e =
|
|
6846
|
+
let dn = useCallback(() => {
|
|
6847
|
+
let e = F.current;
|
|
6845
6848
|
if (!e) return;
|
|
6846
|
-
let t = new Set(
|
|
6847
|
-
for (let e of n) t.has(e) || (
|
|
6848
|
-
let r = new Set(
|
|
6849
|
-
for (let t of
|
|
6850
|
-
let n = applyEntityConfig(t,
|
|
6849
|
+
let t = new Set(w.map((e) => e.id)), n = new Set(I.current.keys());
|
|
6850
|
+
for (let e of n) t.has(e) || (I.current.get(e)?.destroy(), I.current.delete(e));
|
|
6851
|
+
let r = new Set(T.map(String));
|
|
6852
|
+
for (let t of w) {
|
|
6853
|
+
let n = applyEntityConfig(t, E), i = I.current.get(n.id);
|
|
6851
6854
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
6852
6855
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
6853
6856
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -6856,38 +6859,38 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6856
6859
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
6857
6860
|
else {
|
|
6858
6861
|
i.destroy();
|
|
6859
|
-
let t = new CanvasCircleRenderer(e, n,
|
|
6860
|
-
|
|
6862
|
+
let t = new CanvasCircleRenderer(e, n, D, O, k, A);
|
|
6863
|
+
I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6861
6864
|
}
|
|
6862
6865
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
6863
6866
|
else {
|
|
6864
6867
|
i.destroy();
|
|
6865
|
-
let t = new CircleRenderer(e, n,
|
|
6866
|
-
|
|
6868
|
+
let t = new CircleRenderer(e, n, D, O, k, A);
|
|
6869
|
+
I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6867
6870
|
}
|
|
6868
6871
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
6869
6872
|
else {
|
|
6870
6873
|
let t = null;
|
|
6871
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n,
|
|
6874
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, D, O) : n.type === "image" ? t = new CanvasImageRenderer(e, n, D, O) : n.type === "marker" ? t = new MarkerRenderer(e, n, D, O) : n.type === "unit" ? t = new UnitRenderer(e, n, D, O) : n.type === "polygon" ? t = new PolygonRenderer(e, n, D, O, k, j) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, D, O, k, A) : new CircleRenderer(e, n, D, O, k, A) : n.type === "square" ? t = new SquareRenderer(e, n, D, O, k, j) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, D, O, k, j) : n.type === "polyline" && (t = new PolylineRenderer(e, n, D, O, j)), t && (I.current.set(n.id, t), t.setSelected(r.has(String(n.id))), yt.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
6872
6875
|
}
|
|
6873
6876
|
}
|
|
6874
|
-
for (let e of
|
|
6875
|
-
let t =
|
|
6877
|
+
for (let e of yt.current) {
|
|
6878
|
+
let t = I.current.get(e);
|
|
6876
6879
|
t && t.setEditing?.(!0);
|
|
6877
6880
|
}
|
|
6878
6881
|
}, [
|
|
6882
|
+
w,
|
|
6883
|
+
T,
|
|
6879
6884
|
E,
|
|
6880
6885
|
D,
|
|
6881
6886
|
O,
|
|
6882
6887
|
k,
|
|
6883
6888
|
A,
|
|
6884
|
-
j
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
R.current.clear();
|
|
6890
|
-
}, []), fn = useCallback((e) => {
|
|
6889
|
+
j
|
|
6890
|
+
]), fn = useCallback(() => {
|
|
6891
|
+
for (let e of I.current.values()) e.destroy();
|
|
6892
|
+
I.current.clear();
|
|
6893
|
+
}, []), pn = useCallback((e) => {
|
|
6891
6894
|
let t = e.getStyle();
|
|
6892
6895
|
if (!t?.layers) return;
|
|
6893
6896
|
let n = [
|
|
@@ -6902,10 +6905,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6902
6905
|
"marker-"
|
|
6903
6906
|
];
|
|
6904
6907
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6905
|
-
}, []),
|
|
6906
|
-
let t =
|
|
6908
|
+
}, []), mn = useCallback((e) => {
|
|
6909
|
+
let t = C, n = { "raster-opacity": e.opacity ?? 1 }, r = e.brightness ?? t?.brightness, i = e.saturation ?? t?.saturation, a = e.contrast ?? t?.contrast, o = e.hueRotate ?? t?.hueRotate;
|
|
6907
6910
|
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;
|
|
6908
|
-
}, [
|
|
6911
|
+
}, [C]), hn = useCallback((e, t) => {
|
|
6909
6912
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6910
6913
|
type: "raster",
|
|
6911
6914
|
tiles: [t.url],
|
|
@@ -6915,27 +6918,28 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6915
6918
|
scheme: t.scheme ?? "xyz"
|
|
6916
6919
|
};
|
|
6917
6920
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6918
|
-
let a =
|
|
6921
|
+
let a = pn(e);
|
|
6919
6922
|
e.addLayer({
|
|
6920
6923
|
id: r,
|
|
6921
6924
|
type: "raster",
|
|
6922
6925
|
source: n,
|
|
6923
|
-
paint:
|
|
6926
|
+
paint: mn(t),
|
|
6924
6927
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6925
6928
|
}, a);
|
|
6926
|
-
}, [
|
|
6929
|
+
}, [pn, mn]), gn = useCallback(async (e, t) => {
|
|
6927
6930
|
try {
|
|
6928
6931
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6929
|
-
if (!
|
|
6930
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6932
|
+
if (!Ge.current.has(t.id)) return;
|
|
6933
|
+
let a = n.format === "pbf" || n.vector_layers, o = pn(e);
|
|
6934
|
+
if (a) {
|
|
6935
|
+
let t = {
|
|
6936
|
+
type: "vector",
|
|
6937
|
+
tiles: n.tiles,
|
|
6938
|
+
minzoom: n.minzoom ?? 0,
|
|
6939
|
+
maxzoom: n.maxzoom ?? 22
|
|
6940
|
+
};
|
|
6941
|
+
n.bounds && (t.bounds = n.bounds), n.attribution && (t.attribution = n.attribution), e.addSource(r, t);
|
|
6942
|
+
} else e.addSource(r, {
|
|
6939
6943
|
type: "raster",
|
|
6940
6944
|
tiles: n.tiles,
|
|
6941
6945
|
tileSize: t.tileSize ?? n.tileSize ?? 256,
|
|
@@ -6947,21 +6951,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6947
6951
|
id: i,
|
|
6948
6952
|
type: "raster",
|
|
6949
6953
|
source: r,
|
|
6950
|
-
paint:
|
|
6954
|
+
paint: mn(t),
|
|
6951
6955
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6952
|
-
}, o)
|
|
6956
|
+
}, o);
|
|
6953
6957
|
} catch (e) {
|
|
6954
6958
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
6955
6959
|
}
|
|
6956
|
-
}, [
|
|
6960
|
+
}, [pn, mn]), _n = useCallback(async (e, t) => {
|
|
6957
6961
|
try {
|
|
6958
6962
|
let n = await (await fetch(t.url)).json();
|
|
6959
|
-
if (!
|
|
6963
|
+
if (!Ge.current.has(t.id)) return;
|
|
6960
6964
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
6961
6965
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
6962
6966
|
e.getSource(n) || e.addSource(n, i);
|
|
6963
6967
|
}
|
|
6964
|
-
let r =
|
|
6968
|
+
let r = pn(e);
|
|
6965
6969
|
if (n.layers) for (let i of n.layers) {
|
|
6966
6970
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
6967
6971
|
if (e.getLayer(n)) continue;
|
|
@@ -6972,7 +6976,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6972
6976
|
};
|
|
6973
6977
|
i.type === "raster" && (a.paint = {
|
|
6974
6978
|
...a.paint,
|
|
6975
|
-
...
|
|
6979
|
+
...mn(t)
|
|
6976
6980
|
}), t.visible === !1 && (a.layout = {
|
|
6977
6981
|
...a.layout,
|
|
6978
6982
|
visibility: "none"
|
|
@@ -6985,50 +6989,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6985
6989
|
} catch (e) {
|
|
6986
6990
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
6987
6991
|
}
|
|
6988
|
-
}, [
|
|
6992
|
+
}, [pn, mn]), vn = useCallback((e, t) => {
|
|
6989
6993
|
let n = e.getStyle();
|
|
6990
6994
|
if (!n) return;
|
|
6991
6995
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
6992
6996
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
6993
6997
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
6994
6998
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
6995
|
-
}, []),
|
|
6996
|
-
let t =
|
|
6999
|
+
}, []), yn = useCallback((e) => {
|
|
7000
|
+
let t = F.current;
|
|
6997
7001
|
if (!t) return;
|
|
6998
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
6999
|
-
for (let e of r) n.has(e) || (
|
|
7002
|
+
let n = new Set(e.map((e) => e.id)), r = Ge.current;
|
|
7003
|
+
for (let e of r) n.has(e) || (vn(t, e), r.delete(e));
|
|
7000
7004
|
for (let n of e) if (r.has(n.id)) {
|
|
7001
7005
|
let e = `base-layer-${n.id}`;
|
|
7002
7006
|
if (t.getLayer(e)) {
|
|
7003
|
-
let r =
|
|
7007
|
+
let r = mn(n);
|
|
7004
7008
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7005
7009
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7006
7010
|
}
|
|
7007
7011
|
} else switch (r.add(n.id), n.type) {
|
|
7008
7012
|
case "raster":
|
|
7009
|
-
|
|
7013
|
+
hn(t, n);
|
|
7010
7014
|
break;
|
|
7011
7015
|
case "tilejson":
|
|
7012
|
-
|
|
7016
|
+
gn(t, n);
|
|
7013
7017
|
break;
|
|
7014
7018
|
case "style":
|
|
7015
|
-
|
|
7019
|
+
_n(t, n);
|
|
7016
7020
|
break;
|
|
7017
7021
|
default: {
|
|
7018
7022
|
let e = n;
|
|
7019
|
-
e.url &&
|
|
7023
|
+
e.url && hn(t, {
|
|
7020
7024
|
...e,
|
|
7021
7025
|
type: "raster"
|
|
7022
7026
|
});
|
|
7023
7027
|
}
|
|
7024
7028
|
}
|
|
7025
7029
|
}, [
|
|
7026
|
-
mn,
|
|
7027
7030
|
hn,
|
|
7028
7031
|
gn,
|
|
7029
7032
|
_n,
|
|
7030
|
-
|
|
7031
|
-
|
|
7033
|
+
vn,
|
|
7034
|
+
mn
|
|
7035
|
+
]), bn = useCallback((e) => {
|
|
7032
7036
|
let t = e;
|
|
7033
7037
|
for (; t;) {
|
|
7034
7038
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7036,158 +7040,158 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7036
7040
|
t = t.parentElement;
|
|
7037
7041
|
}
|
|
7038
7042
|
return null;
|
|
7039
|
-
}, []),
|
|
7043
|
+
}, []), xn = useCallback((e) => {
|
|
7040
7044
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7041
7045
|
x: e.point.x,
|
|
7042
7046
|
y: e.point.y
|
|
7043
|
-
}, r =
|
|
7047
|
+
}, r = kn.current;
|
|
7044
7048
|
if (r === "picker") {
|
|
7045
7049
|
let e = {
|
|
7046
7050
|
lng: t[0],
|
|
7047
7051
|
lat: t[1]
|
|
7048
7052
|
};
|
|
7049
|
-
|
|
7053
|
+
it(e), At(t), An.current?.(e);
|
|
7050
7054
|
return;
|
|
7051
7055
|
}
|
|
7052
|
-
if (
|
|
7056
|
+
if (gt.current) return;
|
|
7053
7057
|
if (r === "edit") {
|
|
7054
|
-
let e =
|
|
7058
|
+
let e = Mn.current;
|
|
7055
7059
|
if (e === "rectangle") {
|
|
7056
|
-
let e =
|
|
7057
|
-
if (!e)
|
|
7060
|
+
let e = Nn.current;
|
|
7061
|
+
if (!e) lt(t);
|
|
7058
7062
|
else {
|
|
7059
|
-
let n =
|
|
7063
|
+
let n = U.current, r = applyEntityConfig({
|
|
7060
7064
|
...n,
|
|
7061
|
-
id: n?.id ??
|
|
7065
|
+
id: n?.id ?? Mt(),
|
|
7062
7066
|
type: "rectangle",
|
|
7063
7067
|
bounds: [e, t]
|
|
7064
|
-
},
|
|
7065
|
-
|
|
7066
|
-
let i =
|
|
7067
|
-
if (i && !
|
|
7068
|
-
let e = new RectangleRenderer(i, r,
|
|
7069
|
-
|
|
7068
|
+
}, E);
|
|
7069
|
+
Lt();
|
|
7070
|
+
let i = F.current;
|
|
7071
|
+
if (i && !I.current.has(r.id)) {
|
|
7072
|
+
let e = new RectangleRenderer(i, r, D, O, k, j);
|
|
7073
|
+
I.current.set(r.id, e);
|
|
7070
7074
|
}
|
|
7071
|
-
|
|
7075
|
+
Q.current.onRectangleAdd?.(r), lt(null), U.current = null, H.current && (H.current = !1, V(null), i && (i.getCanvas().style.cursor = ""));
|
|
7072
7076
|
}
|
|
7073
7077
|
return;
|
|
7074
7078
|
}
|
|
7075
7079
|
if (e === "circle") {
|
|
7076
|
-
let e =
|
|
7077
|
-
if (!e)
|
|
7080
|
+
let e = dt.current;
|
|
7081
|
+
if (!e) dt.current = { center: t };
|
|
7078
7082
|
else {
|
|
7079
|
-
let n =
|
|
7083
|
+
let n = Bt(e.center, t), r = W.current, i = applyEntityConfig({
|
|
7080
7084
|
...r,
|
|
7081
|
-
id: r?.id ??
|
|
7085
|
+
id: r?.id ?? Mt(),
|
|
7082
7086
|
type: "circle",
|
|
7083
7087
|
center: e.center,
|
|
7084
7088
|
radius: n
|
|
7085
|
-
},
|
|
7086
|
-
|
|
7087
|
-
let a =
|
|
7088
|
-
if (a && !
|
|
7089
|
-
let e = new CircleRenderer(a, i,
|
|
7090
|
-
|
|
7089
|
+
}, E);
|
|
7090
|
+
Ht();
|
|
7091
|
+
let a = F.current;
|
|
7092
|
+
if (a && !I.current.has(i.id)) {
|
|
7093
|
+
let e = new CircleRenderer(a, i, D, O, k, A);
|
|
7094
|
+
I.current.set(i.id, e);
|
|
7091
7095
|
}
|
|
7092
|
-
|
|
7096
|
+
Q.current.onCircleAdd?.(i), dt.current = null, W.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
7093
7097
|
}
|
|
7094
7098
|
return;
|
|
7095
7099
|
}
|
|
7096
7100
|
if (e === "polygon") {
|
|
7097
|
-
let e =
|
|
7101
|
+
let e = ft.current;
|
|
7098
7102
|
if (e.length >= 3) {
|
|
7099
7103
|
let n = e[0];
|
|
7100
|
-
if (
|
|
7101
|
-
let t =
|
|
7104
|
+
if (Bt(n, t) < 20) {
|
|
7105
|
+
let t = G.current, n = applyEntityConfig({
|
|
7102
7106
|
...t,
|
|
7103
|
-
id: t?.id ??
|
|
7107
|
+
id: t?.id ?? Mt(),
|
|
7104
7108
|
type: "polygon",
|
|
7105
7109
|
coordinates: [...e]
|
|
7106
|
-
},
|
|
7107
|
-
|
|
7108
|
-
let r =
|
|
7109
|
-
if (r && !
|
|
7110
|
-
let e = new PolygonRenderer(r, n,
|
|
7111
|
-
|
|
7110
|
+
}, E);
|
|
7111
|
+
Kt();
|
|
7112
|
+
let r = F.current;
|
|
7113
|
+
if (r && !I.current.has(n.id)) {
|
|
7114
|
+
let e = new PolygonRenderer(r, n, D, O, k, j);
|
|
7115
|
+
I.current.set(n.id, e);
|
|
7112
7116
|
}
|
|
7113
|
-
|
|
7117
|
+
Q.current.onPolygonAdd?.(n), ft.current = [], G.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7114
7118
|
return;
|
|
7115
7119
|
}
|
|
7116
7120
|
}
|
|
7117
|
-
|
|
7121
|
+
ft.current = [...e, t];
|
|
7118
7122
|
return;
|
|
7119
7123
|
}
|
|
7120
7124
|
if (e === "square") {
|
|
7121
|
-
let e =
|
|
7122
|
-
if (!e)
|
|
7125
|
+
let e = pt.current;
|
|
7126
|
+
if (!e) pt.current = { center: t };
|
|
7123
7127
|
else {
|
|
7124
|
-
let n =
|
|
7128
|
+
let n = Bt(e.center, t) * 2, r = K.current, i = applyEntityConfig({
|
|
7125
7129
|
...r,
|
|
7126
|
-
id: r?.id ??
|
|
7130
|
+
id: r?.id ?? Mt(),
|
|
7127
7131
|
type: "square",
|
|
7128
7132
|
center: e.center,
|
|
7129
7133
|
length: n
|
|
7130
|
-
},
|
|
7131
|
-
|
|
7132
|
-
let a =
|
|
7133
|
-
if (a && !
|
|
7134
|
-
let e = new SquareRenderer(a, i,
|
|
7135
|
-
|
|
7134
|
+
}, E);
|
|
7135
|
+
Zt();
|
|
7136
|
+
let a = F.current;
|
|
7137
|
+
if (a && !I.current.has(i.id)) {
|
|
7138
|
+
let e = new SquareRenderer(a, i, D, O, k, j);
|
|
7139
|
+
I.current.set(i.id, e);
|
|
7136
7140
|
}
|
|
7137
|
-
|
|
7141
|
+
Q.current.onSquareAdd?.(i), pt.current = null, K.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
|
|
7138
7142
|
}
|
|
7139
7143
|
return;
|
|
7140
7144
|
}
|
|
7141
7145
|
if (e === "polyline") {
|
|
7142
|
-
|
|
7146
|
+
mt.current = [...mt.current, t];
|
|
7143
7147
|
return;
|
|
7144
7148
|
}
|
|
7145
|
-
let n =
|
|
7149
|
+
let n = ut.current;
|
|
7146
7150
|
if (n && n.src && n.width) {
|
|
7147
7151
|
let e = {
|
|
7148
7152
|
...n,
|
|
7149
|
-
id: n.id ??
|
|
7153
|
+
id: n.id ?? Mt(),
|
|
7150
7154
|
type: "marker",
|
|
7151
7155
|
center: t,
|
|
7152
7156
|
src: n.src,
|
|
7153
7157
|
width: n.width
|
|
7154
7158
|
};
|
|
7155
|
-
|
|
7159
|
+
Q.current.onMarkerAdd?.(e), B(null), V(null), Y(), ut.current = null, H.current = !1;
|
|
7156
7160
|
return;
|
|
7157
7161
|
}
|
|
7158
|
-
let r =
|
|
7162
|
+
let r = jn.current;
|
|
7159
7163
|
if (r) {
|
|
7160
7164
|
let e = {
|
|
7161
|
-
id:
|
|
7165
|
+
id: Mt(),
|
|
7162
7166
|
type: "marker",
|
|
7163
7167
|
name: r.name,
|
|
7164
7168
|
center: t,
|
|
7165
7169
|
src: r.icon,
|
|
7166
7170
|
width: r.size || r.width || 32
|
|
7167
7171
|
};
|
|
7168
|
-
r.customData !== void 0 && (e.customData = r.customData),
|
|
7172
|
+
r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), B(null), V(null), Y(), H.current = !1;
|
|
7169
7173
|
return;
|
|
7170
7174
|
}
|
|
7171
7175
|
}
|
|
7172
|
-
if (
|
|
7173
|
-
let e =
|
|
7174
|
-
if (
|
|
7175
|
-
let { entityId: e, activeHandle: n } =
|
|
7176
|
+
if (yt.current.length > 0) {
|
|
7177
|
+
let e = F.current?.getZoom() ?? 12;
|
|
7178
|
+
if (J.current) {
|
|
7179
|
+
let { entityId: e, activeHandle: n } = J.current, r = I.current.get(e);
|
|
7176
7180
|
if (r?.applyHandleMove) {
|
|
7177
7181
|
let e = r.applyHandleMove(n, t);
|
|
7178
|
-
|
|
7182
|
+
Q.current.onEntityEdit?.(e);
|
|
7179
7183
|
}
|
|
7180
|
-
|
|
7184
|
+
J.current = null;
|
|
7181
7185
|
return;
|
|
7182
7186
|
}
|
|
7183
|
-
for (let n of
|
|
7184
|
-
let r =
|
|
7187
|
+
for (let n of yt.current) {
|
|
7188
|
+
let r = I.current.get(n);
|
|
7185
7189
|
if (!r?.getEditHandleAt) continue;
|
|
7186
7190
|
let i = r.getEditHandleAt(t, e);
|
|
7187
7191
|
if (i) {
|
|
7188
7192
|
if (i.type === "midpoint" && r.addVertex) {
|
|
7189
7193
|
let e = r.addVertex(i.index, i.position);
|
|
7190
|
-
|
|
7194
|
+
Q.current.onEntityEdit?.(e), J.current = {
|
|
7191
7195
|
entityId: n,
|
|
7192
7196
|
activeHandle: {
|
|
7193
7197
|
type: "vertex",
|
|
@@ -7195,7 +7199,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7195
7199
|
position: i.position
|
|
7196
7200
|
}
|
|
7197
7201
|
};
|
|
7198
|
-
} else
|
|
7202
|
+
} else J.current = {
|
|
7199
7203
|
entityId: n,
|
|
7200
7204
|
activeHandle: i
|
|
7201
7205
|
};
|
|
@@ -7203,186 +7207,186 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7203
7207
|
}
|
|
7204
7208
|
}
|
|
7205
7209
|
}
|
|
7206
|
-
let i =
|
|
7210
|
+
let i = En.current, a = Dn.current, o = On.current, s = bn(e.originalEvent.target);
|
|
7207
7211
|
if (s) {
|
|
7208
7212
|
let e = i.find((e) => String(e.id) === s);
|
|
7209
7213
|
if (e) {
|
|
7210
7214
|
if (a?.(e), e.popup) {
|
|
7211
|
-
let t = e.popup.content ??
|
|
7212
|
-
t && mergePopupConfig(e.popup,
|
|
7215
|
+
let t = e.popup.content ?? Ie?.(e);
|
|
7216
|
+
t && mergePopupConfig(e.popup, P, t).trigger === "click" && o(s, "click", n);
|
|
7213
7217
|
}
|
|
7214
7218
|
return;
|
|
7215
7219
|
}
|
|
7216
7220
|
}
|
|
7217
|
-
for (let [t, r] of
|
|
7221
|
+
for (let [t, r] of I.current) {
|
|
7218
7222
|
let s = r.getLabelLayerId();
|
|
7219
|
-
if (s &&
|
|
7223
|
+
if (s && F.current?.getLayer(s) && F.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
7220
7224
|
let e = i.find((e) => e.id === t);
|
|
7221
7225
|
if (e) {
|
|
7222
7226
|
if (a?.(e), e.popup) {
|
|
7223
|
-
let r = e.popup.content ??
|
|
7224
|
-
r && mergePopupConfig(e.popup,
|
|
7227
|
+
let r = e.popup.content ?? Ie?.(e);
|
|
7228
|
+
r && mergePopupConfig(e.popup, P, r).trigger === "click" && o(t, "click", n);
|
|
7225
7229
|
}
|
|
7226
7230
|
return;
|
|
7227
7231
|
}
|
|
7228
7232
|
}
|
|
7229
7233
|
}
|
|
7230
|
-
for (let [e, r] of
|
|
7234
|
+
for (let [e, r] of I.current) if (r.isPointInEntity(t)) {
|
|
7231
7235
|
let t = i.find((t) => t.id === e);
|
|
7232
7236
|
if (t) {
|
|
7233
7237
|
if (a?.(t), t.popup) {
|
|
7234
|
-
let r = t.popup.content ??
|
|
7235
|
-
r && mergePopupConfig(t.popup,
|
|
7238
|
+
let r = t.popup.content ?? Ie?.(t);
|
|
7239
|
+
r && mergePopupConfig(t.popup, P, r).trigger === "click" && o(e, "click", n);
|
|
7236
7240
|
}
|
|
7237
7241
|
return;
|
|
7238
7242
|
}
|
|
7239
7243
|
}
|
|
7240
7244
|
}, [
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
]),
|
|
7245
|
+
P,
|
|
7246
|
+
Ie,
|
|
7247
|
+
bn
|
|
7248
|
+
]), Sn = useCallback((e) => {
|
|
7245
7249
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7246
|
-
if (
|
|
7247
|
-
let { entityId: e, activeHandle: n } =
|
|
7248
|
-
|
|
7250
|
+
if (J.current) {
|
|
7251
|
+
let { entityId: e, activeHandle: n } = J.current;
|
|
7252
|
+
I.current.get(e)?.updateEditPreview?.(n, t);
|
|
7249
7253
|
return;
|
|
7250
7254
|
}
|
|
7251
|
-
let n =
|
|
7252
|
-
n === "rectangle" && r &&
|
|
7253
|
-
let i =
|
|
7254
|
-
n === "circle" && i &&
|
|
7255
|
-
let a =
|
|
7256
|
-
n === "polygon" && a.length > 0 &&
|
|
7257
|
-
let o =
|
|
7258
|
-
n === "square" && o &&
|
|
7259
|
-
let s =
|
|
7260
|
-
n === "polyline" && s.length > 0 &&
|
|
7261
|
-
let c =
|
|
7262
|
-
for (let [e, n] of
|
|
7255
|
+
let n = Mn.current, r = Nn.current;
|
|
7256
|
+
n === "rectangle" && r && It(r, t);
|
|
7257
|
+
let i = dt.current;
|
|
7258
|
+
n === "circle" && i && Vt(i.center, t);
|
|
7259
|
+
let a = ft.current;
|
|
7260
|
+
n === "polygon" && a.length > 0 && Gt(a, t);
|
|
7261
|
+
let o = pt.current;
|
|
7262
|
+
n === "square" && o && Xt(o.center, t);
|
|
7263
|
+
let s = mt.current;
|
|
7264
|
+
n === "polyline" && s.length > 0 && en(s, t);
|
|
7265
|
+
let c = En.current, l = On.current;
|
|
7266
|
+
for (let [e, n] of I.current) if (n.isPointInEntity(t)) {
|
|
7263
7267
|
let t = c.find((t) => t.id === e);
|
|
7264
7268
|
if (!t?.popup) continue;
|
|
7265
|
-
let n = t.popup.content ??
|
|
7269
|
+
let n = t.popup.content ?? Ie?.(t);
|
|
7266
7270
|
if (!n) continue;
|
|
7267
|
-
let r = mergePopupConfig(t.popup,
|
|
7271
|
+
let r = mergePopupConfig(t.popup, P, n);
|
|
7268
7272
|
if (r.trigger === "hover") {
|
|
7269
|
-
|
|
7273
|
+
Ye.current && clearTimeout(Ye.current), Ye.current = window.setTimeout(() => {
|
|
7270
7274
|
l(e, "hover");
|
|
7271
7275
|
}, r.hoverDelay);
|
|
7272
7276
|
return;
|
|
7273
7277
|
}
|
|
7274
7278
|
}
|
|
7275
|
-
if (
|
|
7276
|
-
let e =
|
|
7277
|
-
e && !e.isPointInEntity(t) &&
|
|
7279
|
+
if (Ye.current &&= (clearTimeout(Ye.current), null), R?.openedBy === "hover") {
|
|
7280
|
+
let e = I.current.get(R.entityId);
|
|
7281
|
+
e && !e.isPointInEntity(t) && Tt(R.entityId);
|
|
7278
7282
|
}
|
|
7279
7283
|
}, [
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
]),
|
|
7290
|
-
if (e.preventDefault(),
|
|
7291
|
-
if (
|
|
7284
|
+
P,
|
|
7285
|
+
Ie,
|
|
7286
|
+
R,
|
|
7287
|
+
Tt,
|
|
7288
|
+
It,
|
|
7289
|
+
Vt,
|
|
7290
|
+
Gt,
|
|
7291
|
+
Xt,
|
|
7292
|
+
en
|
|
7293
|
+
]), Cn = useCallback((e) => {
|
|
7294
|
+
if (e.preventDefault(), gt.current) return;
|
|
7295
|
+
if (yt.current.length > 0) {
|
|
7292
7296
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7293
|
-
if (
|
|
7294
|
-
|
|
7297
|
+
if (J.current) {
|
|
7298
|
+
I.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7295
7299
|
return;
|
|
7296
7300
|
}
|
|
7297
|
-
let n =
|
|
7298
|
-
for (let e of
|
|
7299
|
-
let r =
|
|
7301
|
+
let n = F.current?.getZoom() ?? 12;
|
|
7302
|
+
for (let e of yt.current) {
|
|
7303
|
+
let r = I.current.get(e);
|
|
7300
7304
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7301
7305
|
let i = r.getEditHandleAt(t, n);
|
|
7302
7306
|
if (i && i.type === "vertex") {
|
|
7303
7307
|
let e = r.deleteVertex(i.index);
|
|
7304
|
-
e &&
|
|
7308
|
+
e && Q.current.onEntityEdit?.(e);
|
|
7305
7309
|
return;
|
|
7306
7310
|
}
|
|
7307
7311
|
}
|
|
7308
7312
|
}
|
|
7309
|
-
if (
|
|
7310
|
-
if (
|
|
7311
|
-
|
|
7313
|
+
if (kn.current !== "edit") return;
|
|
7314
|
+
if (jn.current) {
|
|
7315
|
+
B(null), V(null), Y();
|
|
7312
7316
|
return;
|
|
7313
7317
|
}
|
|
7314
|
-
let t =
|
|
7318
|
+
let t = Mn.current;
|
|
7315
7319
|
if (t === "rectangle") {
|
|
7316
|
-
if (
|
|
7320
|
+
if (Nn.current) lt(null), Lt();
|
|
7317
7321
|
else {
|
|
7318
|
-
|
|
7319
|
-
let e =
|
|
7322
|
+
V(null);
|
|
7323
|
+
let e = F.current;
|
|
7320
7324
|
e && (e.getCanvas().style.cursor = "");
|
|
7321
7325
|
}
|
|
7322
7326
|
return;
|
|
7323
7327
|
}
|
|
7324
7328
|
if (t === "circle") {
|
|
7325
|
-
if (
|
|
7329
|
+
if (dt.current) dt.current = null, Ht();
|
|
7326
7330
|
else {
|
|
7327
|
-
|
|
7328
|
-
let e =
|
|
7331
|
+
V(null);
|
|
7332
|
+
let e = F.current;
|
|
7329
7333
|
e && (e.getCanvas().style.cursor = "");
|
|
7330
7334
|
}
|
|
7331
7335
|
return;
|
|
7332
7336
|
}
|
|
7333
7337
|
if (t === "polygon") {
|
|
7334
|
-
let e =
|
|
7338
|
+
let e = ft.current;
|
|
7335
7339
|
if (e.length >= 3) {
|
|
7336
|
-
let t =
|
|
7340
|
+
let t = G.current, n = applyEntityConfig({
|
|
7337
7341
|
...t,
|
|
7338
|
-
id: t?.id ??
|
|
7342
|
+
id: t?.id ?? Mt(),
|
|
7339
7343
|
type: "polygon",
|
|
7340
7344
|
coordinates: [...e]
|
|
7341
|
-
},
|
|
7342
|
-
|
|
7343
|
-
let r =
|
|
7344
|
-
if (r && !
|
|
7345
|
-
let e = new PolygonRenderer(r, n,
|
|
7346
|
-
|
|
7345
|
+
}, E);
|
|
7346
|
+
Kt();
|
|
7347
|
+
let r = F.current;
|
|
7348
|
+
if (r && !I.current.has(n.id)) {
|
|
7349
|
+
let e = new PolygonRenderer(r, n, D, O, k, j);
|
|
7350
|
+
I.current.set(n.id, e);
|
|
7347
7351
|
}
|
|
7348
|
-
|
|
7349
|
-
} else if (e.length > 0)
|
|
7352
|
+
Q.current.onPolygonAdd?.(n), ft.current = [], G.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7353
|
+
} else if (e.length > 0) ft.current = [], Kt();
|
|
7350
7354
|
else {
|
|
7351
|
-
|
|
7352
|
-
let e =
|
|
7355
|
+
V(null);
|
|
7356
|
+
let e = F.current;
|
|
7353
7357
|
e && (e.getCanvas().style.cursor = "");
|
|
7354
7358
|
}
|
|
7355
7359
|
return;
|
|
7356
7360
|
}
|
|
7357
7361
|
if (t === "square") {
|
|
7358
|
-
if (
|
|
7362
|
+
if (pt.current) pt.current = null, Zt();
|
|
7359
7363
|
else {
|
|
7360
|
-
|
|
7361
|
-
let e =
|
|
7364
|
+
V(null);
|
|
7365
|
+
let e = F.current;
|
|
7362
7366
|
e && (e.getCanvas().style.cursor = "");
|
|
7363
7367
|
}
|
|
7364
7368
|
return;
|
|
7365
7369
|
}
|
|
7366
7370
|
if (t === "polyline") {
|
|
7367
|
-
let e =
|
|
7371
|
+
let e = mt.current;
|
|
7368
7372
|
if (e.length >= 2) {
|
|
7369
|
-
let t =
|
|
7373
|
+
let t = q.current, n = applyEntityConfig({
|
|
7370
7374
|
...t,
|
|
7371
|
-
id: t?.id ??
|
|
7375
|
+
id: t?.id ?? Mt(),
|
|
7372
7376
|
type: "polyline",
|
|
7373
7377
|
coordinates: [...e]
|
|
7374
|
-
},
|
|
7375
|
-
|
|
7376
|
-
let r =
|
|
7377
|
-
if (r && !
|
|
7378
|
-
let e = new PolylineRenderer(r, n,
|
|
7379
|
-
|
|
7378
|
+
}, E);
|
|
7379
|
+
tn();
|
|
7380
|
+
let r = F.current;
|
|
7381
|
+
if (r && !I.current.has(n.id)) {
|
|
7382
|
+
let e = new PolylineRenderer(r, n, D, O, j);
|
|
7383
|
+
I.current.set(n.id, e);
|
|
7380
7384
|
}
|
|
7381
|
-
|
|
7382
|
-
} else if (e.length > 0)
|
|
7385
|
+
Q.current.onPolylineAdd?.(n), mt.current = [], q.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
|
|
7386
|
+
} else if (e.length > 0) mt.current = [], tn();
|
|
7383
7387
|
else {
|
|
7384
|
-
|
|
7385
|
-
let e =
|
|
7388
|
+
V(null);
|
|
7389
|
+
let e = F.current;
|
|
7386
7390
|
e && (e.getCanvas().style.cursor = "");
|
|
7387
7391
|
}
|
|
7388
7392
|
return;
|
|
@@ -7390,45 +7394,45 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7390
7394
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7391
7395
|
x: e.point.x,
|
|
7392
7396
|
y: e.point.y
|
|
7393
|
-
}, i =
|
|
7397
|
+
}, i = En.current, a = bn(e.originalEvent.target);
|
|
7394
7398
|
if (a) {
|
|
7395
7399
|
let e = i.find((e) => String(e.id) === a);
|
|
7396
7400
|
if (e) {
|
|
7397
|
-
|
|
7401
|
+
wn(e, r, n);
|
|
7398
7402
|
return;
|
|
7399
7403
|
}
|
|
7400
7404
|
}
|
|
7401
|
-
for (let [t, a] of
|
|
7405
|
+
for (let [t, a] of I.current) {
|
|
7402
7406
|
let o = a.getLabelLayerId();
|
|
7403
|
-
if (o &&
|
|
7407
|
+
if (o && F.current?.getLayer(o) && F.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7404
7408
|
let e = i.find((e) => e.id === t);
|
|
7405
7409
|
if (e) {
|
|
7406
|
-
|
|
7410
|
+
wn(e, r, n);
|
|
7407
7411
|
return;
|
|
7408
7412
|
}
|
|
7409
7413
|
}
|
|
7410
7414
|
}
|
|
7411
|
-
for (let [e, t] of
|
|
7415
|
+
for (let [e, t] of I.current) if (t.isPointInEntity(n)) {
|
|
7412
7416
|
let t = i.find((t) => t.id === e);
|
|
7413
7417
|
if (t) {
|
|
7414
|
-
|
|
7418
|
+
wn(t, r, n);
|
|
7415
7419
|
return;
|
|
7416
7420
|
}
|
|
7417
7421
|
}
|
|
7418
7422
|
}, [
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
]),
|
|
7427
|
-
let r =
|
|
7423
|
+
bn,
|
|
7424
|
+
Y,
|
|
7425
|
+
Lt,
|
|
7426
|
+
Ht,
|
|
7427
|
+
Kt,
|
|
7428
|
+
Zt,
|
|
7429
|
+
tn
|
|
7430
|
+
]), wn = useCallback((e, t, n) => {
|
|
7431
|
+
let r = Ue.current?.getBoundingClientRect(), i = r ? {
|
|
7428
7432
|
x: t.x + r.left,
|
|
7429
7433
|
y: t.y + r.top
|
|
7430
7434
|
} : t;
|
|
7431
|
-
|
|
7435
|
+
Ze({
|
|
7432
7436
|
position: i,
|
|
7433
7437
|
lngLat: n,
|
|
7434
7438
|
items: [{
|
|
@@ -7444,12 +7448,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7444
7448
|
}),
|
|
7445
7449
|
danger: !0,
|
|
7446
7450
|
onClick: () => {
|
|
7447
|
-
|
|
7451
|
+
Q.current.onEntityDelete?.(e);
|
|
7448
7452
|
}
|
|
7449
7453
|
}]
|
|
7450
7454
|
});
|
|
7451
|
-
}, []),
|
|
7452
|
-
|
|
7455
|
+
}, []), Tn = useCallback(() => {
|
|
7456
|
+
Ze(null);
|
|
7453
7457
|
}, []);
|
|
7454
7458
|
useEffect(() => {
|
|
7455
7459
|
let e = document.createElement("div");
|
|
@@ -7460,11 +7464,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7460
7464
|
width: 100%;
|
|
7461
7465
|
pointer-events: none;
|
|
7462
7466
|
height: 100%;
|
|
7463
|
-
z-index: ${
|
|
7464
|
-
`, document.body.appendChild(e),
|
|
7467
|
+
z-index: ${P?.zIndex ?? 1e3};
|
|
7468
|
+
`, document.body.appendChild(e), qe.current = e, () => {
|
|
7465
7469
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7466
7470
|
};
|
|
7467
|
-
}, [
|
|
7471
|
+
}, [P?.zIndex]), useEffect(() => {
|
|
7468
7472
|
let e = document.createElement("div");
|
|
7469
7473
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
7470
7474
|
position: fixed;
|
|
@@ -7473,65 +7477,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7473
7477
|
width: 100%;
|
|
7474
7478
|
pointer-events: none;
|
|
7475
7479
|
height: 100%;
|
|
7476
|
-
z-index: ${(
|
|
7477
|
-
`, document.body.appendChild(e),
|
|
7480
|
+
z-index: ${(P?.zIndex ?? 1e3) + 100};
|
|
7481
|
+
`, document.body.appendChild(e), Qe.current = e, () => {
|
|
7478
7482
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7479
7483
|
};
|
|
7480
|
-
}, [
|
|
7481
|
-
let
|
|
7482
|
-
|
|
7483
|
-
let
|
|
7484
|
-
|
|
7485
|
-
let
|
|
7486
|
-
|
|
7487
|
-
let
|
|
7488
|
-
|
|
7489
|
-
let
|
|
7490
|
-
|
|
7491
|
-
let
|
|
7492
|
-
|
|
7493
|
-
let
|
|
7494
|
-
|
|
7495
|
-
let
|
|
7496
|
-
|
|
7497
|
-
let
|
|
7498
|
-
|
|
7499
|
-
let
|
|
7500
|
-
|
|
7484
|
+
}, [P?.zIndex]);
|
|
7485
|
+
let En = useRef(w);
|
|
7486
|
+
En.current = w;
|
|
7487
|
+
let Dn = useRef(Re);
|
|
7488
|
+
Dn.current = Re;
|
|
7489
|
+
let On = useRef(wt);
|
|
7490
|
+
On.current = wt;
|
|
7491
|
+
let kn = useRef(tt);
|
|
7492
|
+
kn.current = tt;
|
|
7493
|
+
let An = useRef(y);
|
|
7494
|
+
An.current = y;
|
|
7495
|
+
let jn = useRef(ot);
|
|
7496
|
+
jn.current = ot;
|
|
7497
|
+
let Mn = useRef(st);
|
|
7498
|
+
Mn.current = st;
|
|
7499
|
+
let Nn = useRef(ct);
|
|
7500
|
+
Nn.current = ct;
|
|
7501
|
+
let Q = useRef(_);
|
|
7502
|
+
Q.current = _;
|
|
7503
|
+
let Pn = useRef(E);
|
|
7504
|
+
Pn.current = E, useEffect(() => {
|
|
7501
7505
|
let e = (e) => {
|
|
7502
|
-
if (e.key === "Escape" &&
|
|
7503
|
-
|
|
7506
|
+
if (e.key === "Escape" && J.current) {
|
|
7507
|
+
I.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
|
|
7504
7508
|
return;
|
|
7505
7509
|
}
|
|
7506
|
-
if (e.key === "Escape" &&
|
|
7507
|
-
if (
|
|
7510
|
+
if (e.key === "Escape" && tt === "edit") {
|
|
7511
|
+
if (ot && (B(null), V(null), Y()), st === "rectangle") if (ct) lt(null), Lt();
|
|
7508
7512
|
else {
|
|
7509
|
-
|
|
7510
|
-
let e =
|
|
7513
|
+
V(null);
|
|
7514
|
+
let e = F.current;
|
|
7511
7515
|
e && (e.getCanvas().style.cursor = "");
|
|
7512
7516
|
}
|
|
7513
|
-
if (
|
|
7517
|
+
if (st === "circle") if (dt.current) dt.current = null, Ht();
|
|
7514
7518
|
else {
|
|
7515
|
-
|
|
7516
|
-
let e =
|
|
7519
|
+
V(null);
|
|
7520
|
+
let e = F.current;
|
|
7517
7521
|
e && (e.getCanvas().style.cursor = "");
|
|
7518
7522
|
}
|
|
7519
|
-
if (
|
|
7523
|
+
if (st === "polygon") if (ft.current.length > 0) ft.current = [], Kt();
|
|
7520
7524
|
else {
|
|
7521
|
-
|
|
7522
|
-
let e =
|
|
7525
|
+
V(null);
|
|
7526
|
+
let e = F.current;
|
|
7523
7527
|
e && (e.getCanvas().style.cursor = "");
|
|
7524
7528
|
}
|
|
7525
|
-
if (
|
|
7529
|
+
if (st === "square") if (pt.current) pt.current = null, Zt();
|
|
7526
7530
|
else {
|
|
7527
|
-
|
|
7528
|
-
let e =
|
|
7531
|
+
V(null);
|
|
7532
|
+
let e = F.current;
|
|
7529
7533
|
e && (e.getCanvas().style.cursor = "");
|
|
7530
7534
|
}
|
|
7531
|
-
if (
|
|
7535
|
+
if (st === "polyline") if (mt.current.length > 0) mt.current = [], tn();
|
|
7532
7536
|
else {
|
|
7533
|
-
|
|
7534
|
-
let e =
|
|
7537
|
+
V(null);
|
|
7538
|
+
let e = F.current;
|
|
7535
7539
|
e && (e.getCanvas().style.cursor = "");
|
|
7536
7540
|
}
|
|
7537
7541
|
}
|
|
@@ -7540,62 +7544,62 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7540
7544
|
document.removeEventListener("keydown", e);
|
|
7541
7545
|
};
|
|
7542
7546
|
}, [
|
|
7543
|
-
|
|
7544
|
-
it,
|
|
7545
|
-
at,
|
|
7547
|
+
tt,
|
|
7546
7548
|
ot,
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7549
|
+
st,
|
|
7550
|
+
ct,
|
|
7551
|
+
Y,
|
|
7552
|
+
Lt,
|
|
7553
|
+
Ht,
|
|
7554
|
+
Kt,
|
|
7555
|
+
Zt,
|
|
7556
|
+
tn
|
|
7553
7557
|
]), useEffect(() => {
|
|
7554
|
-
let e =
|
|
7555
|
-
if (!e || !
|
|
7556
|
-
let t =
|
|
7557
|
-
let r =
|
|
7558
|
+
let e = F.current;
|
|
7559
|
+
if (!e || !R) return;
|
|
7560
|
+
let t = R.entityId, n = R.config, r = () => {
|
|
7561
|
+
let r = En.current.find((e) => e.id === t);
|
|
7558
7562
|
if (!r) {
|
|
7559
|
-
|
|
7563
|
+
Et();
|
|
7560
7564
|
return;
|
|
7561
7565
|
}
|
|
7562
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7563
|
-
|
|
7566
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Je.current);
|
|
7567
|
+
Je.current && (Je.current.style.left = `${i.x}px`, Je.current.style.top = `${i.y}px`);
|
|
7564
7568
|
}, i = setTimeout(() => {
|
|
7565
7569
|
r();
|
|
7566
7570
|
}, 50);
|
|
7567
7571
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7568
7572
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7569
7573
|
};
|
|
7570
|
-
}, [
|
|
7571
|
-
let e =
|
|
7572
|
-
if (!e || !
|
|
7573
|
-
let n =
|
|
7574
|
+
}, [R?.entityId, Et]), useEffect(() => {
|
|
7575
|
+
let e = F.current, t = Ue.current;
|
|
7576
|
+
if (!e || !Xe || !t) return;
|
|
7577
|
+
let n = Xe.lngLat, r = () => {
|
|
7574
7578
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7575
7579
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7576
|
-
|
|
7580
|
+
Tn();
|
|
7577
7581
|
return;
|
|
7578
7582
|
}
|
|
7579
7583
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7580
|
-
|
|
7584
|
+
$e.current && ($e.current.style.left = `${s}px`, $e.current.style.top = `${c}px`);
|
|
7581
7585
|
};
|
|
7582
7586
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7583
7587
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7584
7588
|
};
|
|
7585
|
-
}, [
|
|
7586
|
-
if (!
|
|
7589
|
+
}, [Xe?.lngLat, Tn]), useEffect(() => {
|
|
7590
|
+
if (!Ue.current) return;
|
|
7587
7591
|
let e = {
|
|
7588
7592
|
version: 8,
|
|
7589
7593
|
sources: {},
|
|
7590
7594
|
layers: []
|
|
7591
|
-
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: p = !0, boxZoom:
|
|
7592
|
-
container:
|
|
7593
|
-
style:
|
|
7595
|
+
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: p = !0, boxZoom: ve = !0 } = b, g = new mapboxgl.Map({
|
|
7596
|
+
container: Ue.current,
|
|
7597
|
+
style: m || e,
|
|
7594
7598
|
center: l,
|
|
7595
7599
|
zoom: u,
|
|
7596
7600
|
pitch: d,
|
|
7597
7601
|
bearing: f,
|
|
7598
|
-
maxBounds:
|
|
7602
|
+
maxBounds: h,
|
|
7599
7603
|
dragPan: t,
|
|
7600
7604
|
scrollZoom: n,
|
|
7601
7605
|
doubleClickZoom: r,
|
|
@@ -7604,7 +7608,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7604
7608
|
dragRotate: o,
|
|
7605
7609
|
pitchWithRotate: c,
|
|
7606
7610
|
touchPitch: p,
|
|
7607
|
-
boxZoom:
|
|
7611
|
+
boxZoom: ve,
|
|
7608
7612
|
transformRequest: (e, t) => {
|
|
7609
7613
|
if (t === "Glyphs") {
|
|
7610
7614
|
let t = e.match(/\/fonts\/([^/]+)\/(\d+-\d+)\.pbf/);
|
|
@@ -7616,98 +7620,98 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7616
7620
|
return { url: e };
|
|
7617
7621
|
}
|
|
7618
7622
|
});
|
|
7619
|
-
return
|
|
7620
|
-
if (!
|
|
7621
|
-
let e =
|
|
7623
|
+
return F.current = g, g.on("load", () => {
|
|
7624
|
+
if (!g.getStyle().glyphs) {
|
|
7625
|
+
let e = g.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7622
7626
|
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
7623
7627
|
}
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
}),
|
|
7627
|
-
}),
|
|
7628
|
-
|
|
7628
|
+
L.current.clear(), w.forEach((e) => {
|
|
7629
|
+
L.current.set(e.id, e);
|
|
7630
|
+
}), yn(x), dn(), Ft(), Rt(), Wt(), Jt(), $t(), et(g), Le?.(g);
|
|
7631
|
+
}), g.on("click", xn), g.on("mousemove", Sn), g.on("contextmenu", Cn), () => {
|
|
7632
|
+
g.off("click", xn), g.off("mousemove", Sn), g.off("contextmenu", Cn), fn(), jt(), Y(), X(), Z(), g.remove(), F.current = null;
|
|
7629
7633
|
};
|
|
7630
7634
|
}, []), useEffect(() => {
|
|
7631
|
-
if (
|
|
7632
|
-
if (!
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
}),
|
|
7635
|
+
if (F.current) {
|
|
7636
|
+
if (!F.current.isStyleLoaded()) {
|
|
7637
|
+
F.current.once("load", () => {
|
|
7638
|
+
L.current.clear(), w.forEach((e) => {
|
|
7639
|
+
L.current.set(e.id, e);
|
|
7640
|
+
}), dn();
|
|
7637
7641
|
});
|
|
7638
7642
|
return;
|
|
7639
7643
|
}
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
}),
|
|
7644
|
+
L.current.clear(), w.forEach((e) => {
|
|
7645
|
+
L.current.set(e.id, e);
|
|
7646
|
+
}), dn();
|
|
7643
7647
|
}
|
|
7644
|
-
}, [
|
|
7645
|
-
!
|
|
7648
|
+
}, [w, dn]), useEffect(() => {
|
|
7649
|
+
!F.current || !F.current.isStyleLoaded() || (fn(), dn());
|
|
7646
7650
|
}, [
|
|
7651
|
+
D,
|
|
7652
|
+
O,
|
|
7647
7653
|
k,
|
|
7648
7654
|
A,
|
|
7649
7655
|
j,
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
dn,
|
|
7653
|
-
un
|
|
7656
|
+
fn,
|
|
7657
|
+
dn
|
|
7654
7658
|
]), useEffect(() => {
|
|
7655
|
-
if (
|
|
7656
|
-
if (!
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
+
if (F.current) {
|
|
7660
|
+
if (!F.current.isStyleLoaded()) {
|
|
7661
|
+
F.current.once("load", () => {
|
|
7662
|
+
yn(x);
|
|
7659
7663
|
});
|
|
7660
7664
|
return;
|
|
7661
7665
|
}
|
|
7662
|
-
|
|
7663
|
-
}
|
|
7664
|
-
}, [
|
|
7665
|
-
let
|
|
7666
|
-
|
|
7667
|
-
let
|
|
7668
|
-
|
|
7669
|
-
let
|
|
7670
|
-
|
|
7671
|
-
let
|
|
7672
|
-
|
|
7673
|
-
let
|
|
7674
|
-
|
|
7675
|
-
let
|
|
7676
|
-
|
|
7677
|
-
let
|
|
7678
|
-
|
|
7679
|
-
let
|
|
7680
|
-
|
|
7681
|
-
let
|
|
7682
|
-
|
|
7683
|
-
let e =
|
|
7666
|
+
yn(x);
|
|
7667
|
+
}
|
|
7668
|
+
}, [x, yn]);
|
|
7669
|
+
let Fn = useRef(void 0), In = useRef(!0), Ln = useRef(x);
|
|
7670
|
+
Ln.current = x;
|
|
7671
|
+
let Rn = useRef(yn);
|
|
7672
|
+
Rn.current = yn;
|
|
7673
|
+
let zn = useRef(fn);
|
|
7674
|
+
zn.current = fn;
|
|
7675
|
+
let Bn = useRef(dn);
|
|
7676
|
+
Bn.current = dn;
|
|
7677
|
+
let Vn = useRef(Ft);
|
|
7678
|
+
Vn.current = Ft;
|
|
7679
|
+
let Hn = useRef(Rt);
|
|
7680
|
+
Hn.current = Rt;
|
|
7681
|
+
let Un = useRef(Wt);
|
|
7682
|
+
Un.current = Wt;
|
|
7683
|
+
let Wn = useRef(Jt);
|
|
7684
|
+
Wn.current = Jt;
|
|
7685
|
+
let Gn = useRef($t);
|
|
7686
|
+
Gn.current = $t, useEffect(() => {
|
|
7687
|
+
let e = F.current;
|
|
7684
7688
|
if (!e) return;
|
|
7685
|
-
let t =
|
|
7689
|
+
let t = m || {
|
|
7686
7690
|
version: 8,
|
|
7687
7691
|
sources: {},
|
|
7688
7692
|
layers: []
|
|
7689
7693
|
};
|
|
7690
|
-
if (
|
|
7691
|
-
|
|
7694
|
+
if (In.current) {
|
|
7695
|
+
In.current = !1, Fn.current = m;
|
|
7692
7696
|
return;
|
|
7693
7697
|
}
|
|
7694
|
-
|
|
7698
|
+
Fn.current !== m && (Fn.current = m, e.setStyle(t), e.once("style.load", () => {
|
|
7695
7699
|
if (!e.getStyle().glyphs) {
|
|
7696
7700
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7697
7701
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7698
7702
|
}
|
|
7699
|
-
|
|
7703
|
+
Ge.current.clear(), Rn.current(Ln.current), zn.current(), Bn.current(), Vn.current(), Hn.current(), Un.current(), Wn.current(), Gn.current();
|
|
7700
7704
|
}));
|
|
7701
|
-
}, [
|
|
7702
|
-
let e = new Set(
|
|
7703
|
-
for (let [t, n] of
|
|
7704
|
-
}, [
|
|
7705
|
-
let
|
|
7705
|
+
}, [m]), useEffect(() => {
|
|
7706
|
+
let e = new Set(T.map(String));
|
|
7707
|
+
for (let [t, n] of I.current) n.setSelected(e.has(String(t)));
|
|
7708
|
+
}, [T]);
|
|
7709
|
+
let Kn = useRef({});
|
|
7706
7710
|
useEffect(() => {
|
|
7707
|
-
let e =
|
|
7711
|
+
let e = F.current;
|
|
7708
7712
|
if (!e) return;
|
|
7709
|
-
let t =
|
|
7710
|
-
!n && !r && !i && !a || (
|
|
7713
|
+
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
|
+
!n && !r && !i && !a || (Kn.current = {
|
|
7711
7715
|
center: l,
|
|
7712
7716
|
zoom: u,
|
|
7713
7717
|
pitch: d,
|
|
@@ -7724,86 +7728,89 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7724
7728
|
d,
|
|
7725
7729
|
f
|
|
7726
7730
|
]);
|
|
7727
|
-
let
|
|
7728
|
-
if (
|
|
7729
|
-
let e, t;
|
|
7730
|
-
if (
|
|
7731
|
-
let
|
|
7732
|
-
if (
|
|
7733
|
-
let t =
|
|
7731
|
+
let qn = (() => Te === !1 ? null : Te === !0 ? { enabled: !0 } : Te)(), Jn = (() => M === !1 ? null : M === !0 ? { enabled: !0 } : M)(), Yn = (() => Ee === !1 ? null : Ee === !0 ? { enabled: !0 } : Ee)(), $ = (() => {
|
|
7732
|
+
if (De === !1) return null;
|
|
7733
|
+
let e, t, n;
|
|
7734
|
+
if (x && x.length > 0) {
|
|
7735
|
+
let r = x.find((e) => e.hasRoadNetwork === !0) || x[0];
|
|
7736
|
+
if (r.type === "style") {
|
|
7737
|
+
let t = F.current?.getStyle();
|
|
7734
7738
|
if (t?.sources) {
|
|
7735
|
-
let
|
|
7739
|
+
let n = `base-layer-source-${r.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(n));
|
|
7736
7740
|
i && (e = i);
|
|
7737
7741
|
}
|
|
7738
|
-
} else e = `base-layer-source-${
|
|
7739
|
-
t =
|
|
7742
|
+
} else e = `base-layer-source-${r.id}`;
|
|
7743
|
+
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7740
7744
|
}
|
|
7741
|
-
return
|
|
7745
|
+
return De === !0 ? {
|
|
7742
7746
|
enabled: !0,
|
|
7743
7747
|
source: e,
|
|
7744
|
-
sourceLayer: t
|
|
7748
|
+
sourceLayer: t,
|
|
7749
|
+
classField: n
|
|
7745
7750
|
} : {
|
|
7746
|
-
...
|
|
7747
|
-
source:
|
|
7748
|
-
sourceLayer:
|
|
7751
|
+
...De,
|
|
7752
|
+
source: De.source || e,
|
|
7753
|
+
sourceLayer: De.sourceLayer || t,
|
|
7754
|
+
classField: De.classField || n
|
|
7749
7755
|
};
|
|
7750
|
-
})(), Xn = (() =>
|
|
7756
|
+
})(), Xn = (() => Oe ? Oe === !0 ? { enabled: !0 } : Oe : null)(), Zn = (() => Me ? Me === !0 ? { enabled: !0 } : Me : null)(), Qn = (() => Ne || null)(), $n = useMemo(() => {
|
|
7751
7757
|
let e = [];
|
|
7752
|
-
for (let t of
|
|
7753
|
-
let n =
|
|
7758
|
+
for (let t of x) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7759
|
+
let n = F.current;
|
|
7754
7760
|
if (n) {
|
|
7755
7761
|
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
7756
7762
|
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
7757
7763
|
}
|
|
7758
7764
|
} else e.push(`base-layer-${t.id}`);
|
|
7759
7765
|
return e;
|
|
7760
|
-
}, [
|
|
7766
|
+
}, [x, z]);
|
|
7761
7767
|
return /* @__PURE__ */ jsxs("div", {
|
|
7762
|
-
className: `comp-mapbox ${
|
|
7763
|
-
style:
|
|
7768
|
+
className: `comp-mapbox ${tt === "picker" ? "comp-mapbox--picker-mode" : ""} ${Ve}`,
|
|
7769
|
+
style: He,
|
|
7764
7770
|
children: [
|
|
7765
7771
|
/* @__PURE__ */ jsx("div", {
|
|
7766
|
-
ref:
|
|
7772
|
+
ref: Ue,
|
|
7767
7773
|
className: "comp-mapbox__map"
|
|
7768
7774
|
}),
|
|
7769
|
-
|
|
7775
|
+
tt === "picker" && v.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
7770
7776
|
className: "comp-mapbox__crosshair",
|
|
7771
7777
|
children: [/* @__PURE__ */ jsx("div", {
|
|
7772
7778
|
className: "comp-mapbox__crosshair-h",
|
|
7773
|
-
style:
|
|
7779
|
+
style: v.crosshairColor ? { backgroundColor: v.crosshairColor } : void 0
|
|
7774
7780
|
}), /* @__PURE__ */ jsx("div", {
|
|
7775
7781
|
className: "comp-mapbox__crosshair-v",
|
|
7776
|
-
style:
|
|
7782
|
+
style: v.crosshairColor ? { backgroundColor: v.crosshairColor } : void 0
|
|
7777
7783
|
})]
|
|
7778
7784
|
}),
|
|
7779
|
-
|
|
7785
|
+
tt === "edit" && _.showEditTools !== !1 && (_.markerTemplates && _.markerTemplates.length > 0 || _.showRectangleTool || _.showCircleTool || _.showPolygonTool || _.showSquareTool || _.showPolylineTool) || $ && $.enabled !== !1 || Qn && Qn.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
|
|
7780
7786
|
className: "comp-mapbox__edit-controls",
|
|
7781
7787
|
children: [
|
|
7782
|
-
|
|
7783
|
-
markerTemplates:
|
|
7784
|
-
selectedTemplate:
|
|
7785
|
-
onTemplateSelect:
|
|
7786
|
-
drawMode:
|
|
7787
|
-
onDrawModeChange:
|
|
7788
|
-
showRectangleTool:
|
|
7789
|
-
showCircleTool:
|
|
7790
|
-
showPolygonTool:
|
|
7791
|
-
showSquareTool:
|
|
7792
|
-
showPolylineTool:
|
|
7788
|
+
tt === "edit" && _.showEditTools !== !1 && (_.markerTemplates && _.markerTemplates.length > 0 || _.showRectangleTool || _.showCircleTool || _.showPolygonTool || _.showSquareTool || _.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7789
|
+
markerTemplates: _.markerTemplates || [],
|
|
7790
|
+
selectedTemplate: ot,
|
|
7791
|
+
onTemplateSelect: nn,
|
|
7792
|
+
drawMode: st,
|
|
7793
|
+
onDrawModeChange: rn,
|
|
7794
|
+
showRectangleTool: _.showRectangleTool,
|
|
7795
|
+
showCircleTool: _.showCircleTool,
|
|
7796
|
+
showPolygonTool: _.showPolygonTool,
|
|
7797
|
+
showSquareTool: _.showSquareTool,
|
|
7798
|
+
showPolylineTool: _.showPolylineTool
|
|
7793
7799
|
}),
|
|
7794
|
-
|
|
7795
|
-
map:
|
|
7796
|
-
highlightWidth:
|
|
7797
|
-
defaultRoadTypes:
|
|
7798
|
-
defaultMinWidth:
|
|
7799
|
-
source:
|
|
7800
|
-
sourceLayer:
|
|
7801
|
-
|
|
7802
|
-
|
|
7800
|
+
$ && $.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7801
|
+
map: z,
|
|
7802
|
+
highlightWidth: $.highlightWidth,
|
|
7803
|
+
defaultRoadTypes: $.defaultRoadTypes,
|
|
7804
|
+
defaultMinWidth: $.defaultMinWidth,
|
|
7805
|
+
source: $.source,
|
|
7806
|
+
sourceLayer: $.sourceLayer,
|
|
7807
|
+
classField: $.classField,
|
|
7808
|
+
className: $.className,
|
|
7809
|
+
style: $.style
|
|
7803
7810
|
}),
|
|
7804
7811
|
Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7805
|
-
ref:
|
|
7806
|
-
map:
|
|
7812
|
+
ref: We,
|
|
7813
|
+
map: z,
|
|
7807
7814
|
pointCount: Qn.pointCount,
|
|
7808
7815
|
showPointCountInput: Qn.showPointCountInput,
|
|
7809
7816
|
visualType: Qn.visualType,
|
|
@@ -7811,67 +7818,67 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7811
7818
|
})
|
|
7812
7819
|
]
|
|
7813
7820
|
}) : null,
|
|
7814
|
-
(
|
|
7821
|
+
(qn?.enabled !== !1 || Jn?.enabled !== !1 || Yn?.enabled !== !1 || Xn && Xn.enabled !== !1 || Zn && Zn.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7815
7822
|
className: "comp-mapbox__controls",
|
|
7816
7823
|
children: [
|
|
7817
|
-
|
|
7818
|
-
map:
|
|
7819
|
-
precision:
|
|
7820
|
-
className: Kn.className,
|
|
7821
|
-
style: Kn.style
|
|
7822
|
-
}),
|
|
7823
|
-
qn && qn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7824
|
-
map: V,
|
|
7825
|
-
maxWidth: qn.maxWidth,
|
|
7826
|
-
unit: qn.unit,
|
|
7824
|
+
qn && qn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7825
|
+
map: z,
|
|
7826
|
+
precision: qn.precision,
|
|
7827
7827
|
className: qn.className,
|
|
7828
7828
|
style: qn.style
|
|
7829
7829
|
}),
|
|
7830
|
+
Jn && Jn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7831
|
+
map: z,
|
|
7832
|
+
maxWidth: Jn.maxWidth,
|
|
7833
|
+
unit: Jn.unit,
|
|
7834
|
+
className: Jn.className,
|
|
7835
|
+
style: Jn.style
|
|
7836
|
+
}),
|
|
7830
7837
|
Xn && Xn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7831
|
-
map:
|
|
7832
|
-
entityConfig:
|
|
7838
|
+
map: z,
|
|
7839
|
+
entityConfig: E,
|
|
7833
7840
|
onDrawModeChange: (e) => {
|
|
7834
|
-
|
|
7841
|
+
gt.current = e;
|
|
7835
7842
|
},
|
|
7836
7843
|
className: Xn.className,
|
|
7837
7844
|
style: Xn.style
|
|
7838
7845
|
}),
|
|
7839
7846
|
Zn && Zn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7840
|
-
map:
|
|
7841
|
-
value:
|
|
7842
|
-
onChange:
|
|
7847
|
+
map: z,
|
|
7848
|
+
value: C,
|
|
7849
|
+
onChange: Pe,
|
|
7843
7850
|
rasterPaintLayerIds: $n,
|
|
7844
7851
|
className: Zn.className,
|
|
7845
7852
|
style: Zn.style
|
|
7846
7853
|
}),
|
|
7847
|
-
|
|
7848
|
-
map:
|
|
7854
|
+
Yn && Yn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7855
|
+
map: z,
|
|
7849
7856
|
initialCenter: l,
|
|
7850
7857
|
initialZoom: u,
|
|
7851
7858
|
initialPitch: d,
|
|
7852
7859
|
initialBearing: f,
|
|
7853
|
-
duration:
|
|
7854
|
-
className:
|
|
7855
|
-
style:
|
|
7860
|
+
duration: Yn.duration,
|
|
7861
|
+
className: Yn.className,
|
|
7862
|
+
style: Yn.style
|
|
7856
7863
|
})
|
|
7857
7864
|
]
|
|
7858
7865
|
}),
|
|
7859
7866
|
!(Qn && Qn.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7860
|
-
ref:
|
|
7861
|
-
map:
|
|
7867
|
+
ref: We,
|
|
7868
|
+
map: z,
|
|
7862
7869
|
showButton: !1
|
|
7863
7870
|
}),
|
|
7864
|
-
|
|
7865
|
-
popupState:
|
|
7866
|
-
onClose: () =>
|
|
7867
|
-
portalContainer:
|
|
7868
|
-
popupRef:
|
|
7871
|
+
R && qe.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7872
|
+
popupState: R,
|
|
7873
|
+
onClose: () => Tt(R.entityId),
|
|
7874
|
+
portalContainer: qe.current,
|
|
7875
|
+
popupRef: Je
|
|
7869
7876
|
}),
|
|
7870
|
-
|
|
7871
|
-
menuState:
|
|
7872
|
-
onClose:
|
|
7873
|
-
portalContainer:
|
|
7874
|
-
menuRef:
|
|
7877
|
+
Xe && Qe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7878
|
+
menuState: Xe,
|
|
7879
|
+
onClose: Tn,
|
|
7880
|
+
portalContainer: Qe.current,
|
|
7881
|
+
menuRef: $e
|
|
7875
7882
|
})
|
|
7876
7883
|
]
|
|
7877
7884
|
});
|