bbl-mapbox-react 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -4
- package/dist/index.css +1 -1
- package/dist/index.mjs +775 -718
- package/dist/types.d.ts +30 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4015,7 +4015,9 @@ function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style:
|
|
|
4015
4015
|
}, [r]);
|
|
4016
4016
|
useEffect(() => {
|
|
4017
4017
|
if (e) return e.on("mousemove", g), () => {
|
|
4018
|
-
e
|
|
4018
|
+
if (e) try {
|
|
4019
|
+
e.off("mousemove", g);
|
|
4020
|
+
} catch {}
|
|
4019
4021
|
};
|
|
4020
4022
|
}, [e, g]), useEffect(() => () => {
|
|
4021
4023
|
f.current && clearTimeout(f.current);
|
|
@@ -4107,7 +4109,9 @@ function ScaleControl({ map: e, maxWidth: r = 100, unit: i = "metric", className
|
|
|
4107
4109
|
]);
|
|
4108
4110
|
return useEffect(() => {
|
|
4109
4111
|
if (e) return u(), e.on("move", u), e.on("zoom", u), () => {
|
|
4110
|
-
e
|
|
4112
|
+
if (e) try {
|
|
4113
|
+
e.off("move", u), e.off("zoom", u);
|
|
4114
|
+
} catch {}
|
|
4111
4115
|
};
|
|
4112
4116
|
}, [e, u]), /* @__PURE__ */ jsxs("div", {
|
|
4113
4117
|
className: `mapbox-scale-control ${a}`,
|
|
@@ -4183,7 +4187,7 @@ function detectVectorSource(e) {
|
|
|
4183
4187
|
return null;
|
|
4184
4188
|
}
|
|
4185
4189
|
const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaultRoadTypes: c = [], defaultMinWidth: l = 0, source: u, sourceLayer: d, classField: _ = "class", className: v = "", style: y, showButton: b = !0 }, x) => {
|
|
4186
|
-
let [S, C] = useState(!1), [w, ve] = useState(c), [T, E] = useState(!1), [D, ye] = useState(null), be = useRef(!1), k = useRef(null),
|
|
4190
|
+
let [S, C] = useState(!1), [w, ve] = useState(c), [T, E] = useState(!1), [D, ye] = useState(null), be = useRef(!1), k = useRef(null), xe = useRef(null), A = useRef(null), Se = useCallback((e, t, n) => {
|
|
4187
4191
|
if (!e.isStyleLoaded() || !e.getSource(t)) return !1;
|
|
4188
4192
|
let r = !0;
|
|
4189
4193
|
return ROAD_TYPE_OPTIONS.forEach((a) => {
|
|
@@ -4219,7 +4223,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4219
4223
|
let r = detectVectorSource(e);
|
|
4220
4224
|
r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
|
|
4221
4225
|
}
|
|
4222
|
-
t && n ?
|
|
4226
|
+
t && n ? Se(e, t, n) && (be.current = !0, E(!0)) : console.warn("No vector source found for road highlighting");
|
|
4223
4227
|
};
|
|
4224
4228
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4225
4229
|
let n = () => {
|
|
@@ -4228,13 +4232,15 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4228
4232
|
be.current || t();
|
|
4229
4233
|
};
|
|
4230
4234
|
return e.on("styledata", n), e.on("sourcedata", r), () => {
|
|
4231
|
-
e
|
|
4235
|
+
if (e) try {
|
|
4236
|
+
e.off("styledata", n), e.off("sourcedata", r);
|
|
4237
|
+
} catch {}
|
|
4232
4238
|
};
|
|
4233
4239
|
}, [
|
|
4234
4240
|
e,
|
|
4235
4241
|
u,
|
|
4236
4242
|
d,
|
|
4237
|
-
|
|
4243
|
+
Se
|
|
4238
4244
|
]), useEffect(() => {
|
|
4239
4245
|
!e || !T || ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
4240
4246
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
@@ -4252,7 +4258,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4252
4258
|
]), useEffect(() => {
|
|
4253
4259
|
if (!S) return;
|
|
4254
4260
|
let e = (e) => {
|
|
4255
|
-
k.current && !k.current.contains(e.target) &&
|
|
4261
|
+
k.current && !k.current.contains(e.target) && xe.current && !xe.current.contains(e.target) && C(!1);
|
|
4256
4262
|
}, t = setTimeout(() => {
|
|
4257
4263
|
document.addEventListener("mousedown", e);
|
|
4258
4264
|
}, 0);
|
|
@@ -4265,11 +4271,11 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4265
4271
|
if (e.getLayer(n)) try {
|
|
4266
4272
|
e.removeLayer(n);
|
|
4267
4273
|
} catch {}
|
|
4268
|
-
}),
|
|
4274
|
+
}), A.current &&= (A.current.remove(), null);
|
|
4269
4275
|
}, [e]);
|
|
4270
|
-
let
|
|
4276
|
+
let j = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), M = useCallback((t) => {
|
|
4271
4277
|
if (!e || w.length === 0) {
|
|
4272
|
-
|
|
4278
|
+
A.current && A.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
|
|
4273
4279
|
return;
|
|
4274
4280
|
}
|
|
4275
4281
|
let n = w.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)) });
|
|
@@ -4278,7 +4284,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4278
4284
|
m(o) && h.push(`
|
|
4279
4285
|
<div class="road-highlight-popup__row">
|
|
4280
4286
|
<span>道路类型:</span>
|
|
4281
|
-
<span class="road-highlight-popup__value">${
|
|
4287
|
+
<span class="road-highlight-popup__value">${j(o)}</span>
|
|
4282
4288
|
</div>
|
|
4283
4289
|
`), h.push(`
|
|
4284
4290
|
<div class="road-highlight-popup__row">
|
|
@@ -4327,33 +4333,35 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4327
4333
|
<div class="road-highlight-popup__info">${h.join("")}</div>
|
|
4328
4334
|
</div>
|
|
4329
4335
|
`;
|
|
4330
|
-
|
|
4336
|
+
A.current ||= new mapboxgl.Popup({
|
|
4331
4337
|
closeButton: !1,
|
|
4332
4338
|
closeOnClick: !1,
|
|
4333
4339
|
offset: 15,
|
|
4334
4340
|
className: "road-highlight-popup"
|
|
4335
|
-
}),
|
|
4336
|
-
} else
|
|
4341
|
+
}), A.current.setLngLat(r).setHTML(g).addTo(e), e.getCanvas().style.cursor = "pointer";
|
|
4342
|
+
} else A.current && A.current.remove(), e.getCanvas().style.cursor = "";
|
|
4337
4343
|
}, [
|
|
4338
4344
|
e,
|
|
4339
4345
|
w,
|
|
4340
|
-
|
|
4346
|
+
j,
|
|
4341
4347
|
_
|
|
4342
4348
|
]);
|
|
4343
4349
|
useEffect(() => {
|
|
4344
|
-
if (!(!e || !T)) return e.on("mousemove",
|
|
4345
|
-
|
|
4350
|
+
if (!(!e || !T)) return e.on("mousemove", M), () => {
|
|
4351
|
+
if (e) try {
|
|
4352
|
+
e.off("mousemove", M), A.current && A.current.remove(), e.getCanvas().style.cursor = "";
|
|
4353
|
+
} catch {}
|
|
4346
4354
|
};
|
|
4347
4355
|
}, [
|
|
4348
4356
|
e,
|
|
4349
4357
|
T,
|
|
4350
|
-
|
|
4358
|
+
M
|
|
4351
4359
|
]);
|
|
4352
|
-
let
|
|
4360
|
+
let N = (e, t) => {
|
|
4353
4361
|
ve((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
4354
|
-
},
|
|
4362
|
+
}, Ce = (e) => {
|
|
4355
4363
|
ve(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
|
|
4356
|
-
},
|
|
4364
|
+
}, P = w.length > 0, we = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4357
4365
|
/* @__PURE__ */ jsxs("div", {
|
|
4358
4366
|
className: "mapbox-road-highlight-control__panel-header",
|
|
4359
4367
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -4362,7 +4370,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4362
4370
|
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
4363
4371
|
checked: w.length === ROAD_TYPE_OPTIONS.length,
|
|
4364
4372
|
indeterminate: w.length > 0 && w.length < ROAD_TYPE_OPTIONS.length,
|
|
4365
|
-
onChange:
|
|
4373
|
+
onChange: Ce,
|
|
4366
4374
|
style: {
|
|
4367
4375
|
"--color-text-1": "#fff",
|
|
4368
4376
|
"--color-border-2": "rgba(255, 255, 255, 0.3)"
|
|
@@ -4379,11 +4387,11 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4379
4387
|
className: "mapbox-road-highlight-control__type-list",
|
|
4380
4388
|
children: ROAD_TYPE_OPTIONS.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
4381
4389
|
className: "mapbox-road-highlight-control__type-item",
|
|
4382
|
-
onClick: () =>
|
|
4390
|
+
onClick: () => N(e.class, !w.includes(e.class)),
|
|
4383
4391
|
children: [
|
|
4384
4392
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4385
4393
|
checked: w.includes(e.class),
|
|
4386
|
-
onChange: (t) =>
|
|
4394
|
+
onChange: (t) => N(e.class, t),
|
|
4387
4395
|
onClick: (e) => e.stopPropagation(),
|
|
4388
4396
|
style: {
|
|
4389
4397
|
"--color-text-1": "#fff",
|
|
@@ -4417,8 +4425,8 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4417
4425
|
className: `mapbox-road-highlight-control ${v}`,
|
|
4418
4426
|
style: y,
|
|
4419
4427
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
4420
|
-
ref:
|
|
4421
|
-
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${
|
|
4428
|
+
ref: xe,
|
|
4429
|
+
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${P ? "mapbox-road-highlight-control__btn--active" : ""}`,
|
|
4422
4430
|
onClick: () => C(!S),
|
|
4423
4431
|
title: `路网高亮${w.length > 0 ? ` (已选 ${w.length})` : ""}`,
|
|
4424
4432
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -4429,9 +4437,9 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4429
4437
|
}), S && /* @__PURE__ */ jsx("div", {
|
|
4430
4438
|
ref: k,
|
|
4431
4439
|
className: "mapbox-road-highlight-control__panel",
|
|
4432
|
-
children:
|
|
4440
|
+
children: we()
|
|
4433
4441
|
})]
|
|
4434
|
-
}), D && createPortal(
|
|
4442
|
+
}), D && createPortal(we(), D)] });
|
|
4435
4443
|
});
|
|
4436
4444
|
RoadHighlightControl.displayName = "RoadHighlightControl";
|
|
4437
4445
|
var measure_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='1773733446763'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1802'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M110.34624%20352.01024a30.72%2030.72%200%201%200%2061.44%200v-38.46144h680.42752v38.5024a30.72%2030.72%200%200%200%2061.44%200V213.72928a30.72%2030.72%200%200%200-61.44%200v38.33856H171.78624v-38.33856a30.72%2030.72%200%200%200-61.44%200v138.28096z%20m34.816%20127.22176a34.816%2034.816%200%200%200-34.816%2034.816v312.60672c0%2019.2512%2015.5648%2034.816%2034.816%2034.816h733.5936c19.2512%200%2034.816-15.5648%2034.816-34.816V514.048a34.816%2034.816%200%200%200-34.816-34.816H145.2032z%20m26.624%20320.79872V540.672h680.3456v259.35872H171.8272z'%20fill='white'%20p-id='1804'%3e%3c/path%3e%3c/svg%3e", square_default = "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", rectangle_default = "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", circle_default = "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", polygon_default = "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", polyline_default = "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", delete_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='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", SHAPE_LABELS = {
|
|
@@ -4683,28 +4691,30 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4683
4691
|
showArea: r.showArea ?? !0,
|
|
4684
4692
|
showLength: r.showLength ?? !0,
|
|
4685
4693
|
showRadius: r.showRadius ?? !0
|
|
4686
|
-
} : _, [x, S] = useState([]), C = useRef(/* @__PURE__ */ new Map()), w = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null),
|
|
4687
|
-
|
|
4688
|
-
let
|
|
4689
|
-
|
|
4690
|
-
let
|
|
4694
|
+
} : _, [x, S] = useState([]), C = useRef(/* @__PURE__ */ new Map()), w = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), j = useRef([]), M = useRef([]), N = useRef(b);
|
|
4695
|
+
N.current = b;
|
|
4696
|
+
let Ce = useRef(f);
|
|
4697
|
+
Ce.current = f;
|
|
4698
|
+
let P = useCallback(() => `measure-${++w.current}`, []);
|
|
4691
4699
|
useEffect(() => {
|
|
4692
4700
|
s?.(f !== null);
|
|
4693
4701
|
}, [f, s]);
|
|
4694
|
-
let
|
|
4695
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
4702
|
+
let we = useRef(!1), Te = useCallback(() => {
|
|
4703
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), we.current = !0);
|
|
4696
4704
|
}, [e]);
|
|
4697
4705
|
useEffect(() => {
|
|
4698
4706
|
if (!e) return;
|
|
4699
4707
|
let t = () => {
|
|
4700
|
-
initAllPreviewLayers(e),
|
|
4708
|
+
initAllPreviewLayers(e), we.current = !0;
|
|
4701
4709
|
};
|
|
4702
4710
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4703
4711
|
let n = () => {
|
|
4704
|
-
|
|
4712
|
+
we.current = !1;
|
|
4705
4713
|
};
|
|
4706
4714
|
return e.on("style.load", n), () => {
|
|
4707
|
-
e
|
|
4715
|
+
if (e) try {
|
|
4716
|
+
e.off("style.load", n);
|
|
4717
|
+
} catch {}
|
|
4708
4718
|
};
|
|
4709
4719
|
}, [e]), useEffect(() => {
|
|
4710
4720
|
let e = (e) => {
|
|
@@ -4712,9 +4722,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4712
4722
|
};
|
|
4713
4723
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4714
4724
|
}, []);
|
|
4715
|
-
let
|
|
4725
|
+
let F = useCallback((t) => {
|
|
4716
4726
|
if (!e) return;
|
|
4717
|
-
let n = applyEntityConfig(t,
|
|
4727
|
+
let n = applyEntityConfig(t, N.current), r = null;
|
|
4718
4728
|
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) {
|
|
4719
4729
|
C.current.set(n.id, r);
|
|
4720
4730
|
let e = {
|
|
@@ -4725,12 +4735,12 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4725
4735
|
};
|
|
4726
4736
|
S((t) => [...t, e]);
|
|
4727
4737
|
}
|
|
4728
|
-
}, [e]),
|
|
4738
|
+
}, [e]), Ee = useCallback((e) => {
|
|
4729
4739
|
let t = C.current.get(e);
|
|
4730
4740
|
t && (t.destroy(), C.current.delete(e)), S((t) => t.filter((t) => t.entity.id !== e));
|
|
4731
|
-
}, []),
|
|
4741
|
+
}, []), De = useCallback(() => {
|
|
4732
4742
|
C.current.forEach((e) => e.destroy()), C.current.clear(), S([]);
|
|
4733
|
-
}, []),
|
|
4743
|
+
}, []), Oe = useCallback((t) => {
|
|
4734
4744
|
if (!e) return;
|
|
4735
4745
|
let n = C.current.get(t);
|
|
4736
4746
|
if (!n) return;
|
|
@@ -4740,9 +4750,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4740
4750
|
maxZoom: 18,
|
|
4741
4751
|
duration: 1e3
|
|
4742
4752
|
});
|
|
4743
|
-
}, [e]),
|
|
4753
|
+
}, [e]), ke = useCallback((e, t) => {
|
|
4744
4754
|
let n = {
|
|
4745
|
-
...
|
|
4755
|
+
...N.current,
|
|
4746
4756
|
[e]: t
|
|
4747
4757
|
};
|
|
4748
4758
|
y ? i?.({ ...n }) : v(n), S((t) => t.map((t) => {
|
|
@@ -4754,7 +4764,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4754
4764
|
entity: i
|
|
4755
4765
|
};
|
|
4756
4766
|
}));
|
|
4757
|
-
}, [y, i]),
|
|
4767
|
+
}, [y, i]), Ae = useCallback((t, n) => {
|
|
4758
4768
|
if (!e) return;
|
|
4759
4769
|
let [r, i] = t, [a, o] = n, s = [
|
|
4760
4770
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -4773,7 +4783,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4773
4783
|
});
|
|
4774
4784
|
let l = e.getSource(`${PREVIEW_PREFIX}rect-preview-measure-source`);
|
|
4775
4785
|
if (l) {
|
|
4776
|
-
let e =
|
|
4786
|
+
let e = N.current, t = [], n = s[0], r = s[1], i = s[2];
|
|
4777
4787
|
if (e?.showArea) {
|
|
4778
4788
|
let e = distance(n, r), a = distance(r, i);
|
|
4779
4789
|
t.push({
|
|
@@ -4804,7 +4814,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4804
4814
|
features: t
|
|
4805
4815
|
});
|
|
4806
4816
|
}
|
|
4807
|
-
}, [e]),
|
|
4817
|
+
}, [e]), je = useCallback((t, n) => {
|
|
4808
4818
|
if (!e) return;
|
|
4809
4819
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
4810
4820
|
a && a.setData({
|
|
@@ -4815,7 +4825,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4815
4825
|
},
|
|
4816
4826
|
properties: {}
|
|
4817
4827
|
});
|
|
4818
|
-
let o =
|
|
4828
|
+
let o = N.current, s = [], c = [];
|
|
4819
4829
|
if (o?.showArea && s.push({
|
|
4820
4830
|
type: "Feature",
|
|
4821
4831
|
geometry: {
|
|
@@ -4851,7 +4861,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4851
4861
|
type: "FeatureCollection",
|
|
4852
4862
|
features: c
|
|
4853
4863
|
});
|
|
4854
|
-
}, [e]),
|
|
4864
|
+
}, [e]), Me = useCallback((t, n) => {
|
|
4855
4865
|
if (!e) return;
|
|
4856
4866
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
4857
4867
|
a && a.setData({
|
|
@@ -4864,7 +4874,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4864
4874
|
});
|
|
4865
4875
|
let o = e.getSource(`${PREVIEW_PREFIX}square-preview-measure-source`);
|
|
4866
4876
|
if (o) {
|
|
4867
|
-
let e =
|
|
4877
|
+
let e = N.current, n = [];
|
|
4868
4878
|
if (e?.showArea && n.push({
|
|
4869
4879
|
type: "Feature",
|
|
4870
4880
|
geometry: {
|
|
@@ -4888,7 +4898,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4888
4898
|
features: n
|
|
4889
4899
|
});
|
|
4890
4900
|
}
|
|
4891
|
-
}, [e]),
|
|
4901
|
+
}, [e]), I = useCallback((t, n) => {
|
|
4892
4902
|
if (!e) return;
|
|
4893
4903
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
4894
4904
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -4923,7 +4933,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4923
4933
|
});
|
|
4924
4934
|
let o = e.getSource(`${PREVIEW_PREFIX}polygon-preview-measure-source`);
|
|
4925
4935
|
if (o) {
|
|
4926
|
-
let e =
|
|
4936
|
+
let e = N.current, t = [];
|
|
4927
4937
|
if (e?.showArea && r.length >= 3) {
|
|
4928
4938
|
let e = polygonArea([...r, r[0]]), n = 0, i = 0;
|
|
4929
4939
|
for (let e of r) n += e[0], i += e[1];
|
|
@@ -4965,7 +4975,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4965
4975
|
features: t
|
|
4966
4976
|
});
|
|
4967
4977
|
}
|
|
4968
|
-
}, [e]),
|
|
4978
|
+
}, [e]), Ne = useCallback((t, n) => {
|
|
4969
4979
|
if (!e) return;
|
|
4970
4980
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
4971
4981
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -4993,7 +5003,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4993
5003
|
});
|
|
4994
5004
|
let o = e.getSource(`${PREVIEW_PREFIX}polyline-preview-measure-source`);
|
|
4995
5005
|
if (o) {
|
|
4996
|
-
let e =
|
|
5006
|
+
let e = N.current, t = [];
|
|
4997
5007
|
if (e?.showLength && r.length >= 2) for (let e = 0; e < r.length - 1; e++) {
|
|
4998
5008
|
let n = r[e], i = r[e + 1];
|
|
4999
5009
|
t.push({
|
|
@@ -5013,139 +5023,141 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5013
5023
|
}, [e]);
|
|
5014
5024
|
useEffect(() => {
|
|
5015
5025
|
if (!e || !f) return;
|
|
5016
|
-
|
|
5026
|
+
Te(), e.getCanvas().style.cursor = "crosshair";
|
|
5017
5027
|
let t = (t) => {
|
|
5018
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
5028
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = Ce.current;
|
|
5019
5029
|
if (r === "rectangle") {
|
|
5020
5030
|
let t = D.current;
|
|
5021
5031
|
if (!t) D.current = n;
|
|
5022
5032
|
else {
|
|
5023
5033
|
let r = {
|
|
5024
|
-
id:
|
|
5034
|
+
id: P(),
|
|
5025
5035
|
type: "rectangle",
|
|
5026
5036
|
bounds: [t, n]
|
|
5027
5037
|
};
|
|
5028
|
-
|
|
5038
|
+
F(r), D.current = null, clearAllPreviewSources(e), p(null);
|
|
5029
5039
|
}
|
|
5030
5040
|
} else if (r === "circle") {
|
|
5031
5041
|
let t = O.current;
|
|
5032
5042
|
if (!t) O.current = { center: n };
|
|
5033
5043
|
else {
|
|
5034
5044
|
let r = calculateDistance(t.center, n), i = {
|
|
5035
|
-
id:
|
|
5045
|
+
id: P(),
|
|
5036
5046
|
type: "circle",
|
|
5037
5047
|
center: t.center,
|
|
5038
5048
|
radius: r
|
|
5039
5049
|
};
|
|
5040
|
-
|
|
5050
|
+
F(i), O.current = null, clearAllPreviewSources(e), p(null);
|
|
5041
5051
|
}
|
|
5042
5052
|
} else if (r === "square") {
|
|
5043
5053
|
let t = k.current;
|
|
5044
5054
|
if (!t) k.current = { center: n };
|
|
5045
5055
|
else {
|
|
5046
5056
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
5047
|
-
id:
|
|
5057
|
+
id: P(),
|
|
5048
5058
|
type: "square",
|
|
5049
5059
|
center: t.center,
|
|
5050
5060
|
length: r
|
|
5051
5061
|
};
|
|
5052
|
-
|
|
5062
|
+
F(i), k.current = null, clearAllPreviewSources(e), p(null);
|
|
5053
5063
|
}
|
|
5054
5064
|
} else if (r === "polygon") {
|
|
5055
|
-
let t =
|
|
5065
|
+
let t = j.current;
|
|
5056
5066
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
5057
5067
|
let n = {
|
|
5058
|
-
id:
|
|
5068
|
+
id: P(),
|
|
5059
5069
|
type: "polygon",
|
|
5060
5070
|
coordinates: [...t]
|
|
5061
5071
|
};
|
|
5062
|
-
|
|
5072
|
+
F(n), j.current = [], clearAllPreviewSources(e), p(null);
|
|
5063
5073
|
return;
|
|
5064
5074
|
}
|
|
5065
|
-
|
|
5066
|
-
} else r === "polyline" && (
|
|
5075
|
+
j.current = [...t, n];
|
|
5076
|
+
} else r === "polyline" && (M.current = [...M.current, n]);
|
|
5067
5077
|
}, n = (e) => {
|
|
5068
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5069
|
-
if (n === "rectangle" && D.current)
|
|
5070
|
-
else if (n === "circle" && O.current)
|
|
5071
|
-
else if (n === "square" && k.current)
|
|
5078
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = Ce.current;
|
|
5079
|
+
if (n === "rectangle" && D.current) Ae(D.current, t);
|
|
5080
|
+
else if (n === "circle" && O.current) je(O.current.center, t);
|
|
5081
|
+
else if (n === "square" && k.current) Me(k.current.center, t);
|
|
5072
5082
|
else if (n === "polygon") {
|
|
5073
|
-
let e =
|
|
5074
|
-
e.length > 0 &&
|
|
5083
|
+
let e = j.current;
|
|
5084
|
+
e.length > 0 && I(e, t);
|
|
5075
5085
|
} else if (n === "polyline") {
|
|
5076
|
-
let e =
|
|
5077
|
-
e.length > 0 &&
|
|
5086
|
+
let e = M.current;
|
|
5087
|
+
e.length > 0 && Ne(e, t);
|
|
5078
5088
|
}
|
|
5079
5089
|
}, r = (t) => {
|
|
5080
5090
|
t.preventDefault();
|
|
5081
|
-
let n =
|
|
5091
|
+
let n = Ce.current;
|
|
5082
5092
|
if (n === "polygon") {
|
|
5083
|
-
let t =
|
|
5093
|
+
let t = j.current;
|
|
5084
5094
|
if (t.length >= 3) {
|
|
5085
5095
|
let n = {
|
|
5086
|
-
id:
|
|
5096
|
+
id: P(),
|
|
5087
5097
|
type: "polygon",
|
|
5088
5098
|
coordinates: [...t]
|
|
5089
5099
|
};
|
|
5090
|
-
|
|
5091
|
-
} else
|
|
5100
|
+
F(n), j.current = [], clearAllPreviewSources(e), p(null);
|
|
5101
|
+
} else j.current = [], clearAllPreviewSources(e);
|
|
5092
5102
|
} else if (n === "polyline") {
|
|
5093
|
-
let t =
|
|
5103
|
+
let t = M.current;
|
|
5094
5104
|
if (t.length >= 2) {
|
|
5095
5105
|
let n = {
|
|
5096
|
-
id:
|
|
5106
|
+
id: P(),
|
|
5097
5107
|
type: "polyline",
|
|
5098
5108
|
coordinates: [...t]
|
|
5099
5109
|
};
|
|
5100
|
-
|
|
5101
|
-
} else
|
|
5110
|
+
F(n), M.current = [], clearAllPreviewSources(e), p(null);
|
|
5111
|
+
} else M.current = [], clearAllPreviewSources(e);
|
|
5102
5112
|
}
|
|
5103
5113
|
}, i = (t) => {
|
|
5104
|
-
t.key === "Escape" && (D.current = null, O.current = null, k.current = null,
|
|
5114
|
+
t.key === "Escape" && (D.current = null, O.current = null, k.current = null, j.current = [], M.current = [], clearAllPreviewSources(e), p(null));
|
|
5105
5115
|
}, a = (t) => {
|
|
5106
5116
|
t.preventDefault();
|
|
5107
|
-
let n =
|
|
5117
|
+
let n = Ce.current;
|
|
5108
5118
|
if (n === "polygon") {
|
|
5109
|
-
let t =
|
|
5119
|
+
let t = j.current;
|
|
5110
5120
|
if (t.length >= 3) {
|
|
5111
5121
|
let n = {
|
|
5112
|
-
id:
|
|
5122
|
+
id: P(),
|
|
5113
5123
|
type: "polygon",
|
|
5114
5124
|
coordinates: [...t]
|
|
5115
5125
|
};
|
|
5116
|
-
|
|
5126
|
+
F(n), j.current = [], clearAllPreviewSources(e), p(null);
|
|
5117
5127
|
}
|
|
5118
5128
|
} else if (n === "polyline") {
|
|
5119
|
-
let t =
|
|
5129
|
+
let t = M.current;
|
|
5120
5130
|
if (t.length >= 2) {
|
|
5121
5131
|
let n = {
|
|
5122
|
-
id:
|
|
5132
|
+
id: P(),
|
|
5123
5133
|
type: "polyline",
|
|
5124
5134
|
coordinates: [...t]
|
|
5125
5135
|
};
|
|
5126
|
-
|
|
5136
|
+
F(n), M.current = [], clearAllPreviewSources(e), p(null);
|
|
5127
5137
|
}
|
|
5128
5138
|
}
|
|
5129
5139
|
};
|
|
5130
5140
|
return e.doubleClickZoom.disable(), e.on("click", t), e.on("mousemove", n), e.on("contextmenu", r), e.on("dblclick", a), document.addEventListener("keydown", i), () => {
|
|
5131
|
-
|
|
5141
|
+
if (document.removeEventListener("keydown", i), e) try {
|
|
5142
|
+
e.off("click", t), e.off("mousemove", n), e.off("contextmenu", r), e.off("dblclick", a), e.getCanvas().style.cursor = "", e.doubleClickZoom.enable(), clearAllPreviewSources(e);
|
|
5143
|
+
} catch {}
|
|
5132
5144
|
};
|
|
5133
5145
|
}, [
|
|
5134
5146
|
e,
|
|
5135
5147
|
f,
|
|
5148
|
+
P,
|
|
5136
5149
|
F,
|
|
5137
|
-
|
|
5138
|
-
we,
|
|
5139
|
-
ke,
|
|
5150
|
+
Te,
|
|
5140
5151
|
Ae,
|
|
5141
5152
|
je,
|
|
5142
|
-
|
|
5143
|
-
|
|
5153
|
+
Me,
|
|
5154
|
+
I,
|
|
5155
|
+
Ne
|
|
5144
5156
|
]), useEffect(() => () => {
|
|
5145
5157
|
C.current.forEach((e) => e.destroy()), C.current.clear();
|
|
5146
5158
|
}, []);
|
|
5147
|
-
let
|
|
5148
|
-
p((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null,
|
|
5159
|
+
let Pe = useCallback((t) => {
|
|
5160
|
+
p((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null, j.current = [], M.current = [], e && clearAllPreviewSources(e);
|
|
5149
5161
|
}, [e]);
|
|
5150
5162
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
5151
5163
|
className: `mapbox-measure-control ${c}`,
|
|
@@ -5181,17 +5193,17 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5181
5193
|
children: [
|
|
5182
5194
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5183
5195
|
checked: b.showArea,
|
|
5184
|
-
onChange: (e) =>
|
|
5196
|
+
onChange: (e) => ke("showArea", e),
|
|
5185
5197
|
children: "面积"
|
|
5186
5198
|
}),
|
|
5187
5199
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5188
5200
|
checked: b.showLength,
|
|
5189
|
-
onChange: (e) =>
|
|
5201
|
+
onChange: (e) => ke("showLength", e),
|
|
5190
5202
|
children: "长度"
|
|
5191
5203
|
}),
|
|
5192
5204
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5193
5205
|
checked: b.showRadius,
|
|
5194
|
-
onChange: (e) =>
|
|
5206
|
+
onChange: (e) => ke("showRadius", e),
|
|
5195
5207
|
children: "半径"
|
|
5196
5208
|
})
|
|
5197
5209
|
]
|
|
@@ -5204,7 +5216,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5204
5216
|
className: "mapbox-measure-control__tools",
|
|
5205
5217
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
5206
5218
|
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5207
|
-
onClick: () =>
|
|
5219
|
+
onClick: () => Pe(e.mode),
|
|
5208
5220
|
title: e.label,
|
|
5209
5221
|
children: /* @__PURE__ */ jsx("img", {
|
|
5210
5222
|
src: e.icon,
|
|
@@ -5212,7 +5224,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5212
5224
|
})
|
|
5213
5225
|
}, e.mode)), x.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
5214
5226
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
5215
|
-
onClick:
|
|
5227
|
+
onClick: De,
|
|
5216
5228
|
title: "清除全部",
|
|
5217
5229
|
children: /* @__PURE__ */ jsx("img", {
|
|
5218
5230
|
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",
|
|
@@ -5232,7 +5244,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5232
5244
|
/* @__PURE__ */ jsx("th", {})
|
|
5233
5245
|
] }) }), /* @__PURE__ */ jsx("tbody", { children: x.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
5234
5246
|
className: "mapbox-measure-control__table-row",
|
|
5235
|
-
onClick: () =>
|
|
5247
|
+
onClick: () => Oe(e.entity.id),
|
|
5236
5248
|
children: [
|
|
5237
5249
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
5238
5250
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -5241,7 +5253,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5241
5253
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
5242
5254
|
className: "mapbox-measure-control__delete-btn",
|
|
5243
5255
|
onClick: (t) => {
|
|
5244
|
-
t.stopPropagation(),
|
|
5256
|
+
t.stopPropagation(), Ee(e.entity.id);
|
|
5245
5257
|
},
|
|
5246
5258
|
title: "删除",
|
|
5247
5259
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -5659,12 +5671,14 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5659
5671
|
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5660
5672
|
T.current.push(r);
|
|
5661
5673
|
} else be();
|
|
5662
|
-
}, [e, be]),
|
|
5663
|
-
ye(), ve.current = [], D.current = null, v(0), g("idle"), e
|
|
5664
|
-
|
|
5674
|
+
}, [e, be]), xe = useCallback(() => {
|
|
5675
|
+
if (ye(), ve.current = [], D.current = null, v(0), g("idle"), e) try {
|
|
5676
|
+
e.getCanvas().style.cursor = O.current;
|
|
5677
|
+
} catch {}
|
|
5678
|
+
}, [ye, e]), A = useCallback(async () => {
|
|
5665
5679
|
let e = D.current, t = [...ve.current];
|
|
5666
5680
|
if (!e || t.length < 2) {
|
|
5667
|
-
|
|
5681
|
+
xe();
|
|
5668
5682
|
return;
|
|
5669
5683
|
}
|
|
5670
5684
|
g("planning");
|
|
@@ -5673,30 +5687,32 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5673
5687
|
} catch (e) {
|
|
5674
5688
|
console.error("Route planning onSelectFinished failed:", e);
|
|
5675
5689
|
} finally {
|
|
5676
|
-
|
|
5690
|
+
xe();
|
|
5677
5691
|
}
|
|
5678
|
-
}, [
|
|
5692
|
+
}, [xe]), Se = useCallback((e) => {
|
|
5679
5693
|
if (E.current !== "selecting" || !D.current) return;
|
|
5680
5694
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5681
5695
|
ve.current.push(t);
|
|
5682
5696
|
let n = ve.current.length;
|
|
5683
|
-
v(n), k(t), n >= D.current.pointCount &&
|
|
5684
|
-
}, [k,
|
|
5685
|
-
E.current === "selecting" && (e.preventDefault(),
|
|
5686
|
-
}, [
|
|
5697
|
+
v(n), k(t), n >= D.current.pointCount && A();
|
|
5698
|
+
}, [k, A]), j = useCallback((e) => {
|
|
5699
|
+
E.current === "selecting" && (e.preventDefault(), xe());
|
|
5700
|
+
}, [xe]);
|
|
5687
5701
|
useEffect(() => {
|
|
5688
|
-
if (e && p === "selecting") return e.on("click",
|
|
5689
|
-
e
|
|
5702
|
+
if (e && p === "selecting") return e.on("click", Se), e.on("contextmenu", j), () => {
|
|
5703
|
+
if (e) try {
|
|
5704
|
+
e.off("click", Se), e.off("contextmenu", j);
|
|
5705
|
+
} catch {}
|
|
5690
5706
|
};
|
|
5691
5707
|
}, [
|
|
5692
5708
|
e,
|
|
5693
5709
|
p,
|
|
5694
|
-
|
|
5695
|
-
|
|
5710
|
+
Se,
|
|
5711
|
+
j
|
|
5696
5712
|
]);
|
|
5697
|
-
let
|
|
5713
|
+
let M = useCallback((t) => {
|
|
5698
5714
|
if (!e) return;
|
|
5699
|
-
E.current !== "idle" &&
|
|
5715
|
+
E.current !== "idle" && xe();
|
|
5700
5716
|
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5701
5717
|
D.current = {
|
|
5702
5718
|
pointCount: n,
|
|
@@ -5707,21 +5723,21 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5707
5723
|
e,
|
|
5708
5724
|
i,
|
|
5709
5725
|
l,
|
|
5710
|
-
|
|
5726
|
+
xe
|
|
5711
5727
|
]);
|
|
5712
|
-
useImperativeHandle(f, () => ({ startPlanning:
|
|
5713
|
-
let
|
|
5714
|
-
p === "idle" ? S((e) => !e) : p === "selecting" &&
|
|
5715
|
-
},
|
|
5716
|
-
u &&
|
|
5728
|
+
useImperativeHandle(f, () => ({ startPlanning: M }), [M]);
|
|
5729
|
+
let N = () => {
|
|
5730
|
+
p === "idle" ? S((e) => !e) : p === "selecting" && xe();
|
|
5731
|
+
}, Ce = () => {
|
|
5732
|
+
u && M({
|
|
5717
5733
|
pointCount: Math.max(2, y),
|
|
5718
5734
|
visualType: l,
|
|
5719
5735
|
onSelectFinished: u
|
|
5720
5736
|
});
|
|
5721
|
-
},
|
|
5737
|
+
}, P = (e) => {
|
|
5722
5738
|
let t = parseInt(e.target.value, 10);
|
|
5723
5739
|
!isNaN(t) && t >= 2 ? b(t) : e.target.value === "" && b(2);
|
|
5724
|
-
},
|
|
5740
|
+
}, we = () => {
|
|
5725
5741
|
if (p === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5726
5742
|
if (p === "selecting") {
|
|
5727
5743
|
let e = D.current?.pointCount ?? y;
|
|
@@ -5732,20 +5748,20 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5732
5748
|
] });
|
|
5733
5749
|
}
|
|
5734
5750
|
return "路径规划";
|
|
5735
|
-
},
|
|
5751
|
+
}, Te = p === "selecting", F = p === "planning";
|
|
5736
5752
|
return !d && p === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5737
5753
|
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5738
5754
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5739
5755
|
ref: C,
|
|
5740
|
-
className: `mapbox-control-btn mapbox-route-planning-control__btn${
|
|
5741
|
-
onClick:
|
|
5742
|
-
disabled:
|
|
5756
|
+
className: `mapbox-control-btn mapbox-route-planning-control__btn${Te ? " mapbox-route-planning-control__btn--active" : ""}${F ? " mapbox-route-planning-control__btn--planning" : ""}${x ? " mapbox-route-planning-control__btn--active" : ""}`,
|
|
5757
|
+
onClick: N,
|
|
5758
|
+
disabled: F,
|
|
5743
5759
|
title: p === "idle" ? "路径规划" : p === "selecting" ? "取消选点" : "规划中...",
|
|
5744
5760
|
children: [/* @__PURE__ */ jsx("img", {
|
|
5745
5761
|
src: route_planning_default,
|
|
5746
5762
|
alt: "route",
|
|
5747
5763
|
className: "mapbox-route-planning-control__btn-icon"
|
|
5748
|
-
}),
|
|
5764
|
+
}), we()]
|
|
5749
5765
|
}), x && p === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5750
5766
|
ref: w,
|
|
5751
5767
|
className: "mapbox-route-planning-control__panel",
|
|
@@ -5768,7 +5784,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5768
5784
|
className: "mapbox-route-planning-control__panel-input",
|
|
5769
5785
|
value: y,
|
|
5770
5786
|
min: 2,
|
|
5771
|
-
onChange:
|
|
5787
|
+
onChange: P
|
|
5772
5788
|
}) : /* @__PURE__ */ jsx("span", {
|
|
5773
5789
|
className: "mapbox-route-planning-control__panel-value",
|
|
5774
5790
|
children: y
|
|
@@ -5780,7 +5796,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5780
5796
|
}),
|
|
5781
5797
|
/* @__PURE__ */ jsx("button", {
|
|
5782
5798
|
className: "mapbox-route-planning-control__panel-start",
|
|
5783
|
-
onClick:
|
|
5799
|
+
onClick: Ce,
|
|
5784
5800
|
disabled: !u,
|
|
5785
5801
|
children: "开始规划"
|
|
5786
5802
|
})
|
|
@@ -5937,53 +5953,53 @@ function adjustPopupForBounds(e, t) {
|
|
|
5937
5953
|
return r.x + t.width + 10 > n.width && (r.x = n.width - t.width - 10), r.x < 10 && (r.x = 10), r.y + t.height + 10 > n.height && (r.y = n.height - t.height - 10), r.y < 10 && (r.y = 10), r;
|
|
5938
5954
|
}
|
|
5939
5955
|
const Mapbox = forwardRef((e, c) => {
|
|
5940
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig:
|
|
5941
|
-
|
|
5942
|
-
let
|
|
5956
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: j, circleConfig: M, lengthConfig: N, showCoordinates: Ce = !0, showScale: P = !0, showResetView: we = !0, showRoadHighlight: Te = !1, showMeasure: F = !1, showRasterPaint: De = !1, showRoutePlanning: je, onRasterPaintChange: Me, popupDefaults: I, renderPopup: Pe, onMapLoad: Fe, onEntityClick: Ie, onPopupOpen: Le, onPopupClose: Re, className: ze = "", containerStyle: Be } = e, Ve = useRef(null), He = useRef(null), Ue = useRef(null), L = useRef(null), R = useRef(/* @__PURE__ */ new Map()), z = useRef(/* @__PURE__ */ new Map()), We = useRef(/* @__PURE__ */ new Set()), [B, Ge] = useState(null), Ke = useRef(null), qe = useRef(null), Je = useRef(null), [Ye, Xe] = useState(null), Ze = useRef(null), Qe = useRef(null), [$e, et] = useState(null), [V, tt] = useState(_), [nt, rt] = useState(null), it = useRef(null), [at, H] = useState(null), [ot, U] = useState(null), [st, ct] = useState(null), W = useRef(!1), lt = useRef(null), ut = useRef(null), G = useRef(null), dt = useRef(null), K = useRef(null), ft = useRef([]), pt = useRef(null), mt = useRef(null), ht = useRef(null), gt = useRef([]), _t = useRef(null), vt = useRef(!1), [yt, bt] = useState([]), xt = useRef([]);
|
|
5957
|
+
xt.current = yt;
|
|
5958
|
+
let q = useRef(null);
|
|
5943
5959
|
useEffect(() => {
|
|
5944
5960
|
tt(_);
|
|
5945
5961
|
}, [_]);
|
|
5946
|
-
let
|
|
5947
|
-
let t =
|
|
5962
|
+
let St = useCallback((e) => {
|
|
5963
|
+
let t = R.current.get(e), n = z.current.get(e);
|
|
5948
5964
|
if (t && n) {
|
|
5949
5965
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5950
5966
|
let r = {
|
|
5951
5967
|
...n,
|
|
5952
5968
|
isAnimating: !0
|
|
5953
5969
|
};
|
|
5954
|
-
|
|
5970
|
+
z.current.set(e, r), t.startAnimation();
|
|
5955
5971
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5956
5972
|
let r = {
|
|
5957
5973
|
...n,
|
|
5958
5974
|
isAnimating: !0
|
|
5959
5975
|
};
|
|
5960
|
-
|
|
5976
|
+
z.current.set(e, r), t.startAnimation();
|
|
5961
5977
|
}
|
|
5962
5978
|
}
|
|
5963
|
-
}, []),
|
|
5964
|
-
let t =
|
|
5979
|
+
}, []), Ct = useCallback((e) => {
|
|
5980
|
+
let t = R.current.get(e), n = z.current.get(e);
|
|
5965
5981
|
if (t && n) {
|
|
5966
5982
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
5967
5983
|
let r = {
|
|
5968
5984
|
...n,
|
|
5969
5985
|
isAnimating: !1
|
|
5970
5986
|
};
|
|
5971
|
-
|
|
5987
|
+
z.current.set(e, r), t.stopAnimation();
|
|
5972
5988
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
5973
5989
|
let r = {
|
|
5974
5990
|
...n,
|
|
5975
5991
|
isAnimating: !1
|
|
5976
5992
|
};
|
|
5977
|
-
|
|
5993
|
+
z.current.set(e, r), t.stopAnimation();
|
|
5978
5994
|
}
|
|
5979
5995
|
}
|
|
5980
|
-
}, []),
|
|
5981
|
-
let t =
|
|
5982
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
5983
|
-
}, [
|
|
5996
|
+
}, []), wt = useCallback((e) => {
|
|
5997
|
+
let t = z.current.get(e);
|
|
5998
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? Ct(e) : St(e));
|
|
5999
|
+
}, [St, Ct]), Tt = useCallback((e) => {
|
|
5984
6000
|
if (e === void 0) {
|
|
5985
6001
|
let e = !1;
|
|
5986
|
-
for (let [, t] of
|
|
6002
|
+
for (let [, t] of R.current) if (t instanceof UnitRenderer) {
|
|
5987
6003
|
let n = t.getShowTrajectory();
|
|
5988
6004
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
5989
6005
|
e = !0;
|
|
@@ -5991,46 +6007,46 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5991
6007
|
}
|
|
5992
6008
|
}
|
|
5993
6009
|
let t = e ? 0 : "all";
|
|
5994
|
-
for (let [, e] of
|
|
6010
|
+
for (let [, e] of R.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
5995
6011
|
} else {
|
|
5996
6012
|
let t = new Set(e.map(String));
|
|
5997
|
-
for (let [e, n] of
|
|
6013
|
+
for (let [e, n] of R.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
5998
6014
|
}
|
|
5999
|
-
}, []),
|
|
6015
|
+
}, []), Et = useCallback((e, t, n) => {
|
|
6000
6016
|
let r = T.find((t) => String(t.id) === String(e));
|
|
6001
|
-
if (!r?.popup || !
|
|
6002
|
-
let i = r.popup.content ??
|
|
6017
|
+
if (!r?.popup || !L.current) return;
|
|
6018
|
+
let i = r.popup.content ?? Pe?.(r);
|
|
6003
6019
|
if (!i) return;
|
|
6004
|
-
let a = mergePopupConfig(r.popup,
|
|
6005
|
-
|
|
6020
|
+
let a = mergePopupConfig(r.popup, I, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, L.current, n);
|
|
6021
|
+
Ge({
|
|
6006
6022
|
entityId: e,
|
|
6007
6023
|
position: o,
|
|
6008
6024
|
config: a,
|
|
6009
6025
|
openedBy: t,
|
|
6010
6026
|
actualPosition: s
|
|
6011
|
-
}),
|
|
6027
|
+
}), Le?.(e);
|
|
6012
6028
|
}, [
|
|
6013
6029
|
T,
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
]),
|
|
6018
|
-
|
|
6019
|
-
}, [
|
|
6020
|
-
|
|
6021
|
-
}, [
|
|
6022
|
-
let r =
|
|
6030
|
+
I,
|
|
6031
|
+
Pe,
|
|
6032
|
+
Le
|
|
6033
|
+
]), Dt = useCallback((e) => {
|
|
6034
|
+
B?.entityId === e && (Ge(null), Re?.(e));
|
|
6035
|
+
}, [B, Re]), Ot = useCallback(() => {
|
|
6036
|
+
Ge((e) => (e && Re?.(e.entityId), null));
|
|
6037
|
+
}, [Re]), kt = useCallback((e) => B?.entityId === e, [B]), At = useCallback((e, t, n) => {
|
|
6038
|
+
let r = L.current;
|
|
6023
6039
|
r && r.flyTo({
|
|
6024
6040
|
center: e,
|
|
6025
6041
|
zoom: t ?? r.getZoom(),
|
|
6026
6042
|
...n
|
|
6027
6043
|
});
|
|
6028
|
-
}, []),
|
|
6029
|
-
let r =
|
|
6044
|
+
}, []), jt = useCallback((e, t, n) => {
|
|
6045
|
+
let r = L.current;
|
|
6030
6046
|
if (!r || e.length === 0) return;
|
|
6031
6047
|
let i = [];
|
|
6032
6048
|
for (let t of e) {
|
|
6033
|
-
let e =
|
|
6049
|
+
let e = R.current.get(t);
|
|
6034
6050
|
e && i.push(e.getBounds());
|
|
6035
6051
|
}
|
|
6036
6052
|
if (i.length === 0) return;
|
|
@@ -6052,10 +6068,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6052
6068
|
pitch: n?.pitch ?? r.getPitch()
|
|
6053
6069
|
};
|
|
6054
6070
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
6055
|
-
}, []),
|
|
6056
|
-
|
|
6071
|
+
}, []), Mt = useRef(null), Nt = useRef("display"), [Pt, Ft] = useState({}), J = useMemo(() => ({
|
|
6072
|
+
...y,
|
|
6073
|
+
...Pt
|
|
6074
|
+
}), [y, Pt]), It = useCallback((e) => {
|
|
6075
|
+
let t = L.current;
|
|
6057
6076
|
if (!t || !t.getContainer()) return;
|
|
6058
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } =
|
|
6077
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = J;
|
|
6059
6078
|
if (!n) {
|
|
6060
6079
|
it.current &&= (it.current.remove(), null);
|
|
6061
6080
|
return;
|
|
@@ -6084,33 +6103,33 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6084
6103
|
anchor: "bottom"
|
|
6085
6104
|
}).setLngLat(e).addTo(t);
|
|
6086
6105
|
}
|
|
6087
|
-
}, [
|
|
6106
|
+
}, [J, O]), Lt = useCallback(() => {
|
|
6088
6107
|
it.current &&= (it.current.remove(), null);
|
|
6089
|
-
}, []),
|
|
6090
|
-
let t =
|
|
6091
|
-
if (
|
|
6108
|
+
}, []), Rt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), zt = useCallback((e) => {
|
|
6109
|
+
let t = L.current;
|
|
6110
|
+
if (Ve.current) if (_t.current &&= (_t.current.remove(), null), e && t) {
|
|
6092
6111
|
t.getCanvas().style.cursor = "none";
|
|
6093
6112
|
let n = document.createElement("div");
|
|
6094
6113
|
n.className = "mapbox-custom-cursor";
|
|
6095
6114
|
let r = e.size || e.width || 32;
|
|
6096
6115
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
6097
6116
|
let i = document.createElement("img");
|
|
6098
|
-
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),
|
|
6117
|
+
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), _t.current = n;
|
|
6099
6118
|
let a = (e) => {
|
|
6100
|
-
|
|
6119
|
+
_t.current && (_t.current.style.left = `${e.clientX}px`, _t.current.style.top = `${e.clientY}px`);
|
|
6101
6120
|
};
|
|
6102
6121
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
6103
6122
|
document.removeEventListener("mousemove", a);
|
|
6104
6123
|
};
|
|
6105
6124
|
} else t && (t.getCanvas().style.cursor = "");
|
|
6106
6125
|
}, []), Y = useCallback(() => {
|
|
6107
|
-
if (
|
|
6108
|
-
let e =
|
|
6109
|
-
e && e(),
|
|
6126
|
+
if (_t.current) {
|
|
6127
|
+
let e = _t.current._cleanup;
|
|
6128
|
+
e && e(), _t.current.remove(), _t.current = null;
|
|
6110
6129
|
}
|
|
6111
|
-
let e =
|
|
6130
|
+
let e = L.current;
|
|
6112
6131
|
e && (e.getCanvas().style.cursor = "");
|
|
6113
|
-
}, []),
|
|
6132
|
+
}, []), Bt = useCallback((e, t, n) => {
|
|
6114
6133
|
if (!e.getSource(t)) {
|
|
6115
6134
|
if (!e.getStyle().glyphs) {
|
|
6116
6135
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -6146,8 +6165,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6146
6165
|
}
|
|
6147
6166
|
});
|
|
6148
6167
|
}
|
|
6149
|
-
}, []),
|
|
6150
|
-
let e =
|
|
6168
|
+
}, []), Vt = useCallback(() => {
|
|
6169
|
+
let e = L.current;
|
|
6151
6170
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6152
6171
|
type: "geojson",
|
|
6153
6172
|
data: {
|
|
@@ -6171,9 +6190,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6171
6190
|
"line-width": 2,
|
|
6172
6191
|
"line-dasharray": [4, 4]
|
|
6173
6192
|
}
|
|
6174
|
-
}),
|
|
6175
|
-
}, [
|
|
6176
|
-
let n =
|
|
6193
|
+
}), Bt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6194
|
+
}, [Bt]), Ht = useCallback((e, t) => {
|
|
6195
|
+
let n = L.current;
|
|
6177
6196
|
if (!n) return;
|
|
6178
6197
|
let r = n.getSource("rect-preview-source");
|
|
6179
6198
|
if (!r) return;
|
|
@@ -6192,11 +6211,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6192
6211
|
},
|
|
6193
6212
|
properties: {}
|
|
6194
6213
|
});
|
|
6195
|
-
let l =
|
|
6214
|
+
let l = lt.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6196
6215
|
n.getLayer("rect-preview-line") && (n.setPaintProperty("rect-preview-line", "line-color", u), n.setPaintProperty("rect-preview-line", "line-width", d)), n.getLayer("rect-preview-fill") && (n.setPaintProperty("rect-preview-fill", "fill-color", f), n.setPaintProperty("rect-preview-fill", "fill-opacity", p));
|
|
6197
6216
|
let m = n.getSource("rect-preview-measure-source");
|
|
6198
6217
|
if (m) {
|
|
6199
|
-
let e =
|
|
6218
|
+
let e = Vn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6200
6219
|
if (e?.showArea) {
|
|
6201
6220
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6202
6221
|
t.push({
|
|
@@ -6233,8 +6252,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6233
6252
|
features: t
|
|
6234
6253
|
});
|
|
6235
6254
|
}
|
|
6236
|
-
}, []),
|
|
6237
|
-
let e =
|
|
6255
|
+
}, []), Ut = useCallback(() => {
|
|
6256
|
+
let e = L.current;
|
|
6238
6257
|
if (!e) return;
|
|
6239
6258
|
let t = e.getSource("rect-preview-source");
|
|
6240
6259
|
t && t.setData({
|
|
@@ -6247,9 +6266,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6247
6266
|
features: []
|
|
6248
6267
|
});
|
|
6249
6268
|
}, []), X = useCallback(() => {
|
|
6250
|
-
ct(null),
|
|
6251
|
-
}, [
|
|
6252
|
-
let e =
|
|
6269
|
+
ct(null), Ut();
|
|
6270
|
+
}, [Ut]), Wt = useCallback(() => {
|
|
6271
|
+
let e = L.current;
|
|
6253
6272
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6254
6273
|
type: "geojson",
|
|
6255
6274
|
data: {
|
|
@@ -6273,7 +6292,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6273
6292
|
"line-width": 2,
|
|
6274
6293
|
"line-dasharray": [4, 4]
|
|
6275
6294
|
}
|
|
6276
|
-
}),
|
|
6295
|
+
}), Bt(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
6277
6296
|
type: "geojson",
|
|
6278
6297
|
data: {
|
|
6279
6298
|
type: "FeatureCollection",
|
|
@@ -6290,22 +6309,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6290
6309
|
"line-dasharray": [4, 4]
|
|
6291
6310
|
}
|
|
6292
6311
|
}))));
|
|
6293
|
-
}, [
|
|
6312
|
+
}, [Bt]), Gt = useCallback((e, t, n = 64) => {
|
|
6294
6313
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
6295
6314
|
for (let e = 0; e <= n; e++) {
|
|
6296
6315
|
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;
|
|
6297
6316
|
a.push([d, u]);
|
|
6298
6317
|
}
|
|
6299
6318
|
return a;
|
|
6300
|
-
}, []),
|
|
6319
|
+
}, []), Kt = useCallback((e, t) => {
|
|
6301
6320
|
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);
|
|
6302
6321
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6303
|
-
}, []),
|
|
6304
|
-
let n =
|
|
6322
|
+
}, []), qt = useCallback((e, t) => {
|
|
6323
|
+
let n = L.current;
|
|
6305
6324
|
if (!n) return;
|
|
6306
6325
|
let r = n.getSource("circle-preview-source");
|
|
6307
6326
|
if (!r) return;
|
|
6308
|
-
let i =
|
|
6327
|
+
let i = Kt(e, t), a = Gt(e, i);
|
|
6309
6328
|
r.setData({
|
|
6310
6329
|
type: "Feature",
|
|
6311
6330
|
geometry: {
|
|
@@ -6314,9 +6333,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6314
6333
|
},
|
|
6315
6334
|
properties: {}
|
|
6316
6335
|
});
|
|
6317
|
-
let o =
|
|
6336
|
+
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6318
6337
|
n.getLayer("circle-preview-line") && (n.setPaintProperty("circle-preview-line", "line-color", s), n.setPaintProperty("circle-preview-line", "line-width", c)), n.getLayer("circle-preview-fill") && (n.setPaintProperty("circle-preview-fill", "fill-color", l), n.setPaintProperty("circle-preview-fill", "fill-opacity", u));
|
|
6319
|
-
let d =
|
|
6338
|
+
let d = Vn.current, f = [], p = [];
|
|
6320
6339
|
if (d?.showArea) {
|
|
6321
6340
|
let t = Math.PI * i * i;
|
|
6322
6341
|
f.push({
|
|
@@ -6329,7 +6348,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6329
6348
|
});
|
|
6330
6349
|
}
|
|
6331
6350
|
if (d?.showRadius) {
|
|
6332
|
-
let t =
|
|
6351
|
+
let t = G.current?.radiusAngle ?? 90, n = destinationPoint(e, i, t), r = [(e[0] + n[0]) / 2, (e[1] + n[1]) / 2];
|
|
6333
6352
|
p.push({
|
|
6334
6353
|
type: "Feature",
|
|
6335
6354
|
geometry: {
|
|
@@ -6356,8 +6375,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6356
6375
|
type: "FeatureCollection",
|
|
6357
6376
|
features: p
|
|
6358
6377
|
});
|
|
6359
|
-
}, [
|
|
6360
|
-
let e =
|
|
6378
|
+
}, [Kt, Gt]), Jt = useCallback(() => {
|
|
6379
|
+
let e = L.current;
|
|
6361
6380
|
if (!e) return;
|
|
6362
6381
|
let t = e.getSource("circle-preview-source");
|
|
6363
6382
|
t && t.setData({
|
|
@@ -6374,10 +6393,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6374
6393
|
type: "FeatureCollection",
|
|
6375
6394
|
features: []
|
|
6376
6395
|
});
|
|
6377
|
-
}, []),
|
|
6378
|
-
|
|
6379
|
-
}, [
|
|
6380
|
-
let e =
|
|
6396
|
+
}, []), Yt = useCallback(() => {
|
|
6397
|
+
dt.current = null, Jt();
|
|
6398
|
+
}, [Jt]), Xt = useCallback(() => {
|
|
6399
|
+
let e = L.current;
|
|
6381
6400
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6382
6401
|
type: "geojson",
|
|
6383
6402
|
data: {
|
|
@@ -6417,9 +6436,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6417
6436
|
"circle-stroke-color": "#ffffff",
|
|
6418
6437
|
"circle-stroke-width": 2
|
|
6419
6438
|
}
|
|
6420
|
-
}),
|
|
6421
|
-
}, [
|
|
6422
|
-
let n =
|
|
6439
|
+
}), Bt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6440
|
+
}, [Bt]), Zt = useCallback((e, t) => {
|
|
6441
|
+
let n = L.current;
|
|
6423
6442
|
if (!n) return;
|
|
6424
6443
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
6425
6444
|
if (!r || !i) return;
|
|
@@ -6456,11 +6475,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6456
6475
|
properties: {}
|
|
6457
6476
|
}))
|
|
6458
6477
|
});
|
|
6459
|
-
let o =
|
|
6478
|
+
let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6460
6479
|
n.getLayer("polygon-preview-line") && (n.setPaintProperty("polygon-preview-line", "line-color", s), n.setPaintProperty("polygon-preview-line", "line-width", c)), n.getLayer("polygon-preview-fill") && (n.setPaintProperty("polygon-preview-fill", "fill-color", l), n.setPaintProperty("polygon-preview-fill", "fill-opacity", u)), n.getLayer("polygon-vertices") && n.setPaintProperty("polygon-vertices", "circle-color", s);
|
|
6461
6480
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6462
6481
|
if (d) {
|
|
6463
|
-
let e =
|
|
6482
|
+
let e = Vn.current, t = [];
|
|
6464
6483
|
if (e?.showArea && a.length >= 3) {
|
|
6465
6484
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6466
6485
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6502,8 +6521,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6502
6521
|
features: t
|
|
6503
6522
|
});
|
|
6504
6523
|
}
|
|
6505
|
-
}, []),
|
|
6506
|
-
let e =
|
|
6524
|
+
}, []), Qt = useCallback(() => {
|
|
6525
|
+
let e = L.current;
|
|
6507
6526
|
if (!e) return;
|
|
6508
6527
|
let t = e.getSource("polygon-preview-source");
|
|
6509
6528
|
t && t.setData({
|
|
@@ -6520,10 +6539,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6520
6539
|
type: "FeatureCollection",
|
|
6521
6540
|
features: []
|
|
6522
6541
|
});
|
|
6523
|
-
}, []),
|
|
6524
|
-
|
|
6525
|
-
}, [
|
|
6526
|
-
let e =
|
|
6542
|
+
}, []), $t = useCallback(() => {
|
|
6543
|
+
ft.current = [], Qt();
|
|
6544
|
+
}, [Qt]), en = useCallback(() => {
|
|
6545
|
+
let e = L.current;
|
|
6527
6546
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6528
6547
|
type: "geojson",
|
|
6529
6548
|
data: {
|
|
@@ -6547,8 +6566,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6547
6566
|
"line-width": 2,
|
|
6548
6567
|
"line-dasharray": [4, 4]
|
|
6549
6568
|
}
|
|
6550
|
-
}),
|
|
6551
|
-
}, [
|
|
6569
|
+
}), Bt(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6570
|
+
}, [Bt]), tn = useCallback((e, t) => {
|
|
6552
6571
|
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);
|
|
6553
6572
|
return [
|
|
6554
6573
|
[n - s, r + o],
|
|
@@ -6557,12 +6576,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6557
6576
|
[n - s, r - o],
|
|
6558
6577
|
[n - s, r + o]
|
|
6559
6578
|
];
|
|
6560
|
-
}, []),
|
|
6561
|
-
let n =
|
|
6579
|
+
}, []), nn = useCallback((e, t) => {
|
|
6580
|
+
let n = L.current;
|
|
6562
6581
|
if (!n) return;
|
|
6563
6582
|
let r = n.getSource("square-preview-source");
|
|
6564
6583
|
if (!r) return;
|
|
6565
|
-
let i =
|
|
6584
|
+
let i = Kt(e, t) * 2, a = tn(e, i);
|
|
6566
6585
|
r.setData({
|
|
6567
6586
|
type: "Feature",
|
|
6568
6587
|
geometry: {
|
|
@@ -6571,11 +6590,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6571
6590
|
},
|
|
6572
6591
|
properties: {}
|
|
6573
6592
|
});
|
|
6574
|
-
let o =
|
|
6593
|
+
let o = pt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6575
6594
|
n.getLayer("square-preview-line") && (n.setPaintProperty("square-preview-line", "line-color", s), n.setPaintProperty("square-preview-line", "line-width", c)), n.getLayer("square-preview-fill") && (n.setPaintProperty("square-preview-fill", "fill-color", l), n.setPaintProperty("square-preview-fill", "fill-opacity", u));
|
|
6576
6595
|
let d = n.getSource("square-preview-measure-source");
|
|
6577
6596
|
if (d) {
|
|
6578
|
-
let t =
|
|
6597
|
+
let t = Vn.current, n = [];
|
|
6579
6598
|
if (t?.showArea && n.push({
|
|
6580
6599
|
type: "Feature",
|
|
6581
6600
|
geometry: {
|
|
@@ -6599,8 +6618,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6599
6618
|
features: n
|
|
6600
6619
|
});
|
|
6601
6620
|
}
|
|
6602
|
-
}, [
|
|
6603
|
-
let e =
|
|
6621
|
+
}, [Kt, tn]), rn = useCallback(() => {
|
|
6622
|
+
let e = L.current;
|
|
6604
6623
|
if (!e) return;
|
|
6605
6624
|
let t = e.getSource("square-preview-source");
|
|
6606
6625
|
t && t.setData({
|
|
@@ -6612,10 +6631,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6612
6631
|
type: "FeatureCollection",
|
|
6613
6632
|
features: []
|
|
6614
6633
|
});
|
|
6615
|
-
}, []),
|
|
6616
|
-
|
|
6617
|
-
}, [
|
|
6618
|
-
let e =
|
|
6634
|
+
}, []), an = useCallback(() => {
|
|
6635
|
+
mt.current = null, rn();
|
|
6636
|
+
}, [rn]), on = useCallback(() => {
|
|
6637
|
+
let e = L.current;
|
|
6619
6638
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6620
6639
|
type: "geojson",
|
|
6621
6640
|
data: {
|
|
@@ -6647,9 +6666,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6647
6666
|
"circle-stroke-color": "#ffffff",
|
|
6648
6667
|
"circle-stroke-width": 2
|
|
6649
6668
|
}
|
|
6650
|
-
}),
|
|
6651
|
-
}, [
|
|
6652
|
-
let n =
|
|
6669
|
+
}), Bt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
6670
|
+
}, [Bt]), sn = useCallback((e, t) => {
|
|
6671
|
+
let n = L.current;
|
|
6653
6672
|
if (!n) return;
|
|
6654
6673
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
6655
6674
|
if (!r || !i) return;
|
|
@@ -6675,11 +6694,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6675
6694
|
properties: {}
|
|
6676
6695
|
}))
|
|
6677
6696
|
});
|
|
6678
|
-
let o =
|
|
6697
|
+
let o = ht.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
6679
6698
|
n.getLayer("polyline-preview-line") && (n.setPaintProperty("polyline-preview-line", "line-color", s), n.setPaintProperty("polyline-preview-line", "line-width", c)), n.getLayer("polyline-vertices") && n.setPaintProperty("polyline-vertices", "circle-color", s);
|
|
6680
6699
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6681
6700
|
if (l) {
|
|
6682
|
-
let e =
|
|
6701
|
+
let e = Vn.current, t = [];
|
|
6683
6702
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6684
6703
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6685
6704
|
t.push({
|
|
@@ -6696,8 +6715,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6696
6715
|
features: t
|
|
6697
6716
|
});
|
|
6698
6717
|
}
|
|
6699
|
-
}, []),
|
|
6700
|
-
let e =
|
|
6718
|
+
}, []), cn = useCallback(() => {
|
|
6719
|
+
let e = L.current;
|
|
6701
6720
|
if (!e) return;
|
|
6702
6721
|
let t = e.getSource("polyline-preview-source");
|
|
6703
6722
|
t && t.setData({
|
|
@@ -6715,163 +6734,163 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6715
6734
|
features: []
|
|
6716
6735
|
});
|
|
6717
6736
|
}, []), Z = useCallback(() => {
|
|
6718
|
-
|
|
6719
|
-
}, [
|
|
6720
|
-
H(e),
|
|
6737
|
+
gt.current = [], cn();
|
|
6738
|
+
}, [cn]), ln = useCallback((e) => {
|
|
6739
|
+
H(e), zt(e), e ? (U("marker"), X(), Yt(), $t(), an(), Z()) : U(null);
|
|
6721
6740
|
}, [
|
|
6722
|
-
|
|
6741
|
+
zt,
|
|
6723
6742
|
X,
|
|
6724
|
-
|
|
6725
|
-
Jt,
|
|
6743
|
+
Yt,
|
|
6726
6744
|
$t,
|
|
6745
|
+
an,
|
|
6727
6746
|
Z
|
|
6728
|
-
]),
|
|
6747
|
+
]), un = useCallback((e) => {
|
|
6729
6748
|
if (U(e), e === "rectangle") {
|
|
6730
|
-
H(null), Y(),
|
|
6731
|
-
let e =
|
|
6749
|
+
H(null), Y(), Yt(), $t(), an(), Z();
|
|
6750
|
+
let e = L.current;
|
|
6732
6751
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6733
6752
|
} else if (e === "circle") {
|
|
6734
|
-
H(null), Y(), X(),
|
|
6735
|
-
let e =
|
|
6753
|
+
H(null), Y(), X(), $t(), an(), Z();
|
|
6754
|
+
let e = L.current;
|
|
6736
6755
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6737
6756
|
} else if (e === "polygon") {
|
|
6738
|
-
H(null), Y(), X(),
|
|
6739
|
-
let e =
|
|
6757
|
+
H(null), Y(), X(), Yt(), an(), Z();
|
|
6758
|
+
let e = L.current;
|
|
6740
6759
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6741
6760
|
} else if (e === "square") {
|
|
6742
|
-
H(null), Y(), X(),
|
|
6743
|
-
let e =
|
|
6761
|
+
H(null), Y(), X(), Yt(), $t(), Z();
|
|
6762
|
+
let e = L.current;
|
|
6744
6763
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6745
6764
|
} else if (e === "polyline") {
|
|
6746
|
-
H(null), Y(), X(),
|
|
6747
|
-
let e =
|
|
6765
|
+
H(null), Y(), X(), Yt(), $t(), an();
|
|
6766
|
+
let e = L.current;
|
|
6748
6767
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6749
|
-
} else e === "marker" ? (X(),
|
|
6768
|
+
} else e === "marker" ? (X(), Yt(), $t(), an(), Z()) : (H(null), Y(), X(), Yt(), $t(), an(), Z());
|
|
6750
6769
|
}, [
|
|
6751
6770
|
Y,
|
|
6752
6771
|
X,
|
|
6753
|
-
|
|
6754
|
-
Jt,
|
|
6772
|
+
Yt,
|
|
6755
6773
|
$t,
|
|
6774
|
+
an,
|
|
6756
6775
|
Z
|
|
6757
|
-
]),
|
|
6776
|
+
]), dn = useCallback((e) => {
|
|
6758
6777
|
if (e !== "picker") {
|
|
6759
|
-
let e =
|
|
6760
|
-
(!e || !t) &&
|
|
6778
|
+
let e = J.value && isFinite(J.value.lng) && isFinite(J.value.lat), t = J.showMarker !== !1;
|
|
6779
|
+
(!e || !t) && Lt(), rt(null);
|
|
6761
6780
|
}
|
|
6762
6781
|
e !== "edit" && (H(null), U(null), X(), Z(), Y()), tt(e);
|
|
6763
6782
|
}, [
|
|
6764
|
-
|
|
6783
|
+
Lt,
|
|
6765
6784
|
Y,
|
|
6766
6785
|
X,
|
|
6767
6786
|
Z
|
|
6768
|
-
]),
|
|
6769
|
-
|
|
6770
|
-
}, [
|
|
6771
|
-
|
|
6772
|
-
})), [
|
|
6787
|
+
]), fn = useCallback(() => V, [V]), pn = useCallback(() => nt, [nt]), mn = useCallback(() => {
|
|
6788
|
+
Lt(), rt(null);
|
|
6789
|
+
}, [Lt]), hn = useCallback((e = {}) => (Mt.current &&= (Mt.current(null), null), new Promise((t) => {
|
|
6790
|
+
Mt.current = t, Nt.current = In.current, Ft(e), dn("picker");
|
|
6791
|
+
})), [dn]);
|
|
6773
6792
|
useEffect(() => {
|
|
6774
|
-
if (
|
|
6775
|
-
let e =
|
|
6793
|
+
if (!$e) return;
|
|
6794
|
+
let e = J.value;
|
|
6776
6795
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6777
6796
|
let t = [e.lng, e.lat];
|
|
6778
|
-
rt(e),
|
|
6797
|
+
rt(e), It(t);
|
|
6779
6798
|
}
|
|
6780
6799
|
}, [
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6800
|
+
J.value,
|
|
6801
|
+
It,
|
|
6802
|
+
$e
|
|
6784
6803
|
]);
|
|
6785
|
-
let
|
|
6786
|
-
if (tt("edit"), t && (
|
|
6787
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
6804
|
+
let gn = (e) => "mode" in e, _n = useCallback((e, t = !0) => {
|
|
6805
|
+
if (tt("edit"), t && (Lt(), rt(null)), W.current = !0, gn(e)) {
|
|
6806
|
+
if (e.mode === "marker") e.markerStyle ? (ut.current = e.markerStyle, lt.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? zt({
|
|
6788
6807
|
id: "custom",
|
|
6789
6808
|
name: e.markerStyle.name || "Marker",
|
|
6790
6809
|
icon: e.markerStyle.src,
|
|
6791
6810
|
width: e.markerStyle.width
|
|
6792
|
-
}) : Y()) : e.template && (
|
|
6811
|
+
}) : Y()) : e.template && (ut.current = null, lt.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(e.template), U("marker"), zt(e.template));
|
|
6793
6812
|
else if (e.mode === "rectangle") {
|
|
6794
|
-
|
|
6795
|
-
let t =
|
|
6813
|
+
lt.current = e.rectangleStyle || null, ut.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null, H(null), U("rectangle"), Y();
|
|
6814
|
+
let t = L.current;
|
|
6796
6815
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6797
6816
|
} else if (e.mode === "circle") {
|
|
6798
|
-
|
|
6799
|
-
let t =
|
|
6817
|
+
G.current = e.circleStyle || null, lt.current = null, ut.current = null, K.current = null, pt.current = null, ht.current = null, H(null), U("circle"), Y();
|
|
6818
|
+
let t = L.current;
|
|
6800
6819
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6801
6820
|
} else if (e.mode === "polygon") {
|
|
6802
|
-
|
|
6803
|
-
let t =
|
|
6821
|
+
K.current = e.polygonStyle || null, lt.current = null, ut.current = null, G.current = null, pt.current = null, ht.current = null, H(null), U("polygon"), Y();
|
|
6822
|
+
let t = L.current;
|
|
6804
6823
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6805
6824
|
} else if (e.mode === "square") {
|
|
6806
|
-
|
|
6807
|
-
let t =
|
|
6825
|
+
pt.current = e.squareStyle || null, lt.current = null, ut.current = null, G.current = null, K.current = null, ht.current = null, H(null), U("square"), Y();
|
|
6826
|
+
let t = L.current;
|
|
6808
6827
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6809
6828
|
} else if (e.mode === "polyline") {
|
|
6810
|
-
|
|
6811
|
-
let t =
|
|
6829
|
+
ht.current = e.polylineStyle || null, lt.current = null, ut.current = null, G.current = null, K.current = null, pt.current = null, H(null), U("polyline"), Y();
|
|
6830
|
+
let t = L.current;
|
|
6812
6831
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6813
6832
|
}
|
|
6814
|
-
} else H(e), U("marker"),
|
|
6833
|
+
} else H(e), U("marker"), zt(e), lt.current = null, ut.current = null, G.current = null, K.current = null, pt.current = null, ht.current = null;
|
|
6815
6834
|
}, [
|
|
6816
|
-
|
|
6817
|
-
|
|
6835
|
+
Lt,
|
|
6836
|
+
zt,
|
|
6818
6837
|
Y
|
|
6819
6838
|
]);
|
|
6820
6839
|
useImperativeHandle(c, () => ({
|
|
6821
|
-
startAnimation:
|
|
6822
|
-
stopAnimation:
|
|
6823
|
-
toggleAnimation:
|
|
6824
|
-
getMap: () =>
|
|
6825
|
-
openPopup: (e) =>
|
|
6826
|
-
closePopup:
|
|
6827
|
-
closeAllPopups:
|
|
6828
|
-
isPopupOpen:
|
|
6829
|
-
toggleUnitTrajectory:
|
|
6830
|
-
flyTo:
|
|
6831
|
-
flyToEntities:
|
|
6832
|
-
getMode:
|
|
6833
|
-
setMode:
|
|
6834
|
-
getPickedLocation:
|
|
6835
|
-
clearPickedLocation:
|
|
6836
|
-
startDrawing:
|
|
6837
|
-
getRenderer: (e) =>
|
|
6840
|
+
startAnimation: St,
|
|
6841
|
+
stopAnimation: Ct,
|
|
6842
|
+
toggleAnimation: wt,
|
|
6843
|
+
getMap: () => L.current,
|
|
6844
|
+
openPopup: (e) => Et(e, "programmatic"),
|
|
6845
|
+
closePopup: Dt,
|
|
6846
|
+
closeAllPopups: Ot,
|
|
6847
|
+
isPopupOpen: kt,
|
|
6848
|
+
toggleUnitTrajectory: Tt,
|
|
6849
|
+
flyTo: At,
|
|
6850
|
+
flyToEntities: jt,
|
|
6851
|
+
getMode: fn,
|
|
6852
|
+
setMode: dn,
|
|
6853
|
+
getPickedLocation: pn,
|
|
6854
|
+
clearPickedLocation: mn,
|
|
6855
|
+
startDrawing: _n,
|
|
6856
|
+
getRenderer: (e) => R.current.get(e),
|
|
6838
6857
|
setEditingEntities: (e) => {
|
|
6839
|
-
for (let t of
|
|
6840
|
-
for (let t of e)
|
|
6841
|
-
|
|
6858
|
+
for (let t of xt.current) e.map(String).includes(String(t)) || R.current.get(t)?.setEditing?.(!1);
|
|
6859
|
+
for (let t of e) R.current.get(t)?.setEditing?.(!0);
|
|
6860
|
+
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null), bt(e);
|
|
6842
6861
|
},
|
|
6843
|
-
getEditingEntities: () =>
|
|
6844
|
-
startPicking:
|
|
6862
|
+
getEditingEntities: () => xt.current,
|
|
6863
|
+
startPicking: hn,
|
|
6845
6864
|
startRoutePlanning: (e) => {
|
|
6846
|
-
|
|
6865
|
+
He.current?.startPlanning(e);
|
|
6847
6866
|
},
|
|
6848
|
-
getRoadHighlightControl: () =>
|
|
6867
|
+
getRoadHighlightControl: () => Ue.current
|
|
6849
6868
|
}), [
|
|
6850
|
-
xt,
|
|
6851
6869
|
St,
|
|
6852
6870
|
Ct,
|
|
6853
|
-
|
|
6871
|
+
wt,
|
|
6854
6872
|
Et,
|
|
6855
6873
|
Dt,
|
|
6856
6874
|
Ot,
|
|
6857
|
-
wt,
|
|
6858
6875
|
kt,
|
|
6876
|
+
Tt,
|
|
6859
6877
|
At,
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6878
|
+
jt,
|
|
6879
|
+
fn,
|
|
6880
|
+
dn,
|
|
6881
|
+
pn,
|
|
6882
|
+
mn,
|
|
6883
|
+
_n,
|
|
6884
|
+
hn
|
|
6866
6885
|
]);
|
|
6867
|
-
let
|
|
6868
|
-
let e =
|
|
6886
|
+
let vn = useCallback(() => {
|
|
6887
|
+
let e = L.current;
|
|
6869
6888
|
if (!e) return;
|
|
6870
|
-
let t = new Set(T.map((e) => e.id)), n = new Set(
|
|
6871
|
-
for (let e of n) t.has(e) || (
|
|
6889
|
+
let t = new Set(T.map((e) => e.id)), n = new Set(R.current.keys());
|
|
6890
|
+
for (let e of n) t.has(e) || (R.current.get(e)?.destroy(), R.current.delete(e));
|
|
6872
6891
|
let r = new Set(E.map(String));
|
|
6873
6892
|
for (let t of T) {
|
|
6874
|
-
let n = applyEntityConfig(t, D), i =
|
|
6893
|
+
let n = applyEntityConfig(t, D), i = R.current.get(n.id);
|
|
6875
6894
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
6876
6895
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
6877
6896
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -6880,23 +6899,23 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6880
6899
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
6881
6900
|
else {
|
|
6882
6901
|
i.destroy();
|
|
6883
|
-
let t = new CanvasCircleRenderer(e, n, O, k,
|
|
6884
|
-
|
|
6902
|
+
let t = new CanvasCircleRenderer(e, n, O, k, j, M);
|
|
6903
|
+
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6885
6904
|
}
|
|
6886
6905
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
6887
6906
|
else {
|
|
6888
6907
|
i.destroy();
|
|
6889
|
-
let t = new CircleRenderer(e, n, O, k,
|
|
6890
|
-
|
|
6908
|
+
let t = new CircleRenderer(e, n, O, k, j, M);
|
|
6909
|
+
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6891
6910
|
}
|
|
6892
6911
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
6893
6912
|
else {
|
|
6894
6913
|
let t = null;
|
|
6895
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k,
|
|
6914
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, j, M) : new CircleRenderer(e, n, O, k, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, j, N) : n.type === "polyline" && (t = new PolylineRenderer(e, n, O, k, N)), t && (R.current.set(n.id, t), t.setSelected(r.has(String(n.id))), xt.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
6896
6915
|
}
|
|
6897
6916
|
}
|
|
6898
|
-
for (let e of
|
|
6899
|
-
let t =
|
|
6917
|
+
for (let e of xt.current) {
|
|
6918
|
+
let t = R.current.get(e);
|
|
6900
6919
|
t && t.setEditing?.(!0);
|
|
6901
6920
|
}
|
|
6902
6921
|
}, [
|
|
@@ -6905,13 +6924,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6905
6924
|
D,
|
|
6906
6925
|
O,
|
|
6907
6926
|
k,
|
|
6927
|
+
j,
|
|
6908
6928
|
M,
|
|
6909
|
-
N
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
}, []), vn = useCallback((e) => {
|
|
6929
|
+
N
|
|
6930
|
+
]), yn = useCallback(() => {
|
|
6931
|
+
for (let e of R.current.values()) e.destroy();
|
|
6932
|
+
R.current.clear();
|
|
6933
|
+
}, []), bn = useCallback((e) => {
|
|
6915
6934
|
let t = e.getStyle();
|
|
6916
6935
|
if (!t?.layers) return;
|
|
6917
6936
|
let n = [
|
|
@@ -6926,10 +6945,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6926
6945
|
"marker-"
|
|
6927
6946
|
];
|
|
6928
6947
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6929
|
-
}, []),
|
|
6948
|
+
}, []), xn = useCallback((e) => {
|
|
6930
6949
|
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;
|
|
6931
6950
|
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;
|
|
6932
|
-
}, [C]),
|
|
6951
|
+
}, [C]), Sn = useCallback((e, t) => {
|
|
6933
6952
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6934
6953
|
type: "raster",
|
|
6935
6954
|
tiles: [t.url],
|
|
@@ -6939,19 +6958,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6939
6958
|
scheme: t.scheme ?? "xyz"
|
|
6940
6959
|
};
|
|
6941
6960
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6942
|
-
let a =
|
|
6961
|
+
let a = bn(e);
|
|
6943
6962
|
e.addLayer({
|
|
6944
6963
|
id: r,
|
|
6945
6964
|
type: "raster",
|
|
6946
6965
|
source: n,
|
|
6947
|
-
paint:
|
|
6966
|
+
paint: xn(t),
|
|
6948
6967
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6949
6968
|
}, a);
|
|
6950
|
-
}, [
|
|
6969
|
+
}, [bn, xn]), Cn = useCallback(async (e, t) => {
|
|
6951
6970
|
try {
|
|
6952
6971
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6953
|
-
if (!
|
|
6954
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
6972
|
+
if (!We.current.has(t.id)) return;
|
|
6973
|
+
let a = n.format === "pbf" || n.vector_layers, o = bn(e);
|
|
6955
6974
|
if (a) {
|
|
6956
6975
|
let t = {
|
|
6957
6976
|
type: "vector",
|
|
@@ -6972,21 +6991,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6972
6991
|
id: i,
|
|
6973
6992
|
type: "raster",
|
|
6974
6993
|
source: r,
|
|
6975
|
-
paint:
|
|
6994
|
+
paint: xn(t),
|
|
6976
6995
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6977
6996
|
}, o);
|
|
6978
6997
|
} catch (e) {
|
|
6979
6998
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
6980
6999
|
}
|
|
6981
|
-
}, [
|
|
7000
|
+
}, [bn, xn]), wn = useCallback(async (e, t) => {
|
|
6982
7001
|
try {
|
|
6983
7002
|
let n = await (await fetch(t.url)).json();
|
|
6984
|
-
if (!
|
|
7003
|
+
if (!We.current.has(t.id)) return;
|
|
6985
7004
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
6986
7005
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
6987
7006
|
e.getSource(n) || e.addSource(n, i);
|
|
6988
7007
|
}
|
|
6989
|
-
let r =
|
|
7008
|
+
let r = bn(e);
|
|
6990
7009
|
if (n.layers) for (let i of n.layers) {
|
|
6991
7010
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
6992
7011
|
if (e.getLayer(n)) continue;
|
|
@@ -6997,7 +7016,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6997
7016
|
};
|
|
6998
7017
|
i.type === "raster" && (a.paint = {
|
|
6999
7018
|
...a.paint,
|
|
7000
|
-
...
|
|
7019
|
+
...xn(t)
|
|
7001
7020
|
}), t.visible === !1 && (a.layout = {
|
|
7002
7021
|
...a.layout,
|
|
7003
7022
|
visibility: "none"
|
|
@@ -7010,50 +7029,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7010
7029
|
} catch (e) {
|
|
7011
7030
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
7012
7031
|
}
|
|
7013
|
-
}, [
|
|
7032
|
+
}, [bn, xn]), Tn = useCallback((e, t) => {
|
|
7014
7033
|
let n = e.getStyle();
|
|
7015
7034
|
if (!n) return;
|
|
7016
7035
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
7017
7036
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
7018
7037
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7019
7038
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7020
|
-
}, []),
|
|
7021
|
-
let t =
|
|
7039
|
+
}, []), En = useCallback((e) => {
|
|
7040
|
+
let t = L.current;
|
|
7022
7041
|
if (!t) return;
|
|
7023
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
7024
|
-
for (let e of r) n.has(e) || (
|
|
7042
|
+
let n = new Set(e.map((e) => e.id)), r = We.current;
|
|
7043
|
+
for (let e of r) n.has(e) || (Tn(t, e), r.delete(e));
|
|
7025
7044
|
for (let n of e) if (r.has(n.id)) {
|
|
7026
7045
|
let e = `base-layer-${n.id}`;
|
|
7027
7046
|
if (t.getLayer(e)) {
|
|
7028
|
-
let r =
|
|
7047
|
+
let r = xn(n);
|
|
7029
7048
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7030
7049
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7031
7050
|
}
|
|
7032
7051
|
} else switch (r.add(n.id), n.type) {
|
|
7033
7052
|
case "raster":
|
|
7034
|
-
|
|
7053
|
+
Sn(t, n);
|
|
7035
7054
|
break;
|
|
7036
7055
|
case "tilejson":
|
|
7037
|
-
|
|
7056
|
+
Cn(t, n);
|
|
7038
7057
|
break;
|
|
7039
7058
|
case "style":
|
|
7040
|
-
|
|
7059
|
+
wn(t, n);
|
|
7041
7060
|
break;
|
|
7042
7061
|
default: {
|
|
7043
7062
|
let e = n;
|
|
7044
|
-
e.url &&
|
|
7063
|
+
e.url && Sn(t, {
|
|
7045
7064
|
...e,
|
|
7046
7065
|
type: "raster"
|
|
7047
7066
|
});
|
|
7048
7067
|
}
|
|
7049
7068
|
}
|
|
7050
7069
|
}, [
|
|
7051
|
-
bn,
|
|
7052
|
-
xn,
|
|
7053
7070
|
Sn,
|
|
7054
7071
|
Cn,
|
|
7055
|
-
|
|
7056
|
-
|
|
7072
|
+
wn,
|
|
7073
|
+
Tn,
|
|
7074
|
+
xn
|
|
7075
|
+
]), Dn = useCallback((e) => {
|
|
7057
7076
|
let t = e;
|
|
7058
7077
|
for (; t;) {
|
|
7059
7078
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7061,129 +7080,129 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7061
7080
|
t = t.parentElement;
|
|
7062
7081
|
}
|
|
7063
7082
|
return null;
|
|
7064
|
-
}, []),
|
|
7083
|
+
}, []), On = useCallback((e) => {
|
|
7065
7084
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7066
7085
|
x: e.point.x,
|
|
7067
7086
|
y: e.point.y
|
|
7068
|
-
}, r =
|
|
7087
|
+
}, r = In.current;
|
|
7069
7088
|
if (r === "picker") {
|
|
7070
7089
|
let e = {
|
|
7071
7090
|
lng: t[0],
|
|
7072
7091
|
lat: t[1]
|
|
7073
7092
|
};
|
|
7074
|
-
rt(e),
|
|
7093
|
+
rt(e), It(t), Ln.current?.(e), Mt.current && (Mt.current(e), Mt.current = null, Ft({}), Lt(), rt(null), dn(Nt.current));
|
|
7075
7094
|
return;
|
|
7076
7095
|
}
|
|
7077
|
-
if (
|
|
7096
|
+
if (vt.current) return;
|
|
7078
7097
|
if (r === "edit") {
|
|
7079
|
-
let e =
|
|
7098
|
+
let e = zn.current;
|
|
7080
7099
|
if (e === "rectangle") {
|
|
7081
|
-
let e =
|
|
7100
|
+
let e = Bn.current;
|
|
7082
7101
|
if (!e) ct(t);
|
|
7083
7102
|
else {
|
|
7084
|
-
let n =
|
|
7103
|
+
let n = lt.current, r = applyEntityConfig({
|
|
7085
7104
|
...n,
|
|
7086
|
-
id: n?.id ??
|
|
7105
|
+
id: n?.id ?? Rt(),
|
|
7087
7106
|
type: "rectangle",
|
|
7088
7107
|
bounds: [e, t]
|
|
7089
7108
|
}, D);
|
|
7090
|
-
|
|
7091
|
-
let i =
|
|
7092
|
-
if (i && !
|
|
7093
|
-
let e = new RectangleRenderer(i, r, O, k,
|
|
7094
|
-
|
|
7109
|
+
Ut();
|
|
7110
|
+
let i = L.current;
|
|
7111
|
+
if (i && !R.current.has(r.id)) {
|
|
7112
|
+
let e = new RectangleRenderer(i, r, O, k, j, N);
|
|
7113
|
+
R.current.set(r.id, e);
|
|
7095
7114
|
}
|
|
7096
|
-
Q.current.onRectangleAdd?.(r), ct(null),
|
|
7115
|
+
Q.current.onRectangleAdd?.(r), ct(null), lt.current = null, W.current && (W.current = !1, U(null), i && (i.getCanvas().style.cursor = ""));
|
|
7097
7116
|
}
|
|
7098
7117
|
return;
|
|
7099
7118
|
}
|
|
7100
7119
|
if (e === "circle") {
|
|
7101
|
-
let e =
|
|
7102
|
-
if (!e)
|
|
7120
|
+
let e = dt.current;
|
|
7121
|
+
if (!e) dt.current = { center: t };
|
|
7103
7122
|
else {
|
|
7104
|
-
let n =
|
|
7123
|
+
let n = Kt(e.center, t), r = G.current, i = applyEntityConfig({
|
|
7105
7124
|
...r,
|
|
7106
|
-
id: r?.id ??
|
|
7125
|
+
id: r?.id ?? Rt(),
|
|
7107
7126
|
type: "circle",
|
|
7108
7127
|
center: e.center,
|
|
7109
7128
|
radius: n
|
|
7110
7129
|
}, D);
|
|
7111
|
-
|
|
7112
|
-
let a =
|
|
7113
|
-
if (a && !
|
|
7114
|
-
let e = new CircleRenderer(a, i, O, k,
|
|
7115
|
-
|
|
7130
|
+
Jt();
|
|
7131
|
+
let a = L.current;
|
|
7132
|
+
if (a && !R.current.has(i.id)) {
|
|
7133
|
+
let e = new CircleRenderer(a, i, O, k, j, M);
|
|
7134
|
+
R.current.set(i.id, e);
|
|
7116
7135
|
}
|
|
7117
|
-
Q.current.onCircleAdd?.(i),
|
|
7136
|
+
Q.current.onCircleAdd?.(i), dt.current = null, G.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7118
7137
|
}
|
|
7119
7138
|
return;
|
|
7120
7139
|
}
|
|
7121
7140
|
if (e === "polygon") {
|
|
7122
|
-
let e =
|
|
7141
|
+
let e = ft.current;
|
|
7123
7142
|
if (e.length >= 3) {
|
|
7124
7143
|
let n = e[0];
|
|
7125
|
-
if (
|
|
7126
|
-
let t =
|
|
7144
|
+
if (Kt(n, t) < 20) {
|
|
7145
|
+
let t = K.current, n = applyEntityConfig({
|
|
7127
7146
|
...t,
|
|
7128
|
-
id: t?.id ??
|
|
7147
|
+
id: t?.id ?? Rt(),
|
|
7129
7148
|
type: "polygon",
|
|
7130
7149
|
coordinates: [...e]
|
|
7131
7150
|
}, D);
|
|
7132
|
-
|
|
7133
|
-
let r =
|
|
7134
|
-
if (r && !
|
|
7135
|
-
let e = new PolygonRenderer(r, n, O, k,
|
|
7136
|
-
|
|
7151
|
+
Qt();
|
|
7152
|
+
let r = L.current;
|
|
7153
|
+
if (r && !R.current.has(n.id)) {
|
|
7154
|
+
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7155
|
+
R.current.set(n.id, e);
|
|
7137
7156
|
}
|
|
7138
|
-
Q.current.onPolygonAdd?.(n),
|
|
7157
|
+
Q.current.onPolygonAdd?.(n), ft.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7139
7158
|
return;
|
|
7140
7159
|
}
|
|
7141
7160
|
}
|
|
7142
|
-
|
|
7161
|
+
ft.current = [...e, t];
|
|
7143
7162
|
return;
|
|
7144
7163
|
}
|
|
7145
7164
|
if (e === "square") {
|
|
7146
|
-
let e =
|
|
7147
|
-
if (!e)
|
|
7165
|
+
let e = mt.current;
|
|
7166
|
+
if (!e) mt.current = { center: t };
|
|
7148
7167
|
else {
|
|
7149
|
-
let n =
|
|
7168
|
+
let n = Kt(e.center, t) * 2, r = pt.current, i = applyEntityConfig({
|
|
7150
7169
|
...r,
|
|
7151
|
-
id: r?.id ??
|
|
7170
|
+
id: r?.id ?? Rt(),
|
|
7152
7171
|
type: "square",
|
|
7153
7172
|
center: e.center,
|
|
7154
7173
|
length: n
|
|
7155
7174
|
}, D);
|
|
7156
|
-
|
|
7157
|
-
let a =
|
|
7158
|
-
if (a && !
|
|
7159
|
-
let e = new SquareRenderer(a, i, O, k,
|
|
7160
|
-
|
|
7175
|
+
rn();
|
|
7176
|
+
let a = L.current;
|
|
7177
|
+
if (a && !R.current.has(i.id)) {
|
|
7178
|
+
let e = new SquareRenderer(a, i, O, k, j, N);
|
|
7179
|
+
R.current.set(i.id, e);
|
|
7161
7180
|
}
|
|
7162
|
-
Q.current.onSquareAdd?.(i),
|
|
7181
|
+
Q.current.onSquareAdd?.(i), mt.current = null, pt.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7163
7182
|
}
|
|
7164
7183
|
return;
|
|
7165
7184
|
}
|
|
7166
7185
|
if (e === "polyline") {
|
|
7167
|
-
|
|
7186
|
+
gt.current = [...gt.current, t];
|
|
7168
7187
|
return;
|
|
7169
7188
|
}
|
|
7170
|
-
let n =
|
|
7189
|
+
let n = ut.current;
|
|
7171
7190
|
if (n && n.src && n.width) {
|
|
7172
7191
|
let e = {
|
|
7173
7192
|
...n,
|
|
7174
|
-
id: n.id ??
|
|
7193
|
+
id: n.id ?? Rt(),
|
|
7175
7194
|
type: "marker",
|
|
7176
7195
|
center: t,
|
|
7177
7196
|
src: n.src,
|
|
7178
7197
|
width: n.width
|
|
7179
7198
|
};
|
|
7180
|
-
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(),
|
|
7199
|
+
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), ut.current = null, W.current = !1;
|
|
7181
7200
|
return;
|
|
7182
7201
|
}
|
|
7183
|
-
let r =
|
|
7202
|
+
let r = Rn.current;
|
|
7184
7203
|
if (r) {
|
|
7185
7204
|
let e = {
|
|
7186
|
-
id:
|
|
7205
|
+
id: Rt(),
|
|
7187
7206
|
type: "marker",
|
|
7188
7207
|
name: r.name,
|
|
7189
7208
|
center: t,
|
|
@@ -7194,25 +7213,25 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7194
7213
|
return;
|
|
7195
7214
|
}
|
|
7196
7215
|
}
|
|
7197
|
-
if (
|
|
7198
|
-
let e =
|
|
7199
|
-
if (
|
|
7200
|
-
let { entityId: e, activeHandle: n } =
|
|
7216
|
+
if (xt.current.length > 0) {
|
|
7217
|
+
let e = L.current?.getZoom() ?? 12;
|
|
7218
|
+
if (q.current) {
|
|
7219
|
+
let { entityId: e, activeHandle: n } = q.current, r = R.current.get(e);
|
|
7201
7220
|
if (r?.applyHandleMove) {
|
|
7202
7221
|
let e = r.applyHandleMove(n, t);
|
|
7203
7222
|
Q.current.onEntityEdit?.(e);
|
|
7204
7223
|
}
|
|
7205
|
-
|
|
7224
|
+
q.current = null;
|
|
7206
7225
|
return;
|
|
7207
7226
|
}
|
|
7208
|
-
for (let n of
|
|
7209
|
-
let r =
|
|
7227
|
+
for (let n of xt.current) {
|
|
7228
|
+
let r = R.current.get(n);
|
|
7210
7229
|
if (!r?.getEditHandleAt) continue;
|
|
7211
7230
|
let i = r.getEditHandleAt(t, e);
|
|
7212
7231
|
if (i) {
|
|
7213
7232
|
if (i.type === "midpoint" && r.addVertex) {
|
|
7214
7233
|
let e = r.addVertex(i.index, i.position);
|
|
7215
|
-
Q.current.onEntityEdit?.(e),
|
|
7234
|
+
Q.current.onEntityEdit?.(e), q.current = {
|
|
7216
7235
|
entityId: n,
|
|
7217
7236
|
activeHandle: {
|
|
7218
7237
|
type: "vertex",
|
|
@@ -7220,7 +7239,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7220
7239
|
position: i.position
|
|
7221
7240
|
}
|
|
7222
7241
|
};
|
|
7223
|
-
} else
|
|
7242
|
+
} else q.current = {
|
|
7224
7243
|
entityId: n,
|
|
7225
7244
|
activeHandle: i
|
|
7226
7245
|
};
|
|
@@ -7228,104 +7247,104 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7228
7247
|
}
|
|
7229
7248
|
}
|
|
7230
7249
|
}
|
|
7231
|
-
let i =
|
|
7250
|
+
let i = Nn.current, a = Pn.current, o = Fn.current, s = Dn(e.originalEvent.target);
|
|
7232
7251
|
if (s) {
|
|
7233
7252
|
let e = i.find((e) => String(e.id) === s);
|
|
7234
7253
|
if (e) {
|
|
7235
7254
|
if (a?.(e), e.popup) {
|
|
7236
|
-
let t = e.popup.content ??
|
|
7237
|
-
t && mergePopupConfig(e.popup,
|
|
7255
|
+
let t = e.popup.content ?? Pe?.(e);
|
|
7256
|
+
t && mergePopupConfig(e.popup, I, t).trigger === "click" && o(s, "click", n);
|
|
7238
7257
|
}
|
|
7239
7258
|
return;
|
|
7240
7259
|
}
|
|
7241
7260
|
}
|
|
7242
|
-
for (let [t, r] of
|
|
7261
|
+
for (let [t, r] of R.current) {
|
|
7243
7262
|
let s = r.getLabelLayerId();
|
|
7244
|
-
if (s &&
|
|
7263
|
+
if (s && L.current?.getLayer(s) && L.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
7245
7264
|
let e = i.find((e) => e.id === t);
|
|
7246
7265
|
if (e) {
|
|
7247
7266
|
if (a?.(e), e.popup) {
|
|
7248
|
-
let r = e.popup.content ??
|
|
7249
|
-
r && mergePopupConfig(e.popup,
|
|
7267
|
+
let r = e.popup.content ?? Pe?.(e);
|
|
7268
|
+
r && mergePopupConfig(e.popup, I, r).trigger === "click" && o(t, "click", n);
|
|
7250
7269
|
}
|
|
7251
7270
|
return;
|
|
7252
7271
|
}
|
|
7253
7272
|
}
|
|
7254
7273
|
}
|
|
7255
|
-
for (let [e, r] of
|
|
7274
|
+
for (let [e, r] of R.current) if (r.isPointInEntity(t)) {
|
|
7256
7275
|
let t = i.find((t) => t.id === e);
|
|
7257
7276
|
if (t) {
|
|
7258
7277
|
if (a?.(t), t.popup) {
|
|
7259
|
-
let r = t.popup.content ??
|
|
7260
|
-
r && mergePopupConfig(t.popup,
|
|
7278
|
+
let r = t.popup.content ?? Pe?.(t);
|
|
7279
|
+
r && mergePopupConfig(t.popup, I, r).trigger === "click" && o(e, "click", n);
|
|
7261
7280
|
}
|
|
7262
7281
|
return;
|
|
7263
7282
|
}
|
|
7264
7283
|
}
|
|
7265
7284
|
}, [
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
]),
|
|
7285
|
+
I,
|
|
7286
|
+
Pe,
|
|
7287
|
+
Dn
|
|
7288
|
+
]), kn = useCallback((e) => {
|
|
7270
7289
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7271
|
-
if (
|
|
7272
|
-
let { entityId: e, activeHandle: n } =
|
|
7273
|
-
|
|
7290
|
+
if (q.current) {
|
|
7291
|
+
let { entityId: e, activeHandle: n } = q.current;
|
|
7292
|
+
R.current.get(e)?.updateEditPreview?.(n, t);
|
|
7274
7293
|
return;
|
|
7275
7294
|
}
|
|
7276
|
-
let n =
|
|
7277
|
-
n === "rectangle" && r &&
|
|
7278
|
-
let i =
|
|
7279
|
-
n === "circle" && i &&
|
|
7280
|
-
let a =
|
|
7281
|
-
n === "polygon" && a.length > 0 &&
|
|
7282
|
-
let o =
|
|
7283
|
-
n === "square" && o &&
|
|
7284
|
-
let s =
|
|
7285
|
-
n === "polyline" && s.length > 0 &&
|
|
7286
|
-
let c =
|
|
7287
|
-
for (let [e, n] of
|
|
7295
|
+
let n = zn.current, r = Bn.current;
|
|
7296
|
+
n === "rectangle" && r && Ht(r, t);
|
|
7297
|
+
let i = dt.current;
|
|
7298
|
+
n === "circle" && i && qt(i.center, t);
|
|
7299
|
+
let a = ft.current;
|
|
7300
|
+
n === "polygon" && a.length > 0 && Zt(a, t);
|
|
7301
|
+
let o = mt.current;
|
|
7302
|
+
n === "square" && o && nn(o.center, t);
|
|
7303
|
+
let s = gt.current;
|
|
7304
|
+
n === "polyline" && s.length > 0 && sn(s, t);
|
|
7305
|
+
let c = Nn.current, l = Fn.current;
|
|
7306
|
+
for (let [e, n] of R.current) if (n.isPointInEntity(t)) {
|
|
7288
7307
|
let t = c.find((t) => t.id === e);
|
|
7289
7308
|
if (!t?.popup) continue;
|
|
7290
|
-
let n = t.popup.content ??
|
|
7309
|
+
let n = t.popup.content ?? Pe?.(t);
|
|
7291
7310
|
if (!n) continue;
|
|
7292
|
-
let r = mergePopupConfig(t.popup,
|
|
7311
|
+
let r = mergePopupConfig(t.popup, I, n);
|
|
7293
7312
|
if (r.trigger === "hover") {
|
|
7294
|
-
|
|
7313
|
+
Je.current && clearTimeout(Je.current), Je.current = window.setTimeout(() => {
|
|
7295
7314
|
l(e, "hover");
|
|
7296
7315
|
}, r.hoverDelay);
|
|
7297
7316
|
return;
|
|
7298
7317
|
}
|
|
7299
7318
|
}
|
|
7300
|
-
if (
|
|
7301
|
-
let e =
|
|
7302
|
-
e && !e.isPointInEntity(t) &&
|
|
7319
|
+
if (Je.current &&= (clearTimeout(Je.current), null), B?.openedBy === "hover") {
|
|
7320
|
+
let e = R.current.get(B.entityId);
|
|
7321
|
+
e && !e.isPointInEntity(t) && Dt(B.entityId);
|
|
7303
7322
|
}
|
|
7304
7323
|
}, [
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
Lt,
|
|
7324
|
+
I,
|
|
7325
|
+
Pe,
|
|
7326
|
+
B,
|
|
7327
|
+
Dt,
|
|
7310
7328
|
Ht,
|
|
7311
|
-
|
|
7329
|
+
qt,
|
|
7312
7330
|
Zt,
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7331
|
+
nn,
|
|
7332
|
+
sn
|
|
7333
|
+
]), An = useCallback((e) => {
|
|
7334
|
+
if (e.preventDefault(), Mt.current) {
|
|
7335
|
+
Mt.current(null), Mt.current = null, Ft({}), Lt(), rt(null), dn(Nt.current);
|
|
7317
7336
|
return;
|
|
7318
7337
|
}
|
|
7319
|
-
if (
|
|
7320
|
-
if (
|
|
7338
|
+
if (vt.current) return;
|
|
7339
|
+
if (xt.current.length > 0) {
|
|
7321
7340
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7322
|
-
if (
|
|
7323
|
-
|
|
7341
|
+
if (q.current) {
|
|
7342
|
+
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7324
7343
|
return;
|
|
7325
7344
|
}
|
|
7326
|
-
let n =
|
|
7327
|
-
for (let e of
|
|
7328
|
-
let r =
|
|
7345
|
+
let n = L.current?.getZoom() ?? 12;
|
|
7346
|
+
for (let e of xt.current) {
|
|
7347
|
+
let r = R.current.get(e);
|
|
7329
7348
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7330
7349
|
let i = r.getEditHandleAt(t, n);
|
|
7331
7350
|
if (i && i.type === "vertex") {
|
|
@@ -7335,83 +7354,83 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7335
7354
|
}
|
|
7336
7355
|
}
|
|
7337
7356
|
}
|
|
7338
|
-
if (
|
|
7339
|
-
if (
|
|
7357
|
+
if (In.current !== "edit") return;
|
|
7358
|
+
if (Rn.current) {
|
|
7340
7359
|
H(null), U(null), Y();
|
|
7341
7360
|
return;
|
|
7342
7361
|
}
|
|
7343
|
-
let t =
|
|
7362
|
+
let t = zn.current;
|
|
7344
7363
|
if (t === "rectangle") {
|
|
7345
|
-
if (
|
|
7364
|
+
if (Bn.current) ct(null), Ut();
|
|
7346
7365
|
else {
|
|
7347
7366
|
U(null);
|
|
7348
|
-
let e =
|
|
7367
|
+
let e = L.current;
|
|
7349
7368
|
e && (e.getCanvas().style.cursor = "");
|
|
7350
7369
|
}
|
|
7351
7370
|
return;
|
|
7352
7371
|
}
|
|
7353
7372
|
if (t === "circle") {
|
|
7354
|
-
if (
|
|
7373
|
+
if (dt.current) dt.current = null, Jt();
|
|
7355
7374
|
else {
|
|
7356
7375
|
U(null);
|
|
7357
|
-
let e =
|
|
7376
|
+
let e = L.current;
|
|
7358
7377
|
e && (e.getCanvas().style.cursor = "");
|
|
7359
7378
|
}
|
|
7360
7379
|
return;
|
|
7361
7380
|
}
|
|
7362
7381
|
if (t === "polygon") {
|
|
7363
|
-
let e =
|
|
7382
|
+
let e = ft.current;
|
|
7364
7383
|
if (e.length >= 3) {
|
|
7365
|
-
let t =
|
|
7384
|
+
let t = K.current, n = applyEntityConfig({
|
|
7366
7385
|
...t,
|
|
7367
|
-
id: t?.id ??
|
|
7386
|
+
id: t?.id ?? Rt(),
|
|
7368
7387
|
type: "polygon",
|
|
7369
7388
|
coordinates: [...e]
|
|
7370
7389
|
}, D);
|
|
7371
|
-
|
|
7372
|
-
let r =
|
|
7373
|
-
if (r && !
|
|
7374
|
-
let e = new PolygonRenderer(r, n, O, k,
|
|
7375
|
-
|
|
7390
|
+
Qt();
|
|
7391
|
+
let r = L.current;
|
|
7392
|
+
if (r && !R.current.has(n.id)) {
|
|
7393
|
+
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7394
|
+
R.current.set(n.id, e);
|
|
7376
7395
|
}
|
|
7377
|
-
Q.current.onPolygonAdd?.(n),
|
|
7378
|
-
} else if (e.length > 0)
|
|
7396
|
+
Q.current.onPolygonAdd?.(n), ft.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7397
|
+
} else if (e.length > 0) ft.current = [], Qt();
|
|
7379
7398
|
else {
|
|
7380
7399
|
U(null);
|
|
7381
|
-
let e =
|
|
7400
|
+
let e = L.current;
|
|
7382
7401
|
e && (e.getCanvas().style.cursor = "");
|
|
7383
7402
|
}
|
|
7384
7403
|
return;
|
|
7385
7404
|
}
|
|
7386
7405
|
if (t === "square") {
|
|
7387
|
-
if (
|
|
7406
|
+
if (mt.current) mt.current = null, rn();
|
|
7388
7407
|
else {
|
|
7389
7408
|
U(null);
|
|
7390
|
-
let e =
|
|
7409
|
+
let e = L.current;
|
|
7391
7410
|
e && (e.getCanvas().style.cursor = "");
|
|
7392
7411
|
}
|
|
7393
7412
|
return;
|
|
7394
7413
|
}
|
|
7395
7414
|
if (t === "polyline") {
|
|
7396
|
-
let e =
|
|
7415
|
+
let e = gt.current;
|
|
7397
7416
|
if (e.length >= 2) {
|
|
7398
|
-
let t =
|
|
7417
|
+
let t = ht.current, n = applyEntityConfig({
|
|
7399
7418
|
...t,
|
|
7400
|
-
id: t?.id ??
|
|
7419
|
+
id: t?.id ?? Rt(),
|
|
7401
7420
|
type: "polyline",
|
|
7402
7421
|
coordinates: [...e]
|
|
7403
7422
|
}, D);
|
|
7404
|
-
|
|
7405
|
-
let r =
|
|
7406
|
-
if (r && !
|
|
7407
|
-
let e = new PolylineRenderer(r, n, O, k,
|
|
7408
|
-
|
|
7423
|
+
cn();
|
|
7424
|
+
let r = L.current;
|
|
7425
|
+
if (r && !R.current.has(n.id)) {
|
|
7426
|
+
let e = new PolylineRenderer(r, n, O, k, N);
|
|
7427
|
+
R.current.set(n.id, e);
|
|
7409
7428
|
}
|
|
7410
|
-
Q.current.onPolylineAdd?.(n),
|
|
7411
|
-
} else if (e.length > 0)
|
|
7429
|
+
Q.current.onPolylineAdd?.(n), gt.current = [], ht.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7430
|
+
} else if (e.length > 0) gt.current = [], cn();
|
|
7412
7431
|
else {
|
|
7413
7432
|
U(null);
|
|
7414
|
-
let e =
|
|
7433
|
+
let e = L.current;
|
|
7415
7434
|
e && (e.getCanvas().style.cursor = "");
|
|
7416
7435
|
}
|
|
7417
7436
|
return;
|
|
@@ -7419,45 +7438,45 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7419
7438
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7420
7439
|
x: e.point.x,
|
|
7421
7440
|
y: e.point.y
|
|
7422
|
-
}, i =
|
|
7441
|
+
}, i = Nn.current, a = Dn(e.originalEvent.target);
|
|
7423
7442
|
if (a) {
|
|
7424
7443
|
let e = i.find((e) => String(e.id) === a);
|
|
7425
7444
|
if (e) {
|
|
7426
|
-
|
|
7445
|
+
jn(e, r, n);
|
|
7427
7446
|
return;
|
|
7428
7447
|
}
|
|
7429
7448
|
}
|
|
7430
|
-
for (let [t, a] of
|
|
7449
|
+
for (let [t, a] of R.current) {
|
|
7431
7450
|
let o = a.getLabelLayerId();
|
|
7432
|
-
if (o &&
|
|
7451
|
+
if (o && L.current?.getLayer(o) && L.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7433
7452
|
let e = i.find((e) => e.id === t);
|
|
7434
7453
|
if (e) {
|
|
7435
|
-
|
|
7454
|
+
jn(e, r, n);
|
|
7436
7455
|
return;
|
|
7437
7456
|
}
|
|
7438
7457
|
}
|
|
7439
7458
|
}
|
|
7440
|
-
for (let [e, t] of
|
|
7459
|
+
for (let [e, t] of R.current) if (t.isPointInEntity(n)) {
|
|
7441
7460
|
let t = i.find((t) => t.id === e);
|
|
7442
7461
|
if (t) {
|
|
7443
|
-
|
|
7462
|
+
jn(t, r, n);
|
|
7444
7463
|
return;
|
|
7445
7464
|
}
|
|
7446
7465
|
}
|
|
7447
7466
|
}, [
|
|
7448
|
-
|
|
7467
|
+
Dn,
|
|
7449
7468
|
Y,
|
|
7450
|
-
Rt,
|
|
7451
7469
|
Ut,
|
|
7452
|
-
|
|
7470
|
+
Jt,
|
|
7453
7471
|
Qt,
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7472
|
+
rn,
|
|
7473
|
+
cn
|
|
7474
|
+
]), jn = useCallback((e, t, n) => {
|
|
7475
|
+
let r = Ve.current?.getBoundingClientRect(), i = r ? {
|
|
7457
7476
|
x: t.x + r.left,
|
|
7458
7477
|
y: t.y + r.top
|
|
7459
7478
|
} : t;
|
|
7460
|
-
|
|
7479
|
+
Xe({
|
|
7461
7480
|
position: i,
|
|
7462
7481
|
lngLat: n,
|
|
7463
7482
|
items: [{
|
|
@@ -7477,8 +7496,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7477
7496
|
}
|
|
7478
7497
|
}]
|
|
7479
7498
|
});
|
|
7480
|
-
}, []),
|
|
7481
|
-
|
|
7499
|
+
}, []), Mn = useCallback(() => {
|
|
7500
|
+
Xe(null);
|
|
7482
7501
|
}, []);
|
|
7483
7502
|
useEffect(() => {
|
|
7484
7503
|
let e = document.createElement("div");
|
|
@@ -7489,11 +7508,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7489
7508
|
width: 100%;
|
|
7490
7509
|
pointer-events: none;
|
|
7491
7510
|
height: 100%;
|
|
7492
|
-
z-index: ${
|
|
7493
|
-
`, document.body.appendChild(e),
|
|
7511
|
+
z-index: ${I?.zIndex ?? 1e3};
|
|
7512
|
+
`, document.body.appendChild(e), Ke.current = e, () => {
|
|
7494
7513
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7495
7514
|
};
|
|
7496
|
-
}, [
|
|
7515
|
+
}, [I?.zIndex]), useEffect(() => {
|
|
7497
7516
|
let e = document.createElement("div");
|
|
7498
7517
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
7499
7518
|
position: fixed;
|
|
@@ -7502,65 +7521,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7502
7521
|
width: 100%;
|
|
7503
7522
|
pointer-events: none;
|
|
7504
7523
|
height: 100%;
|
|
7505
|
-
z-index: ${(
|
|
7506
|
-
`, document.body.appendChild(e),
|
|
7524
|
+
z-index: ${(I?.zIndex ?? 1e3) + 100};
|
|
7525
|
+
`, document.body.appendChild(e), Ze.current = e, () => {
|
|
7507
7526
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7508
7527
|
};
|
|
7509
|
-
}, [
|
|
7510
|
-
let
|
|
7511
|
-
|
|
7512
|
-
let
|
|
7513
|
-
|
|
7514
|
-
let
|
|
7515
|
-
|
|
7516
|
-
let
|
|
7517
|
-
|
|
7518
|
-
let
|
|
7519
|
-
|
|
7520
|
-
let
|
|
7521
|
-
|
|
7522
|
-
let
|
|
7523
|
-
|
|
7524
|
-
let
|
|
7525
|
-
|
|
7528
|
+
}, [I?.zIndex]);
|
|
7529
|
+
let Nn = useRef(T);
|
|
7530
|
+
Nn.current = T;
|
|
7531
|
+
let Pn = useRef(Ie);
|
|
7532
|
+
Pn.current = Ie;
|
|
7533
|
+
let Fn = useRef(Et);
|
|
7534
|
+
Fn.current = Et;
|
|
7535
|
+
let In = useRef(V);
|
|
7536
|
+
In.current = V;
|
|
7537
|
+
let Ln = useRef(b);
|
|
7538
|
+
Ln.current = b;
|
|
7539
|
+
let Rn = useRef(at);
|
|
7540
|
+
Rn.current = at;
|
|
7541
|
+
let zn = useRef(ot);
|
|
7542
|
+
zn.current = ot;
|
|
7543
|
+
let Bn = useRef(st);
|
|
7544
|
+
Bn.current = st;
|
|
7526
7545
|
let Q = useRef(v);
|
|
7527
7546
|
Q.current = v;
|
|
7528
|
-
let
|
|
7529
|
-
|
|
7547
|
+
let Vn = useRef(D);
|
|
7548
|
+
Vn.current = D, useEffect(() => {
|
|
7530
7549
|
let e = (e) => {
|
|
7531
|
-
if (e.key === "Escape" &&
|
|
7532
|
-
|
|
7550
|
+
if (e.key === "Escape" && q.current) {
|
|
7551
|
+
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7533
7552
|
return;
|
|
7534
7553
|
}
|
|
7535
|
-
if (e.key === "Escape" &&
|
|
7536
|
-
if (at && (H(null), U(null), Y()), ot === "rectangle") if (st) ct(null),
|
|
7554
|
+
if (e.key === "Escape" && V === "edit") {
|
|
7555
|
+
if (at && (H(null), U(null), Y()), ot === "rectangle") if (st) ct(null), Ut();
|
|
7537
7556
|
else {
|
|
7538
7557
|
U(null);
|
|
7539
|
-
let e =
|
|
7558
|
+
let e = L.current;
|
|
7540
7559
|
e && (e.getCanvas().style.cursor = "");
|
|
7541
7560
|
}
|
|
7542
|
-
if (ot === "circle") if (
|
|
7561
|
+
if (ot === "circle") if (dt.current) dt.current = null, Jt();
|
|
7543
7562
|
else {
|
|
7544
7563
|
U(null);
|
|
7545
|
-
let e =
|
|
7564
|
+
let e = L.current;
|
|
7546
7565
|
e && (e.getCanvas().style.cursor = "");
|
|
7547
7566
|
}
|
|
7548
|
-
if (ot === "polygon") if (
|
|
7567
|
+
if (ot === "polygon") if (ft.current.length > 0) ft.current = [], Qt();
|
|
7549
7568
|
else {
|
|
7550
7569
|
U(null);
|
|
7551
|
-
let e =
|
|
7570
|
+
let e = L.current;
|
|
7552
7571
|
e && (e.getCanvas().style.cursor = "");
|
|
7553
7572
|
}
|
|
7554
|
-
if (ot === "square") if (
|
|
7573
|
+
if (ot === "square") if (mt.current) mt.current = null, rn();
|
|
7555
7574
|
else {
|
|
7556
7575
|
U(null);
|
|
7557
|
-
let e =
|
|
7576
|
+
let e = L.current;
|
|
7558
7577
|
e && (e.getCanvas().style.cursor = "");
|
|
7559
7578
|
}
|
|
7560
|
-
if (ot === "polyline") if (
|
|
7579
|
+
if (ot === "polyline") if (gt.current.length > 0) gt.current = [], cn();
|
|
7561
7580
|
else {
|
|
7562
7581
|
U(null);
|
|
7563
|
-
let e =
|
|
7582
|
+
let e = L.current;
|
|
7564
7583
|
e && (e.getCanvas().style.cursor = "");
|
|
7565
7584
|
}
|
|
7566
7585
|
}
|
|
@@ -7569,56 +7588,56 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7569
7588
|
document.removeEventListener("keydown", e);
|
|
7570
7589
|
};
|
|
7571
7590
|
}, [
|
|
7572
|
-
|
|
7591
|
+
V,
|
|
7573
7592
|
at,
|
|
7574
7593
|
ot,
|
|
7575
7594
|
st,
|
|
7576
7595
|
Y,
|
|
7577
|
-
Rt,
|
|
7578
7596
|
Ut,
|
|
7579
|
-
|
|
7597
|
+
Jt,
|
|
7580
7598
|
Qt,
|
|
7581
|
-
|
|
7599
|
+
rn,
|
|
7600
|
+
cn
|
|
7582
7601
|
]), useEffect(() => {
|
|
7583
|
-
let e =
|
|
7584
|
-
if (!e || !
|
|
7585
|
-
let t =
|
|
7586
|
-
let r =
|
|
7602
|
+
let e = L.current;
|
|
7603
|
+
if (!e || !B) return;
|
|
7604
|
+
let t = B.entityId, n = B.config, r = () => {
|
|
7605
|
+
let r = Nn.current.find((e) => e.id === t);
|
|
7587
7606
|
if (!r) {
|
|
7588
|
-
|
|
7607
|
+
Ot();
|
|
7589
7608
|
return;
|
|
7590
7609
|
}
|
|
7591
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7592
|
-
|
|
7610
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, qe.current);
|
|
7611
|
+
qe.current && (qe.current.style.left = `${i.x}px`, qe.current.style.top = `${i.y}px`);
|
|
7593
7612
|
}, i = setTimeout(() => {
|
|
7594
7613
|
r();
|
|
7595
7614
|
}, 50);
|
|
7596
7615
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7597
7616
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7598
7617
|
};
|
|
7599
|
-
}, [
|
|
7600
|
-
let e =
|
|
7601
|
-
if (!e || !
|
|
7602
|
-
let n =
|
|
7618
|
+
}, [B?.entityId, Ot]), useEffect(() => {
|
|
7619
|
+
let e = L.current, t = Ve.current;
|
|
7620
|
+
if (!e || !Ye || !t) return;
|
|
7621
|
+
let n = Ye.lngLat, r = () => {
|
|
7603
7622
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7604
7623
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7605
|
-
|
|
7624
|
+
Mn();
|
|
7606
7625
|
return;
|
|
7607
7626
|
}
|
|
7608
7627
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7609
|
-
|
|
7628
|
+
Qe.current && (Qe.current.style.left = `${s}px`, Qe.current.style.top = `${c}px`);
|
|
7610
7629
|
};
|
|
7611
7630
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7612
7631
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7613
7632
|
};
|
|
7614
|
-
}, [
|
|
7615
|
-
if (!
|
|
7633
|
+
}, [Ye?.lngLat, Mn]), useEffect(() => {
|
|
7634
|
+
if (!Ve.current) return;
|
|
7616
7635
|
let e = {
|
|
7617
7636
|
version: 8,
|
|
7618
7637
|
sources: {},
|
|
7619
7638
|
layers: []
|
|
7620
7639
|
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: m = !0, boxZoom: h = !0 } = x, _ = new mapboxgl.Map({
|
|
7621
|
-
container:
|
|
7640
|
+
container: Ve.current,
|
|
7622
7641
|
style: p || e,
|
|
7623
7642
|
center: l,
|
|
7624
7643
|
zoom: u,
|
|
@@ -7645,98 +7664,98 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7645
7664
|
return { url: e };
|
|
7646
7665
|
}
|
|
7647
7666
|
});
|
|
7648
|
-
return
|
|
7667
|
+
return L.current = _, _.on("load", () => {
|
|
7649
7668
|
if (!_.getStyle().glyphs) {
|
|
7650
7669
|
let e = _.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7651
7670
|
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
7652
7671
|
}
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
}),
|
|
7656
|
-
}), _.on("click",
|
|
7657
|
-
_.off("click",
|
|
7672
|
+
z.current.clear(), T.forEach((e) => {
|
|
7673
|
+
z.current.set(e.id, e);
|
|
7674
|
+
}), En(S), vn(), Vt(), Wt(), Xt(), en(), on(), et(_), Fe?.(_);
|
|
7675
|
+
}), _.on("click", On), _.on("mousemove", kn), _.on("contextmenu", An), () => {
|
|
7676
|
+
_.off("click", On), _.off("mousemove", kn), _.off("contextmenu", An), yn(), Lt(), Y(), X(), Z(), _.remove(), L.current = null;
|
|
7658
7677
|
};
|
|
7659
7678
|
}, []), useEffect(() => {
|
|
7660
|
-
if (
|
|
7661
|
-
if (!
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
}),
|
|
7679
|
+
if (L.current) {
|
|
7680
|
+
if (!L.current.isStyleLoaded()) {
|
|
7681
|
+
L.current.once("load", () => {
|
|
7682
|
+
z.current.clear(), T.forEach((e) => {
|
|
7683
|
+
z.current.set(e.id, e);
|
|
7684
|
+
}), vn();
|
|
7666
7685
|
});
|
|
7667
7686
|
return;
|
|
7668
7687
|
}
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
}),
|
|
7688
|
+
z.current.clear(), T.forEach((e) => {
|
|
7689
|
+
z.current.set(e.id, e);
|
|
7690
|
+
}), vn();
|
|
7672
7691
|
}
|
|
7673
|
-
}, [T,
|
|
7674
|
-
!
|
|
7692
|
+
}, [T, vn]), useEffect(() => {
|
|
7693
|
+
!L.current || !L.current.isStyleLoaded() || (yn(), vn());
|
|
7675
7694
|
}, [
|
|
7676
7695
|
O,
|
|
7677
7696
|
k,
|
|
7697
|
+
j,
|
|
7678
7698
|
M,
|
|
7679
7699
|
N,
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
gn
|
|
7700
|
+
yn,
|
|
7701
|
+
vn
|
|
7683
7702
|
]), useEffect(() => {
|
|
7684
|
-
if (
|
|
7685
|
-
if (!
|
|
7686
|
-
|
|
7687
|
-
|
|
7703
|
+
if (L.current) {
|
|
7704
|
+
if (!L.current.isStyleLoaded()) {
|
|
7705
|
+
L.current.once("load", () => {
|
|
7706
|
+
En(S);
|
|
7688
7707
|
});
|
|
7689
7708
|
return;
|
|
7690
7709
|
}
|
|
7691
|
-
|
|
7692
|
-
}
|
|
7693
|
-
}, [S,
|
|
7694
|
-
let
|
|
7695
|
-
|
|
7696
|
-
let
|
|
7697
|
-
|
|
7698
|
-
let
|
|
7699
|
-
|
|
7700
|
-
let
|
|
7701
|
-
|
|
7702
|
-
let
|
|
7703
|
-
|
|
7704
|
-
let
|
|
7705
|
-
|
|
7706
|
-
let
|
|
7707
|
-
|
|
7708
|
-
let
|
|
7709
|
-
|
|
7710
|
-
let
|
|
7711
|
-
|
|
7712
|
-
let e =
|
|
7710
|
+
En(S);
|
|
7711
|
+
}
|
|
7712
|
+
}, [S, En]);
|
|
7713
|
+
let Hn = useRef(void 0), Un = useRef(!0), Wn = useRef(S);
|
|
7714
|
+
Wn.current = S;
|
|
7715
|
+
let Gn = useRef(En);
|
|
7716
|
+
Gn.current = En;
|
|
7717
|
+
let Kn = useRef(yn);
|
|
7718
|
+
Kn.current = yn;
|
|
7719
|
+
let qn = useRef(vn);
|
|
7720
|
+
qn.current = vn;
|
|
7721
|
+
let Jn = useRef(Vt);
|
|
7722
|
+
Jn.current = Vt;
|
|
7723
|
+
let Yn = useRef(Wt);
|
|
7724
|
+
Yn.current = Wt;
|
|
7725
|
+
let Xn = useRef(Xt);
|
|
7726
|
+
Xn.current = Xt;
|
|
7727
|
+
let Zn = useRef(en);
|
|
7728
|
+
Zn.current = en;
|
|
7729
|
+
let Qn = useRef(on);
|
|
7730
|
+
Qn.current = on, useEffect(() => {
|
|
7731
|
+
let e = L.current;
|
|
7713
7732
|
if (!e) return;
|
|
7714
7733
|
let t = p || {
|
|
7715
7734
|
version: 8,
|
|
7716
7735
|
sources: {},
|
|
7717
7736
|
layers: []
|
|
7718
7737
|
};
|
|
7719
|
-
if (
|
|
7720
|
-
|
|
7738
|
+
if (Un.current) {
|
|
7739
|
+
Un.current = !1, Hn.current = p;
|
|
7721
7740
|
return;
|
|
7722
7741
|
}
|
|
7723
|
-
|
|
7742
|
+
Hn.current !== p && (Hn.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7724
7743
|
if (!e.getStyle().glyphs) {
|
|
7725
7744
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7726
7745
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7727
7746
|
}
|
|
7728
|
-
|
|
7747
|
+
We.current.clear(), Gn.current(Wn.current), Kn.current(), qn.current(), Jn.current(), Yn.current(), Xn.current(), Zn.current(), Qn.current();
|
|
7729
7748
|
}));
|
|
7730
7749
|
}, [p]), useEffect(() => {
|
|
7731
7750
|
let e = new Set(E.map(String));
|
|
7732
|
-
for (let [t, n] of
|
|
7751
|
+
for (let [t, n] of R.current) n.setSelected(e.has(String(t)));
|
|
7733
7752
|
}, [E]);
|
|
7734
|
-
let
|
|
7753
|
+
let $n = useRef({});
|
|
7735
7754
|
useEffect(() => {
|
|
7736
|
-
let e =
|
|
7755
|
+
let e = L.current;
|
|
7737
7756
|
if (!e) return;
|
|
7738
|
-
let t =
|
|
7739
|
-
!n && !r && !i && !a || (
|
|
7757
|
+
let t = $n.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;
|
|
7758
|
+
!n && !r && !i && !a || ($n.current = {
|
|
7740
7759
|
center: l,
|
|
7741
7760
|
zoom: u,
|
|
7742
7761
|
pitch: d,
|
|
@@ -7753,13 +7772,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7753
7772
|
d,
|
|
7754
7773
|
f
|
|
7755
7774
|
]);
|
|
7756
|
-
let
|
|
7757
|
-
if (
|
|
7775
|
+
let er = (() => Ce === !1 ? null : Ce === !0 ? { enabled: !0 } : Ce)(), tr = (() => P === !1 ? null : P === !0 ? { enabled: !0 } : P)(), nr = (() => we === !1 ? null : we === !0 ? { enabled: !0 } : we)(), $ = (() => {
|
|
7776
|
+
if (Te === !1) return null;
|
|
7758
7777
|
let e, t, n;
|
|
7759
7778
|
if (S && S.length > 0) {
|
|
7760
7779
|
let r = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
7761
7780
|
if (r.type === "style") {
|
|
7762
|
-
let t =
|
|
7781
|
+
let t = L.current?.getStyle();
|
|
7763
7782
|
if (t?.sources) {
|
|
7764
7783
|
let n = `base-layer-source-${r.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(n));
|
|
7765
7784
|
i && (e = i);
|
|
@@ -7767,55 +7786,93 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7767
7786
|
} else e = `base-layer-source-${r.id}`;
|
|
7768
7787
|
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7769
7788
|
}
|
|
7770
|
-
return
|
|
7789
|
+
return Te === !0 ? {
|
|
7771
7790
|
enabled: !0,
|
|
7772
7791
|
source: e,
|
|
7773
7792
|
sourceLayer: t,
|
|
7774
7793
|
classField: n
|
|
7775
7794
|
} : {
|
|
7776
|
-
...
|
|
7777
|
-
source:
|
|
7778
|
-
sourceLayer:
|
|
7779
|
-
classField:
|
|
7795
|
+
...Te,
|
|
7796
|
+
source: Te.source || e,
|
|
7797
|
+
sourceLayer: Te.sourceLayer || t,
|
|
7798
|
+
classField: Te.classField || n
|
|
7780
7799
|
};
|
|
7781
|
-
})(),
|
|
7800
|
+
})(), rr = (() => F ? F === !0 ? { enabled: !0 } : F : null)(), ir = (() => De ? De === !0 ? { enabled: !0 } : De : null)(), ar = (() => je || null)(), or = useMemo(() => {
|
|
7782
7801
|
let e = [];
|
|
7783
7802
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7784
|
-
let n =
|
|
7803
|
+
let n = L.current;
|
|
7785
7804
|
if (n) {
|
|
7786
7805
|
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
7787
7806
|
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
7788
7807
|
}
|
|
7789
7808
|
} else e.push(`base-layer-${t.id}`);
|
|
7790
7809
|
return e;
|
|
7791
|
-
}, [S,
|
|
7810
|
+
}, [S, $e]), sr = useMemo(() => {
|
|
7811
|
+
if (V !== "picker") return;
|
|
7812
|
+
let e = J.cursorImage;
|
|
7813
|
+
if (!e) return;
|
|
7814
|
+
let t = e.width ?? 32, n = e.height ?? 32, r = e.anchor ?? "center", i = t / 2, a = n / 2;
|
|
7815
|
+
switch (r) {
|
|
7816
|
+
case "top-left":
|
|
7817
|
+
i = 0, a = 0;
|
|
7818
|
+
break;
|
|
7819
|
+
case "top":
|
|
7820
|
+
i = t / 2, a = 0;
|
|
7821
|
+
break;
|
|
7822
|
+
case "top-right":
|
|
7823
|
+
i = t, a = 0;
|
|
7824
|
+
break;
|
|
7825
|
+
case "left":
|
|
7826
|
+
i = 0, a = n / 2;
|
|
7827
|
+
break;
|
|
7828
|
+
case "center":
|
|
7829
|
+
i = t / 2, a = n / 2;
|
|
7830
|
+
break;
|
|
7831
|
+
case "right":
|
|
7832
|
+
i = t, a = n / 2;
|
|
7833
|
+
break;
|
|
7834
|
+
case "bottom-left":
|
|
7835
|
+
i = 0, a = n;
|
|
7836
|
+
break;
|
|
7837
|
+
case "bottom":
|
|
7838
|
+
i = t / 2, a = n;
|
|
7839
|
+
break;
|
|
7840
|
+
case "bottom-right":
|
|
7841
|
+
i = t, a = n;
|
|
7842
|
+
break;
|
|
7843
|
+
}
|
|
7844
|
+
return `url(${e.url}) ${i} ${a}, crosshair`;
|
|
7845
|
+
}, [V, J.cursorImage]), cr = useMemo(() => sr ? {
|
|
7846
|
+
...Be,
|
|
7847
|
+
"--mapbox-picker-cursor": sr
|
|
7848
|
+
} : Be, [Be, sr]);
|
|
7792
7849
|
return /* @__PURE__ */ jsxs("div", {
|
|
7793
|
-
className: `comp-mapbox ${
|
|
7794
|
-
style:
|
|
7850
|
+
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${ze}`,
|
|
7851
|
+
style: cr,
|
|
7795
7852
|
children: [
|
|
7796
7853
|
/* @__PURE__ */ jsx("div", {
|
|
7797
|
-
ref:
|
|
7854
|
+
ref: Ve,
|
|
7798
7855
|
className: "comp-mapbox__map"
|
|
7799
7856
|
}),
|
|
7800
|
-
|
|
7857
|
+
V === "picker" && J.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
7801
7858
|
className: "comp-mapbox__crosshair",
|
|
7802
7859
|
children: [/* @__PURE__ */ jsx("div", {
|
|
7803
7860
|
className: "comp-mapbox__crosshair-h",
|
|
7804
|
-
style:
|
|
7861
|
+
style: J.crosshairColor ? { backgroundColor: J.crosshairColor } : void 0
|
|
7805
7862
|
}), /* @__PURE__ */ jsx("div", {
|
|
7806
7863
|
className: "comp-mapbox__crosshair-v",
|
|
7807
|
-
style:
|
|
7864
|
+
style: J.crosshairColor ? { backgroundColor: J.crosshairColor } : void 0
|
|
7808
7865
|
})]
|
|
7809
7866
|
}),
|
|
7810
7867
|
/* @__PURE__ */ jsxs("div", {
|
|
7811
|
-
className: `comp-mapbox__edit-controls${
|
|
7868
|
+
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || ar && ar.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
|
|
7812
7869
|
children: [
|
|
7813
|
-
|
|
7870
|
+
V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7814
7871
|
markerTemplates: v.markerTemplates || [],
|
|
7815
7872
|
selectedTemplate: at,
|
|
7816
|
-
onTemplateSelect:
|
|
7873
|
+
onTemplateSelect: ln,
|
|
7817
7874
|
drawMode: ot,
|
|
7818
|
-
onDrawModeChange:
|
|
7875
|
+
onDrawModeChange: un,
|
|
7819
7876
|
showRectangleTool: v.showRectangleTool,
|
|
7820
7877
|
showCircleTool: v.showCircleTool,
|
|
7821
7878
|
showPolygonTool: v.showPolygonTool,
|
|
@@ -7823,8 +7880,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7823
7880
|
showPolylineTool: v.showPolylineTool
|
|
7824
7881
|
}),
|
|
7825
7882
|
/* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7826
|
-
ref:
|
|
7827
|
-
map:
|
|
7883
|
+
ref: Ue,
|
|
7884
|
+
map: $e,
|
|
7828
7885
|
showButton: !!($ && $.enabled !== !1),
|
|
7829
7886
|
highlightWidth: $?.highlightWidth,
|
|
7830
7887
|
defaultRoadTypes: $?.defaultRoadTypes,
|
|
@@ -7835,77 +7892,77 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7835
7892
|
className: $?.className,
|
|
7836
7893
|
style: $?.style
|
|
7837
7894
|
}),
|
|
7838
|
-
|
|
7839
|
-
ref:
|
|
7840
|
-
map:
|
|
7841
|
-
pointCount:
|
|
7842
|
-
showPointCountInput:
|
|
7843
|
-
visualType:
|
|
7844
|
-
onSelectFinished:
|
|
7895
|
+
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7896
|
+
ref: He,
|
|
7897
|
+
map: $e,
|
|
7898
|
+
pointCount: ar.pointCount,
|
|
7899
|
+
showPointCountInput: ar.showPointCountInput,
|
|
7900
|
+
visualType: ar.visualType,
|
|
7901
|
+
onSelectFinished: ar.onSelectFinished
|
|
7845
7902
|
})
|
|
7846
7903
|
]
|
|
7847
7904
|
}),
|
|
7848
|
-
(
|
|
7905
|
+
(er?.enabled !== !1 || tr?.enabled !== !1 || nr?.enabled !== !1 || rr && rr.enabled !== !1 || ir && ir.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7849
7906
|
className: "comp-mapbox__controls",
|
|
7850
7907
|
children: [
|
|
7851
|
-
|
|
7852
|
-
map:
|
|
7853
|
-
precision:
|
|
7854
|
-
className:
|
|
7855
|
-
style:
|
|
7908
|
+
er && er.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7909
|
+
map: $e,
|
|
7910
|
+
precision: er.precision,
|
|
7911
|
+
className: er.className,
|
|
7912
|
+
style: er.style
|
|
7856
7913
|
}),
|
|
7857
|
-
|
|
7858
|
-
map:
|
|
7859
|
-
maxWidth:
|
|
7860
|
-
unit:
|
|
7861
|
-
className:
|
|
7862
|
-
style:
|
|
7914
|
+
tr && tr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7915
|
+
map: $e,
|
|
7916
|
+
maxWidth: tr.maxWidth,
|
|
7917
|
+
unit: tr.unit,
|
|
7918
|
+
className: tr.className,
|
|
7919
|
+
style: tr.style
|
|
7863
7920
|
}),
|
|
7864
|
-
|
|
7865
|
-
map:
|
|
7921
|
+
rr && rr.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7922
|
+
map: $e,
|
|
7866
7923
|
entityConfig: D,
|
|
7867
7924
|
onDrawModeChange: (e) => {
|
|
7868
|
-
|
|
7925
|
+
vt.current = e;
|
|
7869
7926
|
},
|
|
7870
|
-
className:
|
|
7871
|
-
style:
|
|
7927
|
+
className: rr.className,
|
|
7928
|
+
style: rr.style
|
|
7872
7929
|
}),
|
|
7873
|
-
|
|
7874
|
-
map:
|
|
7930
|
+
ir && ir.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7931
|
+
map: $e,
|
|
7875
7932
|
value: C,
|
|
7876
|
-
onChange:
|
|
7877
|
-
rasterPaintLayerIds:
|
|
7878
|
-
className:
|
|
7879
|
-
style:
|
|
7933
|
+
onChange: Me,
|
|
7934
|
+
rasterPaintLayerIds: or,
|
|
7935
|
+
className: ir.className,
|
|
7936
|
+
style: ir.style
|
|
7880
7937
|
}),
|
|
7881
|
-
|
|
7882
|
-
map:
|
|
7938
|
+
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7939
|
+
map: $e,
|
|
7883
7940
|
initialCenter: l,
|
|
7884
7941
|
initialZoom: u,
|
|
7885
7942
|
initialPitch: d,
|
|
7886
7943
|
initialBearing: f,
|
|
7887
|
-
duration:
|
|
7888
|
-
className:
|
|
7889
|
-
style:
|
|
7944
|
+
duration: nr.duration,
|
|
7945
|
+
className: nr.className,
|
|
7946
|
+
style: nr.style
|
|
7890
7947
|
})
|
|
7891
7948
|
]
|
|
7892
7949
|
}),
|
|
7893
|
-
!(
|
|
7894
|
-
ref:
|
|
7895
|
-
map:
|
|
7950
|
+
!(ar && ar.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7951
|
+
ref: He,
|
|
7952
|
+
map: $e,
|
|
7896
7953
|
showButton: !1
|
|
7897
7954
|
}),
|
|
7898
|
-
|
|
7899
|
-
popupState:
|
|
7900
|
-
onClose: () =>
|
|
7901
|
-
portalContainer:
|
|
7902
|
-
popupRef:
|
|
7955
|
+
B && Ke.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7956
|
+
popupState: B,
|
|
7957
|
+
onClose: () => Dt(B.entityId),
|
|
7958
|
+
portalContainer: Ke.current,
|
|
7959
|
+
popupRef: qe
|
|
7903
7960
|
}),
|
|
7904
|
-
|
|
7905
|
-
menuState:
|
|
7906
|
-
onClose:
|
|
7907
|
-
portalContainer:
|
|
7908
|
-
menuRef:
|
|
7961
|
+
Ye && Ze.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7962
|
+
menuState: Ye,
|
|
7963
|
+
onClose: Mn,
|
|
7964
|
+
portalContainer: Ze.current,
|
|
7965
|
+
menuRef: Qe
|
|
7909
7966
|
})
|
|
7910
7967
|
]
|
|
7911
7968
|
});
|