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