bbl-mapbox-react 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BaseCanvasRenderer.d.ts +1 -1
- package/dist/components/CanvasCircleRenderer.d.ts +1 -1
- package/dist/components/MeasureControl.d.ts +5 -2
- package/dist/components/RasterPaintControl.d.ts +15 -0
- package/dist/index.cjs +7 -7
- package/dist/index.css +1 -1
- package/dist/index.mjs +1041 -847
- package/dist/types.d.ts +34 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
2
|
import mapboxgl from "mapbox-gl";
|
|
3
3
|
import * as turf from "@turf/turf";
|
|
4
4
|
import { centroid, polygon } from "@turf/turf";
|
|
5
5
|
import { createRoot } from "react-dom/client";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { Checkbox } from "@arco-design/web-react";
|
|
8
|
+
import { Checkbox, Slider } from "@arco-design/web-react";
|
|
9
9
|
const DEFAULT_NAME_CONFIG = {
|
|
10
10
|
fillColor: "#ffffff",
|
|
11
11
|
fillOpacity: 1,
|
|
@@ -617,8 +617,8 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
617
617
|
}, t.src = e;
|
|
618
618
|
}
|
|
619
619
|
createMarker() {
|
|
620
|
-
let { center: e, src: t, width: n, rotation: r = 0, anchor: i = "center", name: a, confidence:
|
|
621
|
-
this.markerElement = document.createElement("div"), this.markerElement.className = "mapbox-marker-container", this.markerElement.setAttribute("data-entity-id", String(this.entity.id)), this.onBeforeImageCreate(), a && (this.placeholderElement = document.createElement("div"), this.placeholderElement.className = "mapbox-marker-placeholder", this.placeholderElement.textContent = a, this.markerElement.appendChild(this.placeholderElement)), this.imageElement = document.createElement("img"), this.imageElement.src = t, this.imageElement.style.width = `${n}px`, this.imageElement.style.height = `${c}px`, this.imageElement.style.transform = `rotate(${r}deg)`, this.imageElement.style.opacity = `${confidenceToOpacity(
|
|
620
|
+
let { center: e, src: t, width: n, rotation: r = 0, anchor: i = "center", name: a, confidence: o } = this.entity, c = n / this.imageAspectRatio;
|
|
621
|
+
this.markerElement = document.createElement("div"), this.markerElement.className = "mapbox-marker-container", this.markerElement.setAttribute("data-entity-id", String(this.entity.id)), this.onBeforeImageCreate(), a && (this.placeholderElement = document.createElement("div"), this.placeholderElement.className = "mapbox-marker-placeholder", this.placeholderElement.textContent = a, this.markerElement.appendChild(this.placeholderElement)), this.imageElement = document.createElement("img"), this.imageElement.src = t, this.imageElement.style.width = `${n}px`, this.imageElement.style.height = `${c}px`, this.imageElement.style.transform = `rotate(${r}deg)`, this.imageElement.style.opacity = `${confidenceToOpacity(o)}`, this.imageElement.style.pointerEvents = "auto", this.markerElement.appendChild(this.imageElement), a && (this.labelElement = document.createElement("div"), this.labelElement.className = "mapbox-marker-label", this.labelElement.textContent = a, this.labelElement.setAttribute("data-entity-id", String(this.entity.id)), this.updateLabelStyle(), this.markerElement.appendChild(this.labelElement)), this.marker = new mapboxgl.Marker({
|
|
622
622
|
element: this.markerElement,
|
|
623
623
|
anchor: i
|
|
624
624
|
}).setLngLat(e).addTo(this.map), this.onMarkerCreated();
|
|
@@ -2781,19 +2781,19 @@ var RectangleRenderer = class e {
|
|
|
2781
2781
|
this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
2782
2782
|
}
|
|
2783
2783
|
};
|
|
2784
|
-
const EntityPopup = ({ popupState: e, onClose: r, portalContainer:
|
|
2785
|
-
let c = useRef(null), [l, u] = useState("entering"), [
|
|
2784
|
+
const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef: s }) => {
|
|
2785
|
+
let c = useRef(null), [l, u] = useState("entering"), [d, h] = useState(!1), g = useRef(e.position), _ = useRef(!1), v = s || c;
|
|
2786
2786
|
_.current || (g.current = e.position), useEffect(() => {
|
|
2787
2787
|
let e = setTimeout(() => {
|
|
2788
2788
|
h(!0);
|
|
2789
2789
|
}, 60);
|
|
2790
2790
|
return () => clearTimeout(e);
|
|
2791
2791
|
}, []), useEffect(() => {
|
|
2792
|
-
if (l === "entering" &&
|
|
2792
|
+
if (l === "entering" && d) {
|
|
2793
2793
|
let e = setTimeout(() => u("entered"), 50);
|
|
2794
2794
|
return () => clearTimeout(e);
|
|
2795
2795
|
}
|
|
2796
|
-
}, [l,
|
|
2796
|
+
}, [l, d]);
|
|
2797
2797
|
let y = useCallback(() => {
|
|
2798
2798
|
e.config.animation === "none" ? r() : (_.current = !0, u("exiting"), setTimeout(() => r(), 200));
|
|
2799
2799
|
}, [e.config.animation, r]);
|
|
@@ -2818,7 +2818,7 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: o, popupRef:
|
|
|
2818
2818
|
y,
|
|
2819
2819
|
v
|
|
2820
2820
|
]);
|
|
2821
|
-
let
|
|
2821
|
+
let b = () => {
|
|
2822
2822
|
switch (e.actualPosition) {
|
|
2823
2823
|
case "top": return "center bottom";
|
|
2824
2824
|
case "bottom": return "center top";
|
|
@@ -2827,18 +2827,18 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: o, popupRef:
|
|
|
2827
2827
|
case "center":
|
|
2828
2828
|
default: return "center center";
|
|
2829
2829
|
}
|
|
2830
|
-
},
|
|
2830
|
+
}, x = g.current, S = /* @__PURE__ */ jsxs("div", {
|
|
2831
2831
|
ref: v,
|
|
2832
|
-
className: `entity-popup ${
|
|
2832
|
+
className: `entity-popup ${d ? `entity-popup--${l} animation-${e.config.animation}` : ""} ${e.config.className || ""}`,
|
|
2833
2833
|
style: {
|
|
2834
2834
|
position: "fixed",
|
|
2835
|
-
left: `${
|
|
2836
|
-
top: `${
|
|
2835
|
+
left: `${x.x}px`,
|
|
2836
|
+
top: `${x.y}px`,
|
|
2837
2837
|
maxWidth: e.config.maxWidth,
|
|
2838
2838
|
zIndex: e.config.zIndex,
|
|
2839
2839
|
pointerEvents: "all",
|
|
2840
|
-
opacity:
|
|
2841
|
-
transformOrigin:
|
|
2840
|
+
opacity: d ? void 0 : 0,
|
|
2841
|
+
transformOrigin: b(),
|
|
2842
2842
|
...e.config.style
|
|
2843
2843
|
},
|
|
2844
2844
|
role: "dialog",
|
|
@@ -2853,10 +2853,10 @@ const EntityPopup = ({ popupState: e, onClose: r, portalContainer: o, popupRef:
|
|
|
2853
2853
|
children: e.config.content
|
|
2854
2854
|
})]
|
|
2855
2855
|
});
|
|
2856
|
-
return createPortal(
|
|
2856
|
+
return createPortal(S, i);
|
|
2857
2857
|
};
|
|
2858
2858
|
var location_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768373933818'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='30344'%20width='200'%20height='200'%3e%3cpath%20d='M400.440142%201024h-0.073136a48.781895%2048.781895%200%200%201-45.490763-31.448598L3.383306%2066.061072a48.781895%2048.781895%200%200%201%2062.897196-62.897197l926.563466%20351.419801a48.928168%2048.928168%200%200%201%200.219409%2091.127799L597.761811%20597.688654l-151.904042%20395.082157a48.781895%2048.781895%200%200%201-45.490763%2031.229189zM133.053921%20132.907627l267.678766%20705.691916%20113.87318-296.201913a48.855032%2048.855032%200%200%201%2028.011193-27.938057l296.201913-113.87318-705.765052-267.678766z'%20p-id='30345'%20fill='%23ffffff'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e";
|
|
2859
|
-
function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style:
|
|
2859
|
+
function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style: a }) {
|
|
2860
2860
|
let [s, c] = useState(null), l = useCallback((e) => {
|
|
2861
2861
|
c({
|
|
2862
2862
|
lng: Number(e.lngLat.lng.toFixed(r)),
|
|
@@ -2869,7 +2869,7 @@ function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style:
|
|
|
2869
2869
|
};
|
|
2870
2870
|
}, [e, l]), s ? /* @__PURE__ */ jsxs("div", {
|
|
2871
2871
|
className: `mapbox-coordinate-display ${i}`,
|
|
2872
|
-
style:
|
|
2872
|
+
style: a,
|
|
2873
2873
|
children: [/* @__PURE__ */ jsx("img", {
|
|
2874
2874
|
src: location_default,
|
|
2875
2875
|
alt: "location",
|
|
@@ -2887,7 +2887,7 @@ function CoordinateDisplay({ map: e, precision: r = 6, className: i = "", style:
|
|
|
2887
2887
|
}) : null;
|
|
2888
2888
|
}
|
|
2889
2889
|
var scaler_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20t='1768374054549'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20p-id='31504'%20width='200'%20height='200'%3e%3cpath%20d='M53.80096%20687.40096l282.79808%20282.79808%20633.6-633.6-282.79808-282.79808-90.39872%2090.39872-28.29824%2028.20096-42.7008%2042.7008-23.5008%2023.5008-63.20128%2063.19616-12.29824%2012.29824-373.20192%20373.30432z%20m282.79808%20212.10112l-212.10112-212.1984%2054.99904-54.99904%20106.10176%20106.10176%2028.29824-28.29824-106.10176-106.10176%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.69184-70.71232%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.70208%2042.39872-42.39872%20106.10176%20106.10176%2028.29824-28.29824-106.09664-106.10688%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.7072%2042.39872-42.39872%2070.70208%2070.70208%2028.29824-28.29824-70.70208-70.70208%2042.7008-42.7008%20106.10176%20106.10176%2028.29824-28.29824-105.99936-106.10176%2054.99904-54.99904%20212.10112%20212.10112L336.59904%20899.50208z'%20fill='%23ffffff'%20p-id='31505'%20/%3e%3cscript%20xmlns=''%20/%3e%3c/svg%3e";
|
|
2890
|
-
function ScaleControl({ map: e, maxWidth: r = 100, unit: i = "metric", className:
|
|
2890
|
+
function ScaleControl({ map: e, maxWidth: r = 100, unit: i = "metric", className: a = "", style: s }) {
|
|
2891
2891
|
let [c, l] = useState({
|
|
2892
2892
|
width: 100,
|
|
2893
2893
|
label: "100 m"
|
|
@@ -2945,7 +2945,7 @@ function ScaleControl({ map: e, maxWidth: r = 100, unit: i = "metric", className
|
|
|
2945
2945
|
e.off("move", u), e.off("zoom", u);
|
|
2946
2946
|
};
|
|
2947
2947
|
}, [e, u]), /* @__PURE__ */ jsxs("div", {
|
|
2948
|
-
className: `mapbox-scale-control ${
|
|
2948
|
+
className: `mapbox-scale-control ${a}`,
|
|
2949
2949
|
style: s,
|
|
2950
2950
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2951
2951
|
className: "mapbox-scale-control__bar-wrapper",
|
|
@@ -3017,8 +3017,8 @@ function detectVectorSource(e) {
|
|
|
3017
3017
|
};
|
|
3018
3018
|
return null;
|
|
3019
3019
|
}
|
|
3020
|
-
function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
3021
|
-
let [g, _] = useState(!1), [v, y] = useState(
|
|
3020
|
+
function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u, className: d = "", style: f }) {
|
|
3021
|
+
let [g, _] = useState(!1), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(null), C = useRef(null), w = useRef(null), T = useCallback((e, t, n) => {
|
|
3022
3022
|
if (!e.isStyleLoaded()) return !1;
|
|
3023
3023
|
let i = !0;
|
|
3024
3024
|
return ROAD_TYPE_OPTIONS.forEach((a) => {
|
|
@@ -3054,7 +3054,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3054
3054
|
let r = detectVectorSource(e);
|
|
3055
3055
|
r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
|
|
3056
3056
|
}
|
|
3057
|
-
t && n ?
|
|
3057
|
+
t && n ? T(e, t, n) && x(!0) : console.warn("No vector source found for road highlighting");
|
|
3058
3058
|
};
|
|
3059
3059
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
3060
3060
|
let n = () => {
|
|
@@ -3067,9 +3067,9 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3067
3067
|
e,
|
|
3068
3068
|
l,
|
|
3069
3069
|
u,
|
|
3070
|
-
|
|
3070
|
+
T
|
|
3071
3071
|
]), useEffect(() => {
|
|
3072
|
-
!e || !
|
|
3072
|
+
!e || !b || ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
3073
3073
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
3074
3074
|
if (e.getLayer(n)) try {
|
|
3075
3075
|
let r = v.includes(t.class);
|
|
@@ -3080,12 +3080,12 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3080
3080
|
});
|
|
3081
3081
|
}, [
|
|
3082
3082
|
e,
|
|
3083
|
-
|
|
3083
|
+
b,
|
|
3084
3084
|
v
|
|
3085
3085
|
]), useEffect(() => {
|
|
3086
3086
|
if (!g) return;
|
|
3087
3087
|
let e = (e) => {
|
|
3088
|
-
|
|
3088
|
+
S.current && !S.current.contains(e.target) && C.current && !C.current.contains(e.target) && _(!1);
|
|
3089
3089
|
}, t = setTimeout(() => {
|
|
3090
3090
|
document.addEventListener("mousedown", e);
|
|
3091
3091
|
}, 0);
|
|
@@ -3098,20 +3098,20 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3098
3098
|
if (e.getLayer(n)) try {
|
|
3099
3099
|
e.removeLayer(n);
|
|
3100
3100
|
} catch {}
|
|
3101
|
-
}),
|
|
3101
|
+
}), w.current &&= (w.current.remove(), null);
|
|
3102
3102
|
}, [e]);
|
|
3103
|
-
let
|
|
3103
|
+
let E = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), D = useCallback((t) => {
|
|
3104
3104
|
if (!e || v.length === 0) {
|
|
3105
|
-
|
|
3105
|
+
w.current && w.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
|
|
3106
3106
|
return;
|
|
3107
3107
|
}
|
|
3108
3108
|
let n = v.map((e) => `${LAYER_ID_PREFIX}${e}`), r = [[t.point.x - 10, t.point.y - 10], [t.point.x + 10, t.point.y + 10]], i = e.queryRenderedFeatures(r, { layers: n.filter((t) => e.getLayer(t)) });
|
|
3109
3109
|
if (i.length > 0) {
|
|
3110
|
-
let n = i[0].properties || {}, r = t.lngLat, a = n.name || n.name_en || n.name_local || "",
|
|
3111
|
-
m(
|
|
3110
|
+
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 = [];
|
|
3111
|
+
m(o) && h.push(`
|
|
3112
3112
|
<div class="road-highlight-popup__row">
|
|
3113
3113
|
<span>道路类型:</span>
|
|
3114
|
-
<span class="road-highlight-popup__value">${
|
|
3114
|
+
<span class="road-highlight-popup__value">${E(o)}</span>
|
|
3115
3115
|
</div>
|
|
3116
3116
|
`), h.push(`
|
|
3117
3117
|
<div class="road-highlight-popup__row">
|
|
@@ -3160,38 +3160,38 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3160
3160
|
<div class="road-highlight-popup__info">${h.join("")}</div>
|
|
3161
3161
|
</div>
|
|
3162
3162
|
`;
|
|
3163
|
-
|
|
3163
|
+
w.current ||= new mapboxgl.Popup({
|
|
3164
3164
|
closeButton: !1,
|
|
3165
3165
|
closeOnClick: !1,
|
|
3166
3166
|
offset: 15,
|
|
3167
3167
|
className: "road-highlight-popup"
|
|
3168
|
-
}),
|
|
3169
|
-
} else
|
|
3168
|
+
}), w.current.setLngLat(r).setHTML(g).addTo(e), e.getCanvas().style.cursor = "pointer";
|
|
3169
|
+
} else w.current && w.current.remove(), e.getCanvas().style.cursor = "";
|
|
3170
3170
|
}, [
|
|
3171
3171
|
e,
|
|
3172
3172
|
v,
|
|
3173
|
-
|
|
3173
|
+
E
|
|
3174
3174
|
]);
|
|
3175
3175
|
useEffect(() => {
|
|
3176
|
-
if (!(!e || !
|
|
3177
|
-
e.off("mousemove",
|
|
3176
|
+
if (!(!e || !b)) return e.on("mousemove", D), () => {
|
|
3177
|
+
e.off("mousemove", D), w.current && w.current.remove(), e.getCanvas().style.cursor = "";
|
|
3178
3178
|
};
|
|
3179
3179
|
}, [
|
|
3180
3180
|
e,
|
|
3181
|
-
|
|
3182
|
-
|
|
3181
|
+
b,
|
|
3182
|
+
D
|
|
3183
3183
|
]);
|
|
3184
|
-
let
|
|
3184
|
+
let ve = (e, t) => {
|
|
3185
3185
|
y((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
3186
|
-
},
|
|
3186
|
+
}, ye = (e) => {
|
|
3187
3187
|
y(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
|
|
3188
|
-
},
|
|
3188
|
+
}, k = v.length > 0;
|
|
3189
3189
|
return /* @__PURE__ */ jsxs("div", {
|
|
3190
3190
|
className: `mapbox-road-highlight-control ${d}`,
|
|
3191
|
-
style:
|
|
3191
|
+
style: f,
|
|
3192
3192
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
3193
|
-
ref:
|
|
3194
|
-
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${
|
|
3193
|
+
ref: C,
|
|
3194
|
+
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${k ? "mapbox-road-highlight-control__btn--active" : ""}`,
|
|
3195
3195
|
onClick: () => _(!g),
|
|
3196
3196
|
title: `路网高亮${v.length > 0 ? ` (已选 ${v.length})` : ""}`,
|
|
3197
3197
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -3200,7 +3200,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3200
3200
|
className: "mapbox-road-highlight-control__btn-icon"
|
|
3201
3201
|
}), /* @__PURE__ */ jsxs("span", { children: ["路网", v.length > 0 ? ` (${v.length})` : ""] })]
|
|
3202
3202
|
}), g && /* @__PURE__ */ jsxs("div", {
|
|
3203
|
-
ref:
|
|
3203
|
+
ref: S,
|
|
3204
3204
|
className: "mapbox-road-highlight-control__panel",
|
|
3205
3205
|
children: [
|
|
3206
3206
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -3211,7 +3211,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3211
3211
|
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
3212
3212
|
checked: v.length === ROAD_TYPE_OPTIONS.length,
|
|
3213
3213
|
indeterminate: v.length > 0 && v.length < ROAD_TYPE_OPTIONS.length,
|
|
3214
|
-
onChange:
|
|
3214
|
+
onChange: ye,
|
|
3215
3215
|
style: {
|
|
3216
3216
|
"--color-text-1": "#fff",
|
|
3217
3217
|
"--color-border-2": "rgba(255, 255, 255, 0.3)"
|
|
@@ -3228,11 +3228,11 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3228
3228
|
className: "mapbox-road-highlight-control__type-list",
|
|
3229
3229
|
children: ROAD_TYPE_OPTIONS.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
3230
3230
|
className: "mapbox-road-highlight-control__type-item",
|
|
3231
|
-
onClick: () =>
|
|
3231
|
+
onClick: () => ve(e.class, !v.includes(e.class)),
|
|
3232
3232
|
children: [
|
|
3233
3233
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
3234
3234
|
checked: v.includes(e.class),
|
|
3235
|
-
onChange: (t) =>
|
|
3235
|
+
onChange: (t) => ve(e.class, t),
|
|
3236
3236
|
onClick: (e) => e.stopPropagation(),
|
|
3237
3237
|
style: {
|
|
3238
3238
|
"--color-text-1": "#fff",
|
|
@@ -3257,7 +3257,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
|
|
|
3257
3257
|
className: "mapbox-road-highlight-control__tip",
|
|
3258
3258
|
children: "💡 选中道路类型后立即显示高亮"
|
|
3259
3259
|
}),
|
|
3260
|
-
!
|
|
3260
|
+
!b && /* @__PURE__ */ jsx("div", {
|
|
3261
3261
|
className: "mapbox-road-highlight-control__warning",
|
|
3262
3262
|
children: "⚠️ 正在初始化图层..."
|
|
3263
3263
|
})
|
|
@@ -3367,7 +3367,14 @@ function clearPreviewSource(e, t) {
|
|
|
3367
3367
|
features: []
|
|
3368
3368
|
});
|
|
3369
3369
|
}
|
|
3370
|
+
function ensureGlyphs(e) {
|
|
3371
|
+
if (!e.getStyle().glyphs) {
|
|
3372
|
+
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
3373
|
+
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3370
3376
|
function initAllPreviewLayers(e) {
|
|
3377
|
+
ensureGlyphs(e);
|
|
3371
3378
|
for (let t of [
|
|
3372
3379
|
"rect",
|
|
3373
3380
|
"circle",
|
|
@@ -3498,16 +3505,20 @@ function clearAllPreviewSources(e) {
|
|
|
3498
3505
|
"polyline-vertices-source"
|
|
3499
3506
|
]) clearPreviewSource(e, `${PREVIEW_PREFIX}${t}`);
|
|
3500
3507
|
}
|
|
3501
|
-
function MeasureControl({ map: e,
|
|
3502
|
-
let [
|
|
3503
|
-
showArea:
|
|
3504
|
-
showLength:
|
|
3505
|
-
showRadius:
|
|
3506
|
-
}),
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3508
|
+
function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, className: s = "", style: c }) {
|
|
3509
|
+
let [l, u] = useState(!1), [d, f] = useState(null), [g, _] = useState({
|
|
3510
|
+
showArea: !0,
|
|
3511
|
+
showLength: !0,
|
|
3512
|
+
showRadius: !0
|
|
3513
|
+
}), v = r !== void 0, y = v ? {
|
|
3514
|
+
showArea: r.showArea ?? !0,
|
|
3515
|
+
showLength: r.showLength ?? !0,
|
|
3516
|
+
showRadius: r.showRadius ?? !0
|
|
3517
|
+
} : g, [b, x] = useState([]), S = useRef(/* @__PURE__ */ new Map()), C = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), A = useRef([]), j = useRef([]), M = useRef(y);
|
|
3518
|
+
M.current = y;
|
|
3519
|
+
let be = useRef(d);
|
|
3520
|
+
be.current = d;
|
|
3521
|
+
let xe = useCallback(() => `measure-${++C.current}`, []), Se = useRef(!1), Ce = useCallback(() => {
|
|
3511
3522
|
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), Se.current = !0);
|
|
3512
3523
|
}, [e]);
|
|
3513
3524
|
useEffect(() => {
|
|
@@ -3524,31 +3535,31 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3524
3535
|
};
|
|
3525
3536
|
}, [e]), useEffect(() => {
|
|
3526
3537
|
let e = (e) => {
|
|
3527
|
-
|
|
3538
|
+
T.current && !T.current.contains(e.target) && E.current && !E.current.contains(e.target) && u(!1);
|
|
3528
3539
|
};
|
|
3529
3540
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
3530
3541
|
}, []);
|
|
3531
3542
|
let we = useCallback((t) => {
|
|
3532
3543
|
if (!e) return;
|
|
3533
|
-
let n = applyEntityConfig(t,
|
|
3544
|
+
let n = applyEntityConfig(t, M.current), r = null;
|
|
3534
3545
|
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) {
|
|
3535
|
-
|
|
3546
|
+
S.current.set(n.id, r);
|
|
3536
3547
|
let e = {
|
|
3537
3548
|
entity: n,
|
|
3538
3549
|
shapeLabel: SHAPE_LABELS[n.type] || n.type,
|
|
3539
3550
|
area: computeEntityArea(n),
|
|
3540
3551
|
lengthOrRadius: computeEntityLengthOrRadius(n)
|
|
3541
3552
|
};
|
|
3542
|
-
|
|
3553
|
+
x((t) => [...t, e]);
|
|
3543
3554
|
}
|
|
3544
3555
|
}, [e]), Te = useCallback((e) => {
|
|
3545
|
-
let t =
|
|
3546
|
-
t && (t.destroy(),
|
|
3556
|
+
let t = S.current.get(e);
|
|
3557
|
+
t && (t.destroy(), S.current.delete(e)), x((t) => t.filter((t) => t.entity.id !== e));
|
|
3547
3558
|
}, []), Ee = useCallback(() => {
|
|
3548
|
-
|
|
3559
|
+
S.current.forEach((e) => e.destroy()), S.current.clear(), x([]);
|
|
3549
3560
|
}, []), De = useCallback((t) => {
|
|
3550
3561
|
if (!e) return;
|
|
3551
|
-
let n =
|
|
3562
|
+
let n = S.current.get(t);
|
|
3552
3563
|
if (!n) return;
|
|
3553
3564
|
let r = n.getBounds();
|
|
3554
3565
|
e.fitBounds(r, {
|
|
@@ -3557,22 +3568,20 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3557
3568
|
duration: 1e3
|
|
3558
3569
|
});
|
|
3559
3570
|
}, [e]), Oe = useCallback((e, t) => {
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3571
|
+
let n = {
|
|
3572
|
+
...M.current,
|
|
3573
|
+
[e]: t
|
|
3574
|
+
};
|
|
3575
|
+
v ? i?.({ ...n }) : _(n), x((t) => t.map((t) => {
|
|
3576
|
+
let r = { ...t.entity };
|
|
3577
|
+
r[e] = void 0;
|
|
3578
|
+
let i = applyEntityConfig(r, n), a = S.current.get(t.entity.id);
|
|
3579
|
+
return a && a.update(i), {
|
|
3580
|
+
...t,
|
|
3581
|
+
entity: i
|
|
3564
3582
|
};
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
n[e] = void 0;
|
|
3568
|
-
let i = applyEntityConfig(n, r), a = y.current.get(t.entity.id);
|
|
3569
|
-
return a && a.update(i), {
|
|
3570
|
-
...t,
|
|
3571
|
-
entity: i
|
|
3572
|
-
};
|
|
3573
|
-
})), r;
|
|
3574
|
-
});
|
|
3575
|
-
}, []), ke = useCallback((t, n) => {
|
|
3583
|
+
}));
|
|
3584
|
+
}, [v, i]), ke = useCallback((t, n) => {
|
|
3576
3585
|
if (!e) return;
|
|
3577
3586
|
let [r, i] = t, [a, o] = n, s = [
|
|
3578
3587
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -3591,7 +3600,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3591
3600
|
});
|
|
3592
3601
|
let l = e.getSource(`${PREVIEW_PREFIX}rect-preview-measure-source`);
|
|
3593
3602
|
if (l) {
|
|
3594
|
-
let e =
|
|
3603
|
+
let e = M.current, t = [], n = s[0], r = s[1], i = s[2];
|
|
3595
3604
|
if (e?.showArea) {
|
|
3596
3605
|
let e = distance(n, r), a = distance(r, i);
|
|
3597
3606
|
t.push({
|
|
@@ -3633,7 +3642,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3633
3642
|
},
|
|
3634
3643
|
properties: {}
|
|
3635
3644
|
});
|
|
3636
|
-
let o =
|
|
3645
|
+
let o = M.current, s = [], c = [];
|
|
3637
3646
|
if (o?.showArea && s.push({
|
|
3638
3647
|
type: "Feature",
|
|
3639
3648
|
geometry: {
|
|
@@ -3669,7 +3678,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3669
3678
|
type: "FeatureCollection",
|
|
3670
3679
|
features: c
|
|
3671
3680
|
});
|
|
3672
|
-
}, [e]),
|
|
3681
|
+
}, [e]), je = useCallback((t, n) => {
|
|
3673
3682
|
if (!e) return;
|
|
3674
3683
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
3675
3684
|
a && a.setData({
|
|
@@ -3682,7 +3691,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3682
3691
|
});
|
|
3683
3692
|
let o = e.getSource(`${PREVIEW_PREFIX}square-preview-measure-source`);
|
|
3684
3693
|
if (o) {
|
|
3685
|
-
let e =
|
|
3694
|
+
let e = M.current, n = [];
|
|
3686
3695
|
if (e?.showArea && n.push({
|
|
3687
3696
|
type: "Feature",
|
|
3688
3697
|
geometry: {
|
|
@@ -3706,7 +3715,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3706
3715
|
features: n
|
|
3707
3716
|
});
|
|
3708
3717
|
}
|
|
3709
|
-
}, [e]),
|
|
3718
|
+
}, [e]), Me = useCallback((t, n) => {
|
|
3710
3719
|
if (!e) return;
|
|
3711
3720
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
3712
3721
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -3741,7 +3750,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3741
3750
|
});
|
|
3742
3751
|
let o = e.getSource(`${PREVIEW_PREFIX}polygon-preview-measure-source`);
|
|
3743
3752
|
if (o) {
|
|
3744
|
-
let e =
|
|
3753
|
+
let e = M.current, t = [];
|
|
3745
3754
|
if (e?.showArea && r.length >= 3) {
|
|
3746
3755
|
let e = polygonArea([...r, r[0]]), n = 0, i = 0;
|
|
3747
3756
|
for (let e of r) n += e[0], i += e[1];
|
|
@@ -3783,7 +3792,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3783
3792
|
features: t
|
|
3784
3793
|
});
|
|
3785
3794
|
}
|
|
3786
|
-
}, [e]),
|
|
3795
|
+
}, [e]), N = useCallback((t, n) => {
|
|
3787
3796
|
if (!e) return;
|
|
3788
3797
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
3789
3798
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -3811,7 +3820,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3811
3820
|
});
|
|
3812
3821
|
let o = e.getSource(`${PREVIEW_PREFIX}polyline-preview-measure-source`);
|
|
3813
3822
|
if (o) {
|
|
3814
|
-
let e =
|
|
3823
|
+
let e = M.current, t = [];
|
|
3815
3824
|
if (e?.showLength && r.length >= 2) for (let e = 0; e < r.length - 1; e++) {
|
|
3816
3825
|
let n = r[e], i = r[e + 1];
|
|
3817
3826
|
t.push({
|
|
@@ -3830,118 +3839,118 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3830
3839
|
}
|
|
3831
3840
|
}, [e]);
|
|
3832
3841
|
useEffect(() => {
|
|
3833
|
-
if (!e || !
|
|
3842
|
+
if (!e || !d) return;
|
|
3834
3843
|
Ce(), e.getCanvas().style.cursor = "crosshair";
|
|
3835
3844
|
let t = (t) => {
|
|
3836
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
3845
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = be.current;
|
|
3837
3846
|
if (r === "rectangle") {
|
|
3838
|
-
let t =
|
|
3839
|
-
if (!t)
|
|
3847
|
+
let t = D.current;
|
|
3848
|
+
if (!t) D.current = n;
|
|
3840
3849
|
else {
|
|
3841
3850
|
let r = {
|
|
3842
|
-
id:
|
|
3851
|
+
id: xe(),
|
|
3843
3852
|
type: "rectangle",
|
|
3844
3853
|
bounds: [t, n]
|
|
3845
3854
|
};
|
|
3846
|
-
we(r),
|
|
3855
|
+
we(r), D.current = null, clearAllPreviewSources(e), f(null);
|
|
3847
3856
|
}
|
|
3848
3857
|
} else if (r === "circle") {
|
|
3849
|
-
let t =
|
|
3850
|
-
if (!t)
|
|
3858
|
+
let t = O.current;
|
|
3859
|
+
if (!t) O.current = { center: n };
|
|
3851
3860
|
else {
|
|
3852
3861
|
let r = calculateDistance(t.center, n), i = {
|
|
3853
|
-
id:
|
|
3862
|
+
id: xe(),
|
|
3854
3863
|
type: "circle",
|
|
3855
3864
|
center: t.center,
|
|
3856
3865
|
radius: r
|
|
3857
3866
|
};
|
|
3858
|
-
we(i),
|
|
3867
|
+
we(i), O.current = null, clearAllPreviewSources(e), f(null);
|
|
3859
3868
|
}
|
|
3860
3869
|
} else if (r === "square") {
|
|
3861
|
-
let t =
|
|
3862
|
-
if (!t)
|
|
3870
|
+
let t = k.current;
|
|
3871
|
+
if (!t) k.current = { center: n };
|
|
3863
3872
|
else {
|
|
3864
3873
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
3865
|
-
id:
|
|
3874
|
+
id: xe(),
|
|
3866
3875
|
type: "square",
|
|
3867
3876
|
center: t.center,
|
|
3868
3877
|
length: r
|
|
3869
3878
|
};
|
|
3870
|
-
we(i),
|
|
3879
|
+
we(i), k.current = null, clearAllPreviewSources(e), f(null);
|
|
3871
3880
|
}
|
|
3872
3881
|
} else if (r === "polygon") {
|
|
3873
|
-
let t =
|
|
3882
|
+
let t = A.current;
|
|
3874
3883
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
3875
3884
|
let n = {
|
|
3876
|
-
id:
|
|
3885
|
+
id: xe(),
|
|
3877
3886
|
type: "polygon",
|
|
3878
3887
|
coordinates: [...t]
|
|
3879
3888
|
};
|
|
3880
|
-
we(n),
|
|
3889
|
+
we(n), A.current = [], clearAllPreviewSources(e), f(null);
|
|
3881
3890
|
return;
|
|
3882
3891
|
}
|
|
3883
|
-
|
|
3884
|
-
} else r === "polyline" && (
|
|
3892
|
+
A.current = [...t, n];
|
|
3893
|
+
} else r === "polyline" && (j.current = [...j.current, n]);
|
|
3885
3894
|
}, n = (e) => {
|
|
3886
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
3887
|
-
if (n === "rectangle" &&
|
|
3888
|
-
else if (n === "circle" &&
|
|
3889
|
-
else if (n === "square" &&
|
|
3895
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = be.current;
|
|
3896
|
+
if (n === "rectangle" && D.current) ke(D.current, t);
|
|
3897
|
+
else if (n === "circle" && O.current) Ae(O.current.center, t);
|
|
3898
|
+
else if (n === "square" && k.current) je(k.current.center, t);
|
|
3890
3899
|
else if (n === "polygon") {
|
|
3891
|
-
let e =
|
|
3892
|
-
e.length > 0 &&
|
|
3900
|
+
let e = A.current;
|
|
3901
|
+
e.length > 0 && Me(e, t);
|
|
3893
3902
|
} else if (n === "polyline") {
|
|
3894
|
-
let e =
|
|
3895
|
-
e.length > 0 &&
|
|
3903
|
+
let e = j.current;
|
|
3904
|
+
e.length > 0 && N(e, t);
|
|
3896
3905
|
}
|
|
3897
3906
|
}, r = (t) => {
|
|
3898
3907
|
t.preventDefault();
|
|
3899
|
-
let n =
|
|
3908
|
+
let n = be.current;
|
|
3900
3909
|
if (n === "polygon") {
|
|
3901
|
-
let t =
|
|
3910
|
+
let t = A.current;
|
|
3902
3911
|
if (t.length >= 3) {
|
|
3903
3912
|
let n = {
|
|
3904
|
-
id:
|
|
3913
|
+
id: xe(),
|
|
3905
3914
|
type: "polygon",
|
|
3906
3915
|
coordinates: [...t]
|
|
3907
3916
|
};
|
|
3908
|
-
we(n),
|
|
3909
|
-
} else
|
|
3917
|
+
we(n), A.current = [], clearAllPreviewSources(e), f(null);
|
|
3918
|
+
} else A.current = [], clearAllPreviewSources(e);
|
|
3910
3919
|
} else if (n === "polyline") {
|
|
3911
|
-
let t =
|
|
3920
|
+
let t = j.current;
|
|
3912
3921
|
if (t.length >= 2) {
|
|
3913
3922
|
let n = {
|
|
3914
|
-
id:
|
|
3923
|
+
id: xe(),
|
|
3915
3924
|
type: "polyline",
|
|
3916
3925
|
coordinates: [...t]
|
|
3917
3926
|
};
|
|
3918
|
-
we(n),
|
|
3919
|
-
} else
|
|
3927
|
+
we(n), j.current = [], clearAllPreviewSources(e), f(null);
|
|
3928
|
+
} else j.current = [], clearAllPreviewSources(e);
|
|
3920
3929
|
}
|
|
3921
3930
|
}, i = (t) => {
|
|
3922
|
-
t.key === "Escape" && (
|
|
3931
|
+
t.key === "Escape" && (D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], clearAllPreviewSources(e), f(null));
|
|
3923
3932
|
}, a = (t) => {
|
|
3924
3933
|
t.preventDefault();
|
|
3925
|
-
let n =
|
|
3934
|
+
let n = be.current;
|
|
3926
3935
|
if (n === "polygon") {
|
|
3927
|
-
let t =
|
|
3936
|
+
let t = A.current;
|
|
3928
3937
|
if (t.length >= 3) {
|
|
3929
3938
|
let n = {
|
|
3930
|
-
id:
|
|
3939
|
+
id: xe(),
|
|
3931
3940
|
type: "polygon",
|
|
3932
3941
|
coordinates: [...t]
|
|
3933
3942
|
};
|
|
3934
|
-
we(n),
|
|
3943
|
+
we(n), A.current = [], clearAllPreviewSources(e), f(null);
|
|
3935
3944
|
}
|
|
3936
3945
|
} else if (n === "polyline") {
|
|
3937
|
-
let t =
|
|
3946
|
+
let t = j.current;
|
|
3938
3947
|
if (t.length >= 2) {
|
|
3939
3948
|
let n = {
|
|
3940
|
-
id:
|
|
3949
|
+
id: xe(),
|
|
3941
3950
|
type: "polyline",
|
|
3942
3951
|
coordinates: [...t]
|
|
3943
3952
|
};
|
|
3944
|
-
we(n),
|
|
3953
|
+
we(n), j.current = [], clearAllPreviewSources(e), f(null);
|
|
3945
3954
|
}
|
|
3946
3955
|
}
|
|
3947
3956
|
};
|
|
@@ -3950,28 +3959,28 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3950
3959
|
};
|
|
3951
3960
|
}, [
|
|
3952
3961
|
e,
|
|
3953
|
-
|
|
3954
|
-
|
|
3962
|
+
d,
|
|
3963
|
+
xe,
|
|
3955
3964
|
we,
|
|
3956
3965
|
Ce,
|
|
3957
3966
|
ke,
|
|
3958
3967
|
Ae,
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3968
|
+
je,
|
|
3969
|
+
Me,
|
|
3970
|
+
N
|
|
3962
3971
|
]), useEffect(() => () => {
|
|
3963
|
-
|
|
3972
|
+
S.current.forEach((e) => e.destroy()), S.current.clear();
|
|
3964
3973
|
}, []);
|
|
3965
|
-
let
|
|
3966
|
-
|
|
3974
|
+
let Ne = useCallback((t) => {
|
|
3975
|
+
f((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], e && clearAllPreviewSources(e);
|
|
3967
3976
|
}, [e]);
|
|
3968
3977
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
3969
|
-
className: `mapbox-measure-control ${
|
|
3970
|
-
style:
|
|
3978
|
+
className: `mapbox-measure-control ${s}`,
|
|
3979
|
+
style: c,
|
|
3971
3980
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
3972
|
-
ref:
|
|
3973
|
-
className: `mapbox-control-btn mapbox-measure-control__btn ${
|
|
3974
|
-
onClick: () =>
|
|
3981
|
+
ref: E,
|
|
3982
|
+
className: `mapbox-control-btn mapbox-measure-control__btn ${l ? "mapbox-measure-control__btn--active" : ""}`,
|
|
3983
|
+
onClick: () => u(!l),
|
|
3975
3984
|
title: "测量",
|
|
3976
3985
|
children: [
|
|
3977
3986
|
/* @__PURE__ */ jsx("img", {
|
|
@@ -3980,14 +3989,14 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3980
3989
|
className: "mapbox-measure-control__btn-icon"
|
|
3981
3990
|
}),
|
|
3982
3991
|
/* @__PURE__ */ jsx("span", { children: "测量" }),
|
|
3983
|
-
|
|
3992
|
+
b.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
3984
3993
|
"(",
|
|
3985
|
-
|
|
3994
|
+
b.length,
|
|
3986
3995
|
")"
|
|
3987
3996
|
] })
|
|
3988
3997
|
]
|
|
3989
|
-
}),
|
|
3990
|
-
ref:
|
|
3998
|
+
}), l && /* @__PURE__ */ jsxs("div", {
|
|
3999
|
+
ref: T,
|
|
3991
4000
|
className: "mapbox-measure-control__panel",
|
|
3992
4001
|
children: [
|
|
3993
4002
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -3998,17 +4007,17 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
3998
4007
|
className: "mapbox-measure-control__settings",
|
|
3999
4008
|
children: [
|
|
4000
4009
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4001
|
-
checked:
|
|
4010
|
+
checked: y.showArea,
|
|
4002
4011
|
onChange: (e) => Oe("showArea", e),
|
|
4003
4012
|
children: "面积"
|
|
4004
4013
|
}),
|
|
4005
4014
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4006
|
-
checked:
|
|
4015
|
+
checked: y.showLength,
|
|
4007
4016
|
onChange: (e) => Oe("showLength", e),
|
|
4008
4017
|
children: "长度"
|
|
4009
4018
|
}),
|
|
4010
4019
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4011
|
-
checked:
|
|
4020
|
+
checked: y.showRadius,
|
|
4012
4021
|
onChange: (e) => Oe("showRadius", e),
|
|
4013
4022
|
children: "半径"
|
|
4014
4023
|
})
|
|
@@ -4021,14 +4030,14 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
4021
4030
|
/* @__PURE__ */ jsxs("div", {
|
|
4022
4031
|
className: "mapbox-measure-control__tools",
|
|
4023
4032
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
4024
|
-
className: `mapbox-measure-control__tool-btn ${
|
|
4025
|
-
onClick: () =>
|
|
4033
|
+
className: `mapbox-measure-control__tool-btn ${d === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
4034
|
+
onClick: () => Ne(e.mode),
|
|
4026
4035
|
title: e.label,
|
|
4027
4036
|
children: /* @__PURE__ */ jsx("img", {
|
|
4028
4037
|
src: e.icon,
|
|
4029
4038
|
alt: e.label
|
|
4030
4039
|
})
|
|
4031
|
-
}, e.mode)),
|
|
4040
|
+
}, e.mode)), b.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
4032
4041
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
4033
4042
|
onClick: Ee,
|
|
4034
4043
|
title: "清除全部",
|
|
@@ -4038,7 +4047,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
4038
4047
|
})
|
|
4039
4048
|
})]
|
|
4040
4049
|
}),
|
|
4041
|
-
|
|
4050
|
+
b.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
4042
4051
|
className: "mapbox-measure-control__list",
|
|
4043
4052
|
children: /* @__PURE__ */ jsxs("table", {
|
|
4044
4053
|
className: "mapbox-measure-control__table",
|
|
@@ -4048,7 +4057,7 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
4048
4057
|
/* @__PURE__ */ jsx("th", { children: "面积" }),
|
|
4049
4058
|
/* @__PURE__ */ jsx("th", { children: "长度/半径" }),
|
|
4050
4059
|
/* @__PURE__ */ jsx("th", {})
|
|
4051
|
-
] }) }), /* @__PURE__ */ jsx("tbody", { children:
|
|
4060
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: b.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
4052
4061
|
className: "mapbox-measure-control__table-row",
|
|
4053
4062
|
onClick: () => De(e.entity.id),
|
|
4054
4063
|
children: [
|
|
@@ -4078,8 +4087,145 @@ function MeasureControl({ map: e, defaultEntityConfig: r, className: o = "", sty
|
|
|
4078
4087
|
})]
|
|
4079
4088
|
}) : null;
|
|
4080
4089
|
}
|
|
4090
|
+
var raster_paint_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='1773803353422'%20class='icon'%20viewBox='0%200%201028%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6757'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128.5'%20height='128'%3e%3cpath%20d='M835.073959%20357.94044V345.56192a345.170251%20345.170251%200%201%200-686.690426%2049.672777A345.090902%20345.090902%200%200%200%20523.706588%20974.009826a345.090902%20345.090902%200%201%200%20311.049973-616.069386zM490.141757%2048.001359a297.877959%20297.877959%200%200%201%20297.560561%20297.560561c0%207.934948%200%2016.345994-1.031543%2025.074437A297.639911%20297.639911%200%200%201%20490.141757%20643.122482h-15.869897a289.943011%20289.943011%200%200%201-104.106522-24.757039A297.481212%20297.481212%200%200%201%20490.141757%2048.001359zM345.170251%20976.39031a297.560561%20297.560561%200%200%201-185.281043-530.371944c0%201.031543%200.714145%202.142436%201.031544%203.253328s1.50764%204.522921%202.301135%206.824056c1.269592%203.888125%202.697882%207.934948%204.126173%2011.743724%200.952194%202.301135%201.825038%204.60227%202.697882%206.903405%201.58699%203.808775%203.253329%207.934948%204.919668%2011.505675%200.952194%202.142436%201.904388%204.284872%202.935931%206.347958%201.983737%204.284872%204.126173%208.490395%206.268609%2012.695918l2.380485%204.60227c3.01528%205.633813%206.268609%2011.108928%209.601287%2016.504692%200.793495%201.428291%201.745689%202.777232%202.618533%204.126173%202.539183%204.046824%205.157716%207.934948%207.934948%2011.981772l4.205523%205.792512c2.380484%203.253329%204.760969%206.506658%207.220803%209.680637l4.840318%206.030561c2.459834%203.01528%204.999017%205.951211%207.538201%208.887142l5.157717%205.792512c2.777232%203.01528%205.633813%205.951211%208.569744%208.887142l4.840318%204.999018c4.205523%204.046824%208.411045%207.934948%2012.775267%2011.823073l3.09463%202.618533c4.205523%203.650076%208.490395%207.220803%2012.854616%2010.63283l5.713163%204.205523c3.332678%202.459834%206.586007%204.919668%209.998035%207.220803l6.506657%204.364222q4.999017%203.332678%209.998035%206.427308c2.221786%201.348941%204.443571%202.697882%206.744706%203.967474%203.570727%202.142436%207.300152%204.126173%2010.950229%206.10991l6.18926%203.253329%202.301135%201.269592v12.378519c0%207.379502%200%2014.759004%200.793494%2021.979807%200%202.459834%200.396747%204.840318%200.634796%207.220803%200%204.840318%200.793495%209.759986%201.428291%2014.600305%200%202.777232%200.872844%205.554464%201.269592%208.411045%200.714145%204.364222%201.428291%208.728443%202.221785%2013.013315%200.555446%202.935931%201.190242%205.871862%201.825038%208.728443%200.952194%204.205523%201.904388%207.934948%203.015281%2012.457869s1.50764%205.871862%202.380484%208.728443%202.380484%207.934948%203.729426%2012.140471c0.952194%202.856581%201.825038%205.633813%202.856581%208.490395%201.428291%204.046824%203.01528%207.934948%204.60227%2012.061121%201.110893%202.618533%202.142436%205.316415%203.253329%207.934948%201.825038%204.284872%203.729426%208.411045%205.713163%2012.537219%201.110893%202.301135%202.142436%204.681619%203.332678%206.903405%202.618533%205.316415%205.475114%2010.474132%208.411045%2015.869896%200.555446%201.110893%201.110893%202.221786%201.745689%203.332679%203.570727%206.10991%207.379502%2012.061121%2011.346976%2018.012332%201.269592%201.904388%202.697882%203.808775%204.046824%205.713163%202.777232%203.967474%205.475114%207.934948%208.411045%2011.664374%201.745689%202.301135%203.570727%204.443571%205.395765%206.744706s5.316415%206.586007%207.934948%209.839336%204.046824%204.60227%206.10991%206.824056%205.633813%206.030561%208.490395%209.045841l6.744706%206.586007c2.935931%202.856581%205.871862%205.633813%208.966492%207.934948s4.681619%204.205523%207.062104%206.268609%206.427308%205.316415%209.759986%207.934948%204.760969%203.888125%207.300152%205.713163l2.380485%201.904388A295.894222%20295.894222%200%200%201%20345.170251%20976.39031z%20m335.965711-11.981772a296.608368%20296.608368%200%200%201-146.479145-38.563848c-5.792512-3.332678-11.426326-6.744706-16.90144-10.315433-1.825038-1.190242-3.491377-2.539183-5.237066-3.729426-3.650076-2.459834-7.300152-4.999017-10.79153-7.934948-2.063087-1.50764-3.967474-3.173979-5.871862-4.760969-3.173979-2.459834-6.268609-4.919668-9.283889-7.934949s-3.967474-3.650076-5.951211-5.475114-5.633813-5.078367-7.934949-7.934948-3.808775-4.046824-5.792512-6.10991-5.078367-5.157716-7.458851-7.934949l-5.554464-6.506657c-1.825038-2.142436-4.60227-5.475114-6.824056-7.934949s-3.412028-4.681619-5.157716-7.062104-4.205523-5.633813-6.10991-8.490394-3.253329-4.999017-4.840319-7.458852-3.729426-5.792512-5.475114-8.807792-2.935931-5.157716-4.364222-7.934949-3.332678-6.030561-4.919668-9.045841-2.539183-5.395765-3.808775-7.934948-2.935931-6.18926-4.284872-9.363239-2.301135-5.554464-3.412028-8.411045-2.459834-6.268609-3.570726-9.521938-1.983737-5.792512-2.856582-8.649094-2.063087-6.506658-3.01528-9.759986-1.58699-5.951211-2.301135-8.887142-1.666339-6.586007-2.380485-9.918686S388.812467%20722.471965%20388.812467%20719.536034s-1.190242-6.665357-1.666339-9.998035-0.793495-6.18926-1.110893-9.28389-0.793495-6.824056-1.031543-10.236083%200-6.268609-0.555447-9.363239v-6.665357h0.396748l2.142436%200.634796c4.364222%201.428291%208.807793%202.697882%2013.251363%203.967474l4.840319%201.269592%2011.505675%202.697883%204.52292%201.031543c5.237066%201.031543%2010.474132%201.983737%2015.869897%202.856581h1.348941c4.840318%200.793495%209.759986%201.348941%2014.600305%201.904388l4.919668%200.476097q5.951211%200.634796%2011.902422%200.952194H490.855902a344.456106%20344.456106%200%200%200%20183.138607-52.529358c5.395765-3.412028%2010.71218-7.062104%2015.869896-10.71218%201.745689-1.190242%203.332678-2.539183%205.078367-3.729426%203.412028-2.539183%206.903405-5.157716%2010.236084-7.934948l5.713162-4.760969c3.01528-2.459834%206.030561-4.999017%208.966492-7.934949l5.633813-5.237066c2.856581-2.618533%205.554464-5.237066%207.934949-7.934948l5.475114-5.633813c2.618533-2.697882%205.237066-5.475114%207.934948-8.331696l5.078367-5.713163%207.458851-9.045841%204.522921-5.633813%207.934948-10.315433%203.570727-4.999017c3.173979-4.60227%206.268609-9.363239%209.20454-14.203558l1.031543-1.586989c3.332678-5.475114%206.506658-11.029578%209.601288-16.663392%200.634796-1.190242%201.190242-2.380484%201.745688-3.570727%202.301135-4.443571%204.60227-8.887142%206.665357-13.410062%200.872844-1.825038%201.666339-3.729426%202.539183-5.554464%201.745689-3.967474%203.491377-7.934948%205.078367-11.902422%200.793495-2.063087%201.58699-4.205523%202.459834-6.347959%201.428291-3.808775%202.856581-7.934948%204.126173-11.505675%200.793495-2.221786%201.50764-4.522921%202.221786-6.744706%201.190242-3.808775%202.380484-7.934948%203.491377-11.585025%200.634796-2.301135%201.269592-4.60227%201.825038-6.903405%201.031543-3.967474%201.904388-7.934948%202.777232-11.902422%200.555446-2.301135%201.031543-4.522921%201.50764-6.824056%200-1.031543%200.476097-2.142436%200.634796-3.173979a297.560561%20297.560561%200%200%201-148.304183%20555.446381z'%20fill='%23ffffff'%20p-id='6758'%3e%3c/path%3e%3c/svg%3e", DEFAULT_CONFIG = {
|
|
4091
|
+
brightness: 1,
|
|
4092
|
+
saturation: 0,
|
|
4093
|
+
contrast: 0,
|
|
4094
|
+
hueRotate: 0
|
|
4095
|
+
}, SLIDER_CONFIG = [
|
|
4096
|
+
{
|
|
4097
|
+
key: "brightness",
|
|
4098
|
+
label: "亮度",
|
|
4099
|
+
min: 0,
|
|
4100
|
+
max: 1,
|
|
4101
|
+
step: .01
|
|
4102
|
+
},
|
|
4103
|
+
{
|
|
4104
|
+
key: "saturation",
|
|
4105
|
+
label: "饱和度",
|
|
4106
|
+
min: -1,
|
|
4107
|
+
max: 1,
|
|
4108
|
+
step: .01
|
|
4109
|
+
},
|
|
4110
|
+
{
|
|
4111
|
+
key: "contrast",
|
|
4112
|
+
label: "对比度",
|
|
4113
|
+
min: -1,
|
|
4114
|
+
max: 1,
|
|
4115
|
+
step: .01
|
|
4116
|
+
},
|
|
4117
|
+
{
|
|
4118
|
+
key: "hueRotate",
|
|
4119
|
+
label: "色相",
|
|
4120
|
+
min: 0,
|
|
4121
|
+
max: 360,
|
|
4122
|
+
step: 1
|
|
4123
|
+
}
|
|
4124
|
+
];
|
|
4125
|
+
function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds: c = [], className: l, style: u }) {
|
|
4126
|
+
let [d, f] = useState(!1), [h, _] = useState({ ...DEFAULT_CONFIG }), v = useRef(null), y = useRef(null), b = r !== void 0;
|
|
4127
|
+
useEffect(() => {
|
|
4128
|
+
let e = (e) => {
|
|
4129
|
+
v.current && !v.current.contains(e.target) && y.current && !y.current.contains(e.target) && f(!1);
|
|
4130
|
+
};
|
|
4131
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4132
|
+
}, []);
|
|
4133
|
+
let x = useMemo(() => b ? {
|
|
4134
|
+
brightness: r.brightness ?? DEFAULT_CONFIG.brightness,
|
|
4135
|
+
saturation: r.saturation ?? DEFAULT_CONFIG.saturation,
|
|
4136
|
+
contrast: r.contrast ?? DEFAULT_CONFIG.contrast,
|
|
4137
|
+
hueRotate: r.hueRotate ?? DEFAULT_CONFIG.hueRotate
|
|
4138
|
+
} : h, [
|
|
4139
|
+
b,
|
|
4140
|
+
r,
|
|
4141
|
+
h
|
|
4142
|
+
]), S = useRef(b);
|
|
4143
|
+
useEffect(() => {
|
|
4144
|
+
b && !S.current && _({ ...x }), S.current = b;
|
|
4145
|
+
}, [b, x]);
|
|
4146
|
+
let C = useCallback((t) => {
|
|
4147
|
+
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));
|
|
4148
|
+
}, [e, c]), w = useCallback((e, t) => {
|
|
4149
|
+
if (b) s?.({
|
|
4150
|
+
...x,
|
|
4151
|
+
[e]: t
|
|
4152
|
+
});
|
|
4153
|
+
else {
|
|
4154
|
+
let n = {
|
|
4155
|
+
...h,
|
|
4156
|
+
[e]: t
|
|
4157
|
+
};
|
|
4158
|
+
_(n), C(n);
|
|
4159
|
+
}
|
|
4160
|
+
}, [
|
|
4161
|
+
b,
|
|
4162
|
+
s,
|
|
4163
|
+
x,
|
|
4164
|
+
h,
|
|
4165
|
+
C
|
|
4166
|
+
]), T = useCallback(() => {
|
|
4167
|
+
b ? s?.({ ...DEFAULT_CONFIG }) : (_({ ...DEFAULT_CONFIG }), C({ ...DEFAULT_CONFIG }));
|
|
4168
|
+
}, [
|
|
4169
|
+
b,
|
|
4170
|
+
s,
|
|
4171
|
+
C
|
|
4172
|
+
]);
|
|
4173
|
+
useEffect(() => {
|
|
4174
|
+
!b && c.length > 0 && C(h);
|
|
4175
|
+
}, [
|
|
4176
|
+
c,
|
|
4177
|
+
b,
|
|
4178
|
+
C,
|
|
4179
|
+
h
|
|
4180
|
+
]);
|
|
4181
|
+
let E = (e, t) => e === "hueRotate" ? `${Math.round(t)}°` : t.toFixed(2);
|
|
4182
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4183
|
+
className: `mapbox-raster-paint-control${l ? ` ${l}` : ""}`,
|
|
4184
|
+
style: u,
|
|
4185
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
4186
|
+
ref: y,
|
|
4187
|
+
className: `mapbox-control-btn mapbox-raster-paint-control__btn${d ? " mapbox-raster-paint-control__btn--active" : ""}`,
|
|
4188
|
+
onClick: () => f(!d),
|
|
4189
|
+
title: "栅格渲染调节",
|
|
4190
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
4191
|
+
className: "mapbox-control-btn__icon mapbox-raster-paint-control__btn-icon",
|
|
4192
|
+
src: raster_paint_default,
|
|
4193
|
+
alt: "raster paint"
|
|
4194
|
+
}), /* @__PURE__ */ jsx("span", { children: "渲染" })]
|
|
4195
|
+
}), d && /* @__PURE__ */ jsxs("div", {
|
|
4196
|
+
ref: v,
|
|
4197
|
+
className: "mapbox-raster-paint-control__panel",
|
|
4198
|
+
children: [SLIDER_CONFIG.map(({ key: e, label: t, min: n, max: r, step: i }) => /* @__PURE__ */ jsxs("div", {
|
|
4199
|
+
className: "mapbox-raster-paint-control__slider-row",
|
|
4200
|
+
children: [
|
|
4201
|
+
/* @__PURE__ */ jsx("span", {
|
|
4202
|
+
className: "mapbox-raster-paint-control__label",
|
|
4203
|
+
children: t
|
|
4204
|
+
}),
|
|
4205
|
+
/* @__PURE__ */ jsx(Slider, {
|
|
4206
|
+
className: "mapbox-raster-paint-control__slider",
|
|
4207
|
+
min: n,
|
|
4208
|
+
max: r,
|
|
4209
|
+
step: i,
|
|
4210
|
+
value: x[e],
|
|
4211
|
+
onChange: (t) => w(e, t),
|
|
4212
|
+
tooltipVisible: !1
|
|
4213
|
+
}),
|
|
4214
|
+
/* @__PURE__ */ jsx("span", {
|
|
4215
|
+
className: "mapbox-raster-paint-control__value",
|
|
4216
|
+
children: E(e, x[e])
|
|
4217
|
+
})
|
|
4218
|
+
]
|
|
4219
|
+
}, e)), /* @__PURE__ */ jsx("button", {
|
|
4220
|
+
className: "mapbox-raster-paint-control__reset",
|
|
4221
|
+
onClick: T,
|
|
4222
|
+
children: "重置"
|
|
4223
|
+
})]
|
|
4224
|
+
})]
|
|
4225
|
+
});
|
|
4226
|
+
}
|
|
4081
4227
|
var marker_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769397418113'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10253'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M755.4048%20217.2928A348.3648%20348.3648%200%200%200%20512%20119.3472a348.3136%20348.3136%200%200%200-243.3536%2097.8944%20328.4992%20328.4992%200%200%200-100.864%20236.3392c0%2049.408%2011.7248%2095.744%2032%20137.728a378.0096%20378.0096%200%200%200%2091.136%20118.4256l203.5712%20179.456%2017.5104%2015.4624%2017.5104-15.4624%20203.4176-179.3536a378.6752%20378.6752%200%200%200%2091.2384-118.4768c20.2752-41.984%2032.0512-88.32%2032.0512-137.7792a328.448%20328.448%200%200%200-100.8128-236.288z%20m24.1152%20353.3824a329.216%20329.216%200%200%201-79.872%20103.0656l-188.0064%20164.6592-187.1872-164.7616a329.0624%20329.0624%200%200%201-79.7696-103.0144%20267.0592%20267.0592%200%200%201-27.136-117.0944c0-78.7968%2032.9728-150.1184%2086.272-201.728a298.3936%20298.3936%200%200%201%20208.2816-83.5584c81.3056%200%20154.9824%2031.9488%20208.2304%2083.6096a279.9104%20279.9104%200%200%201%2086.272%20201.728%20266.496%20266.496%200%200%201-27.0848%20117.0944z%20m-164.1472-212.1728l0.0512-0.0512a146.9952%20146.9952%200%200%200-104.2432-43.2128c-40.6528%200-77.568%2016.5376-104.2432%2043.2128l0.0512%200.0512a147.3536%20147.3536%200%200%200-0.0512%20208.6912%20147.0464%20147.0464%200%200%200%20208.4864%200%20147.5072%20147.5072%200%200%200-0.0512-208.6912z%20m-34.1504%20174.2336a97.536%2097.536%200%200%201-69.2736%2028.7232%2097.6384%2097.6384%200%200%201-69.3248-28.7232%2097.792%2097.792%200%200%201-0.1536-138.4448h0.1024a97.9456%2097.9456%200%200%201%20138.5984%200h0.1536c17.664%2017.6128%2028.5696%2042.1376%2028.5696%2069.2224a97.1776%2097.1776%200%200%201-28.672%2069.2224z'%20fill='%23ffffff'%20p-id='10254'%3e%3c/path%3e%3c/svg%3e";
|
|
4082
|
-
const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect: r, drawMode:
|
|
4228
|
+
const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect: r, drawMode: i, onDrawModeChange: s, showRectangleTool: c = !1, showCircleTool: l = !1, showPolygonTool: u = !1, showSquareTool: d = !1, showPolylineTool: f = !1 }) => {
|
|
4083
4229
|
let [h, g] = useState(!1), _ = useRef(null);
|
|
4084
4230
|
useEffect(() => {
|
|
4085
4231
|
let e = (e) => {
|
|
@@ -4090,24 +4236,24 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4090
4236
|
let v = (e) => {
|
|
4091
4237
|
t?.id === e.id ? (r(null), s(null)) : (r(e), s("marker")), g(!1);
|
|
4092
4238
|
}, y = () => {
|
|
4093
|
-
|
|
4094
|
-
}, ge = () => {
|
|
4095
|
-
o === "circle" ? s(null) : (r(null), s("circle"));
|
|
4239
|
+
i === "rectangle" ? s(null) : (r(null), s("rectangle"));
|
|
4096
4240
|
}, b = () => {
|
|
4097
|
-
|
|
4098
|
-
}, _e = () => {
|
|
4099
|
-
o === "square" ? s(null) : (r(null), s("square"));
|
|
4241
|
+
i === "circle" ? s(null) : (r(null), s("circle"));
|
|
4100
4242
|
}, x = () => {
|
|
4101
|
-
|
|
4243
|
+
i === "polygon" ? s(null) : (r(null), s("polygon"));
|
|
4102
4244
|
}, S = () => {
|
|
4103
|
-
|
|
4104
|
-
}, C = (
|
|
4245
|
+
i === "square" ? s(null) : (r(null), s("square"));
|
|
4246
|
+
}, C = () => {
|
|
4247
|
+
i === "polyline" ? s(null) : (r(null), s("polyline"));
|
|
4248
|
+
}, w = () => {
|
|
4249
|
+
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), g(!h);
|
|
4250
|
+
}, T = (e) => e.size ? {
|
|
4105
4251
|
width: e.size,
|
|
4106
4252
|
height: e.size
|
|
4107
4253
|
} : {
|
|
4108
4254
|
width: e.width || 32,
|
|
4109
4255
|
height: e.height || 32
|
|
4110
|
-
},
|
|
4256
|
+
}, E = h || t, D = i === "rectangle", O = i === "circle", ve = i === "polygon", ye = i === "square", k = i === "polyline";
|
|
4111
4257
|
return /* @__PURE__ */ jsxs("div", {
|
|
4112
4258
|
ref: _,
|
|
4113
4259
|
className: "mapbox-edit-control",
|
|
@@ -4115,8 +4261,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4115
4261
|
className: "mapbox-edit-control__btn-group",
|
|
4116
4262
|
children: [
|
|
4117
4263
|
/* @__PURE__ */ jsxs("button", {
|
|
4118
|
-
className: `mapbox-control-btn ${
|
|
4119
|
-
onClick:
|
|
4264
|
+
className: `mapbox-control-btn ${E ? "mapbox-control-btn--active" : ""}`,
|
|
4265
|
+
onClick: w,
|
|
4120
4266
|
title: "Marker",
|
|
4121
4267
|
children: [t ? /* @__PURE__ */ jsx("img", {
|
|
4122
4268
|
src: t.icon,
|
|
@@ -4129,8 +4275,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4129
4275
|
}), /* @__PURE__ */ jsx("span", { children: t ? t.name : "Marker" })]
|
|
4130
4276
|
}),
|
|
4131
4277
|
d && /* @__PURE__ */ jsxs("button", {
|
|
4132
|
-
className: `mapbox-control-btn ${
|
|
4133
|
-
onClick:
|
|
4278
|
+
className: `mapbox-control-btn ${ye ? "mapbox-control-btn--active" : ""}`,
|
|
4279
|
+
onClick: S,
|
|
4134
4280
|
title: "绘制正方形",
|
|
4135
4281
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4136
4282
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e",
|
|
@@ -4139,7 +4285,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4139
4285
|
}), /* @__PURE__ */ jsx("span", { children: "正方形" })]
|
|
4140
4286
|
}),
|
|
4141
4287
|
c && /* @__PURE__ */ jsxs("button", {
|
|
4142
|
-
className: `mapbox-control-btn ${
|
|
4288
|
+
className: `mapbox-control-btn ${D ? "mapbox-control-btn--active" : ""}`,
|
|
4143
4289
|
onClick: y,
|
|
4144
4290
|
title: "绘制矩形",
|
|
4145
4291
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -4149,8 +4295,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4149
4295
|
}), /* @__PURE__ */ jsx("span", { children: "矩形" })]
|
|
4150
4296
|
}),
|
|
4151
4297
|
l && /* @__PURE__ */ jsxs("button", {
|
|
4152
|
-
className: `mapbox-control-btn ${
|
|
4153
|
-
onClick:
|
|
4298
|
+
className: `mapbox-control-btn ${O ? "mapbox-control-btn--active" : ""}`,
|
|
4299
|
+
onClick: b,
|
|
4154
4300
|
title: "绘制圆形",
|
|
4155
4301
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4156
4302
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e",
|
|
@@ -4159,8 +4305,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4159
4305
|
}), /* @__PURE__ */ jsx("span", { children: "圆形" })]
|
|
4160
4306
|
}),
|
|
4161
4307
|
u && /* @__PURE__ */ jsxs("button", {
|
|
4162
|
-
className: `mapbox-control-btn ${
|
|
4163
|
-
onClick:
|
|
4308
|
+
className: `mapbox-control-btn ${ve ? "mapbox-control-btn--active" : ""}`,
|
|
4309
|
+
onClick: x,
|
|
4164
4310
|
title: "绘制多边形",
|
|
4165
4311
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4166
4312
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e",
|
|
@@ -4168,9 +4314,9 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4168
4314
|
className: "mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg"
|
|
4169
4315
|
}), /* @__PURE__ */ jsx("span", { children: "多边形" })]
|
|
4170
4316
|
}),
|
|
4171
|
-
|
|
4172
|
-
className: `mapbox-control-btn ${
|
|
4173
|
-
onClick:
|
|
4317
|
+
f && /* @__PURE__ */ jsxs("button", {
|
|
4318
|
+
className: `mapbox-control-btn ${k ? "mapbox-control-btn--active" : ""}`,
|
|
4319
|
+
onClick: C,
|
|
4174
4320
|
title: "绘制折线",
|
|
4175
4321
|
children: [/* @__PURE__ */ jsx("img", {
|
|
4176
4322
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e",
|
|
@@ -4187,7 +4333,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4187
4333
|
}), /* @__PURE__ */ jsx("div", {
|
|
4188
4334
|
className: "mapbox-edit-control__template-list",
|
|
4189
4335
|
children: e.map((e) => {
|
|
4190
|
-
let n =
|
|
4336
|
+
let n = T(e), r = t?.id === e.id;
|
|
4191
4337
|
return /* @__PURE__ */ jsxs("div", {
|
|
4192
4338
|
className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
|
|
4193
4339
|
onClick: () => v(e),
|
|
@@ -4209,7 +4355,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4209
4355
|
})]
|
|
4210
4356
|
})]
|
|
4211
4357
|
});
|
|
4212
|
-
}, ContextMenu = ({ menuState: e, onClose: r, portalContainer:
|
|
4358
|
+
}, ContextMenu = ({ menuState: e, onClose: r, portalContainer: i, menuRef: o }) => {
|
|
4213
4359
|
let s = useRef(null);
|
|
4214
4360
|
useEffect(() => (o && (o.current = s.current), () => {
|
|
4215
4361
|
o && (o.current = null);
|
|
@@ -4232,7 +4378,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4232
4378
|
let e = s.current.getBoundingClientRect();
|
|
4233
4379
|
u.x + e.width > window.innerWidth && (u.x = window.innerWidth - e.width - 10), u.y + e.height > window.innerHeight && (u.y = window.innerHeight - e.height - 10);
|
|
4234
4380
|
}
|
|
4235
|
-
let
|
|
4381
|
+
let d = /* @__PURE__ */ jsx("div", {
|
|
4236
4382
|
ref: s,
|
|
4237
4383
|
className: "context-menu",
|
|
4238
4384
|
style: {
|
|
@@ -4255,7 +4401,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4255
4401
|
})]
|
|
4256
4402
|
}, e.key))
|
|
4257
4403
|
});
|
|
4258
|
-
return createPortal(
|
|
4404
|
+
return createPortal(d, i);
|
|
4259
4405
|
};
|
|
4260
4406
|
function mergePopupConfig(e, t, n) {
|
|
4261
4407
|
return {
|
|
@@ -4403,52 +4549,52 @@ function adjustPopupForBounds(e, t) {
|
|
|
4403
4549
|
}, r = { ...e };
|
|
4404
4550
|
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;
|
|
4405
4551
|
}
|
|
4406
|
-
const Mapbox = forwardRef((e,
|
|
4407
|
-
let { center:
|
|
4552
|
+
const Mapbox = forwardRef((e, c) => {
|
|
4553
|
+
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: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: A, circleConfig: j, lengthConfig: M, showCoordinates: be = !0, showScale: Se = !0, showResetView: Ee = !0, showRoadHighlight: De = !1, showMeasure: Oe = !1, showRasterPaint: Ae = !1, onRasterPaintChange: je, popupDefaults: N, renderPopup: Pe, onMapLoad: Fe, onEntityClick: Ie, onPopupOpen: Le, onPopupClose: Re, className: ze = "", containerStyle: Be } = e, Ve = useRef(null), P = useRef(null), F = useRef(/* @__PURE__ */ new Map()), I = useRef(/* @__PURE__ */ new Map()), He = useRef(/* @__PURE__ */ new Set()), [L, Ue] = useState(null), We = useRef(null), Ge = useRef(null), Ke = useRef(null), [qe, Je] = useState(null), Ye = useRef(null), Xe = useRef(null), [Ze, Qe] = useState(null), [R, $e] = useState(_), [et, tt] = useState(null), nt = useRef(null), [rt, z] = useState(null), [it, B] = useState(null), [at, ot] = useState(null), V = useRef(!1), H = useRef(null), U = useRef(null), W = useRef(null), st = useRef(null), G = useRef(null), ct = useRef([]), K = useRef(null), lt = useRef(null), q = useRef(null), ut = useRef([]), J = useRef(null);
|
|
4408
4554
|
useEffect(() => {
|
|
4409
|
-
|
|
4410
|
-
}, [
|
|
4411
|
-
let
|
|
4412
|
-
let t =
|
|
4555
|
+
$e(_);
|
|
4556
|
+
}, [_]);
|
|
4557
|
+
let dt = useCallback((e) => {
|
|
4558
|
+
let t = F.current.get(e), n = I.current.get(e);
|
|
4413
4559
|
if (t && n) {
|
|
4414
4560
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
4415
4561
|
let r = {
|
|
4416
4562
|
...n,
|
|
4417
4563
|
isAnimating: !0
|
|
4418
4564
|
};
|
|
4419
|
-
|
|
4565
|
+
I.current.set(e, r), t.startAnimation();
|
|
4420
4566
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
4421
4567
|
let r = {
|
|
4422
4568
|
...n,
|
|
4423
4569
|
isAnimating: !0
|
|
4424
4570
|
};
|
|
4425
|
-
|
|
4571
|
+
I.current.set(e, r), t.startAnimation();
|
|
4426
4572
|
}
|
|
4427
4573
|
}
|
|
4428
|
-
}, []),
|
|
4429
|
-
let t =
|
|
4574
|
+
}, []), ft = useCallback((e) => {
|
|
4575
|
+
let t = F.current.get(e), n = I.current.get(e);
|
|
4430
4576
|
if (t && n) {
|
|
4431
4577
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
4432
4578
|
let r = {
|
|
4433
4579
|
...n,
|
|
4434
4580
|
isAnimating: !1
|
|
4435
4581
|
};
|
|
4436
|
-
|
|
4582
|
+
I.current.set(e, r), t.stopAnimation();
|
|
4437
4583
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
4438
4584
|
let r = {
|
|
4439
4585
|
...n,
|
|
4440
4586
|
isAnimating: !1
|
|
4441
4587
|
};
|
|
4442
|
-
|
|
4588
|
+
I.current.set(e, r), t.stopAnimation();
|
|
4443
4589
|
}
|
|
4444
4590
|
}
|
|
4445
|
-
}, []),
|
|
4446
|
-
let t =
|
|
4447
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
4448
|
-
}, [
|
|
4591
|
+
}, []), pt = useCallback((e) => {
|
|
4592
|
+
let t = I.current.get(e);
|
|
4593
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? ft(e) : dt(e));
|
|
4594
|
+
}, [dt, ft]), mt = useCallback((e) => {
|
|
4449
4595
|
if (e === void 0) {
|
|
4450
4596
|
let e = !1;
|
|
4451
|
-
for (let [, t] of
|
|
4597
|
+
for (let [, t] of F.current) if (t instanceof UnitRenderer) {
|
|
4452
4598
|
let n = t.getShowTrajectory();
|
|
4453
4599
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
4454
4600
|
e = !0;
|
|
@@ -4456,46 +4602,46 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4456
4602
|
}
|
|
4457
4603
|
}
|
|
4458
4604
|
let t = e ? 0 : "all";
|
|
4459
|
-
for (let [, e] of
|
|
4605
|
+
for (let [, e] of F.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
4460
4606
|
} else {
|
|
4461
4607
|
let t = new Set(e.map(String));
|
|
4462
|
-
for (let [e, n] of
|
|
4608
|
+
for (let [e, n] of F.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
4463
4609
|
}
|
|
4464
|
-
}, []),
|
|
4465
|
-
let r =
|
|
4466
|
-
if (!r?.popup || !
|
|
4467
|
-
let i = r.popup.content ??
|
|
4610
|
+
}, []), ht = useCallback((e, t, n) => {
|
|
4611
|
+
let r = T.find((t) => String(t.id) === String(e));
|
|
4612
|
+
if (!r?.popup || !P.current) return;
|
|
4613
|
+
let i = r.popup.content ?? Pe?.(r);
|
|
4468
4614
|
if (!i) return;
|
|
4469
|
-
let a = mergePopupConfig(r.popup,
|
|
4470
|
-
|
|
4615
|
+
let a = mergePopupConfig(r.popup, N, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, P.current, n);
|
|
4616
|
+
Ue({
|
|
4471
4617
|
entityId: e,
|
|
4472
4618
|
position: o,
|
|
4473
4619
|
config: a,
|
|
4474
4620
|
openedBy: t,
|
|
4475
4621
|
actualPosition: s
|
|
4476
|
-
}),
|
|
4622
|
+
}), Le?.(e);
|
|
4477
4623
|
}, [
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
]),
|
|
4483
|
-
|
|
4484
|
-
}, [
|
|
4485
|
-
|
|
4486
|
-
}, [
|
|
4487
|
-
let r =
|
|
4624
|
+
T,
|
|
4625
|
+
N,
|
|
4626
|
+
Pe,
|
|
4627
|
+
Le
|
|
4628
|
+
]), gt = useCallback((e) => {
|
|
4629
|
+
L?.entityId === e && (Ue(null), Re?.(e));
|
|
4630
|
+
}, [L, Re]), _t = useCallback(() => {
|
|
4631
|
+
Ue((e) => (e && Re?.(e.entityId), null));
|
|
4632
|
+
}, [Re]), vt = useCallback((e) => L?.entityId === e, [L]), yt = useCallback((e, t, n) => {
|
|
4633
|
+
let r = P.current;
|
|
4488
4634
|
r && r.flyTo({
|
|
4489
4635
|
center: e,
|
|
4490
4636
|
zoom: t ?? r.getZoom(),
|
|
4491
4637
|
...n
|
|
4492
4638
|
});
|
|
4493
|
-
}, []),
|
|
4494
|
-
let r =
|
|
4639
|
+
}, []), bt = useCallback((e, t, n) => {
|
|
4640
|
+
let r = P.current;
|
|
4495
4641
|
if (!r || e.length === 0) return;
|
|
4496
4642
|
let i = [];
|
|
4497
4643
|
for (let t of e) {
|
|
4498
|
-
let e =
|
|
4644
|
+
let e = F.current.get(t);
|
|
4499
4645
|
e && i.push(e.getBounds());
|
|
4500
4646
|
}
|
|
4501
4647
|
if (i.length === 0) return;
|
|
@@ -4517,82 +4663,88 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4517
4663
|
pitch: n?.pitch ?? r.getPitch()
|
|
4518
4664
|
};
|
|
4519
4665
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
4520
|
-
}, []),
|
|
4521
|
-
let t =
|
|
4666
|
+
}, []), xt = useCallback((e) => {
|
|
4667
|
+
let t = P.current;
|
|
4522
4668
|
if (!t || !t.getContainer()) return;
|
|
4523
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff" } =
|
|
4669
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff" } = y;
|
|
4524
4670
|
if (!n) {
|
|
4525
|
-
|
|
4671
|
+
nt.current &&= (nt.current.remove(), null);
|
|
4526
4672
|
return;
|
|
4527
4673
|
}
|
|
4528
|
-
if (
|
|
4674
|
+
if (nt.current) nt.current.setLngLat(e);
|
|
4529
4675
|
else {
|
|
4530
4676
|
let n = document.createElement("div");
|
|
4531
4677
|
n.className = "mapbox-picker-marker";
|
|
4532
4678
|
let i = document.createElement("div");
|
|
4533
|
-
i.className = "marker-inner", i.style.background = r, n.appendChild(i),
|
|
4679
|
+
i.className = "marker-inner", i.style.background = r, n.appendChild(i), nt.current = new mapboxgl.Marker({
|
|
4534
4680
|
element: n,
|
|
4535
4681
|
anchor: "bottom"
|
|
4536
4682
|
}).setLngLat(e).addTo(t);
|
|
4537
4683
|
}
|
|
4538
|
-
}, [
|
|
4539
|
-
|
|
4540
|
-
}, []),
|
|
4541
|
-
let t =
|
|
4542
|
-
if (
|
|
4684
|
+
}, [y]), St = useCallback(() => {
|
|
4685
|
+
nt.current &&= (nt.current.remove(), null);
|
|
4686
|
+
}, []), Ct = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), wt = useCallback((e) => {
|
|
4687
|
+
let t = P.current;
|
|
4688
|
+
if (Ve.current) if (J.current &&= (J.current.remove(), null), e && t) {
|
|
4543
4689
|
t.getCanvas().style.cursor = "none";
|
|
4544
4690
|
let n = document.createElement("div");
|
|
4545
4691
|
n.className = "mapbox-custom-cursor";
|
|
4546
4692
|
let r = e.size || e.width || 32;
|
|
4547
4693
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
4548
4694
|
let i = document.createElement("img");
|
|
4549
|
-
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),
|
|
4695
|
+
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), J.current = n;
|
|
4550
4696
|
let a = (e) => {
|
|
4551
|
-
|
|
4697
|
+
J.current && (J.current.style.left = `${e.clientX}px`, J.current.style.top = `${e.clientY}px`);
|
|
4552
4698
|
};
|
|
4553
4699
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
4554
4700
|
document.removeEventListener("mousemove", a);
|
|
4555
4701
|
};
|
|
4556
4702
|
} else t && (t.getCanvas().style.cursor = "");
|
|
4557
|
-
}, []),
|
|
4558
|
-
if (
|
|
4559
|
-
let e =
|
|
4560
|
-
e && e(),
|
|
4703
|
+
}, []), Y = useCallback(() => {
|
|
4704
|
+
if (J.current) {
|
|
4705
|
+
let e = J.current._cleanup;
|
|
4706
|
+
e && e(), J.current.remove(), J.current = null;
|
|
4561
4707
|
}
|
|
4562
|
-
let e =
|
|
4708
|
+
let e = P.current;
|
|
4563
4709
|
e && (e.getCanvas().style.cursor = "");
|
|
4564
|
-
}, []),
|
|
4565
|
-
e.getSource(t)
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
features: []
|
|
4570
|
-
}
|
|
4571
|
-
}), e.addLayer({
|
|
4572
|
-
id: n,
|
|
4573
|
-
type: "symbol",
|
|
4574
|
-
source: t,
|
|
4575
|
-
filter: [
|
|
4576
|
-
"==",
|
|
4577
|
-
"$type",
|
|
4578
|
-
"Point"
|
|
4579
|
-
],
|
|
4580
|
-
layout: {
|
|
4581
|
-
"text-field": ["get", "label"],
|
|
4582
|
-
"text-size": 12,
|
|
4583
|
-
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
4584
|
-
"text-allow-overlap": !0,
|
|
4585
|
-
"text-rotation-alignment": "map",
|
|
4586
|
-
"text-offset": [0, -.8]
|
|
4587
|
-
},
|
|
4588
|
-
paint: {
|
|
4589
|
-
"text-color": "#ffffff",
|
|
4590
|
-
"text-halo-color": "rgba(0, 0, 0, 0.8)",
|
|
4591
|
-
"text-halo-width": 1
|
|
4710
|
+
}, []), X = useCallback((e, t, n) => {
|
|
4711
|
+
if (!e.getSource(t)) {
|
|
4712
|
+
if (!e.getStyle().glyphs) {
|
|
4713
|
+
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
4714
|
+
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
4592
4715
|
}
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4716
|
+
e.addSource(t, {
|
|
4717
|
+
type: "geojson",
|
|
4718
|
+
data: {
|
|
4719
|
+
type: "FeatureCollection",
|
|
4720
|
+
features: []
|
|
4721
|
+
}
|
|
4722
|
+
}), e.addLayer({
|
|
4723
|
+
id: n,
|
|
4724
|
+
type: "symbol",
|
|
4725
|
+
source: t,
|
|
4726
|
+
filter: [
|
|
4727
|
+
"==",
|
|
4728
|
+
"$type",
|
|
4729
|
+
"Point"
|
|
4730
|
+
],
|
|
4731
|
+
layout: {
|
|
4732
|
+
"text-field": ["get", "label"],
|
|
4733
|
+
"text-size": 12,
|
|
4734
|
+
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
4735
|
+
"text-allow-overlap": !0,
|
|
4736
|
+
"text-rotation-alignment": "map",
|
|
4737
|
+
"text-offset": [0, -.8]
|
|
4738
|
+
},
|
|
4739
|
+
paint: {
|
|
4740
|
+
"text-color": "#ffffff",
|
|
4741
|
+
"text-halo-color": "rgba(0, 0, 0, 0.8)",
|
|
4742
|
+
"text-halo-width": 1
|
|
4743
|
+
}
|
|
4744
|
+
});
|
|
4745
|
+
}
|
|
4746
|
+
}, []), Tt = useCallback(() => {
|
|
4747
|
+
let e = P.current;
|
|
4596
4748
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
4597
4749
|
type: "geojson",
|
|
4598
4750
|
data: {
|
|
@@ -4616,9 +4768,9 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4616
4768
|
"line-width": 2,
|
|
4617
4769
|
"line-dasharray": [4, 4]
|
|
4618
4770
|
}
|
|
4619
|
-
}),
|
|
4620
|
-
}, [
|
|
4621
|
-
let n =
|
|
4771
|
+
}), X(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
4772
|
+
}, [X]), Et = useCallback((e, t) => {
|
|
4773
|
+
let n = P.current;
|
|
4622
4774
|
if (!n) return;
|
|
4623
4775
|
let r = n.getSource("rect-preview-source");
|
|
4624
4776
|
if (!r) return;
|
|
@@ -4637,11 +4789,11 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4637
4789
|
},
|
|
4638
4790
|
properties: {}
|
|
4639
4791
|
});
|
|
4640
|
-
let l =
|
|
4792
|
+
let l = H.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
4641
4793
|
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));
|
|
4642
4794
|
let m = n.getSource("rect-preview-measure-source");
|
|
4643
4795
|
if (m) {
|
|
4644
|
-
let e =
|
|
4796
|
+
let e = Tn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
4645
4797
|
if (e?.showArea) {
|
|
4646
4798
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
4647
4799
|
t.push({
|
|
@@ -4678,8 +4830,8 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4678
4830
|
features: t
|
|
4679
4831
|
});
|
|
4680
4832
|
}
|
|
4681
|
-
}, []),
|
|
4682
|
-
let e =
|
|
4833
|
+
}, []), Dt = useCallback(() => {
|
|
4834
|
+
let e = P.current;
|
|
4683
4835
|
if (!e) return;
|
|
4684
4836
|
let t = e.getSource("rect-preview-source");
|
|
4685
4837
|
t && t.setData({
|
|
@@ -4691,10 +4843,10 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4691
4843
|
type: "FeatureCollection",
|
|
4692
4844
|
features: []
|
|
4693
4845
|
});
|
|
4694
|
-
}, []),
|
|
4695
|
-
|
|
4696
|
-
}, [
|
|
4697
|
-
let e =
|
|
4846
|
+
}, []), Z = useCallback(() => {
|
|
4847
|
+
ot(null), Dt();
|
|
4848
|
+
}, [Dt]), Ot = useCallback(() => {
|
|
4849
|
+
let e = P.current;
|
|
4698
4850
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
4699
4851
|
type: "geojson",
|
|
4700
4852
|
data: {
|
|
@@ -4718,7 +4870,7 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4718
4870
|
"line-width": 2,
|
|
4719
4871
|
"line-dasharray": [4, 4]
|
|
4720
4872
|
}
|
|
4721
|
-
}),
|
|
4873
|
+
}), X(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
4722
4874
|
type: "geojson",
|
|
4723
4875
|
data: {
|
|
4724
4876
|
type: "FeatureCollection",
|
|
@@ -4735,22 +4887,22 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4735
4887
|
"line-dasharray": [4, 4]
|
|
4736
4888
|
}
|
|
4737
4889
|
}))));
|
|
4738
|
-
}, [
|
|
4890
|
+
}, [X]), kt = useCallback((e, t, n = 64) => {
|
|
4739
4891
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
4740
4892
|
for (let e = 0; e <= n; e++) {
|
|
4741
4893
|
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;
|
|
4742
4894
|
a.push([d, u]);
|
|
4743
4895
|
}
|
|
4744
4896
|
return a;
|
|
4745
|
-
}, []),
|
|
4897
|
+
}, []), At = useCallback((e, t) => {
|
|
4746
4898
|
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);
|
|
4747
4899
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
4748
|
-
}, []),
|
|
4749
|
-
let n =
|
|
4900
|
+
}, []), jt = useCallback((e, t) => {
|
|
4901
|
+
let n = P.current;
|
|
4750
4902
|
if (!n) return;
|
|
4751
4903
|
let r = n.getSource("circle-preview-source");
|
|
4752
4904
|
if (!r) return;
|
|
4753
|
-
let i =
|
|
4905
|
+
let i = At(e, t), a = kt(e, i);
|
|
4754
4906
|
r.setData({
|
|
4755
4907
|
type: "Feature",
|
|
4756
4908
|
geometry: {
|
|
@@ -4759,9 +4911,9 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4759
4911
|
},
|
|
4760
4912
|
properties: {}
|
|
4761
4913
|
});
|
|
4762
|
-
let o =
|
|
4914
|
+
let o = W.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
4763
4915
|
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));
|
|
4764
|
-
let d =
|
|
4916
|
+
let d = Tn.current, f = [], p = [];
|
|
4765
4917
|
if (d?.showArea) {
|
|
4766
4918
|
let t = Math.PI * i * i;
|
|
4767
4919
|
f.push({
|
|
@@ -4774,7 +4926,7 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4774
4926
|
});
|
|
4775
4927
|
}
|
|
4776
4928
|
if (d?.showRadius) {
|
|
4777
|
-
let t =
|
|
4929
|
+
let t = W.current?.radiusAngle ?? 90, n = destinationPoint(e, i, t), r = [(e[0] + n[0]) / 2, (e[1] + n[1]) / 2];
|
|
4778
4930
|
p.push({
|
|
4779
4931
|
type: "Feature",
|
|
4780
4932
|
geometry: {
|
|
@@ -4801,8 +4953,8 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4801
4953
|
type: "FeatureCollection",
|
|
4802
4954
|
features: p
|
|
4803
4955
|
});
|
|
4804
|
-
}, [
|
|
4805
|
-
let e =
|
|
4956
|
+
}, [At, kt]), Mt = useCallback(() => {
|
|
4957
|
+
let e = P.current;
|
|
4806
4958
|
if (!e) return;
|
|
4807
4959
|
let t = e.getSource("circle-preview-source");
|
|
4808
4960
|
t && t.setData({
|
|
@@ -4819,10 +4971,10 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4819
4971
|
type: "FeatureCollection",
|
|
4820
4972
|
features: []
|
|
4821
4973
|
});
|
|
4822
|
-
}, []),
|
|
4823
|
-
|
|
4824
|
-
}, [
|
|
4825
|
-
let e =
|
|
4974
|
+
}, []), Nt = useCallback(() => {
|
|
4975
|
+
st.current = null, Mt();
|
|
4976
|
+
}, [Mt]), Pt = useCallback(() => {
|
|
4977
|
+
let e = P.current;
|
|
4826
4978
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
4827
4979
|
type: "geojson",
|
|
4828
4980
|
data: {
|
|
@@ -4862,9 +5014,9 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4862
5014
|
"circle-stroke-color": "#ffffff",
|
|
4863
5015
|
"circle-stroke-width": 2
|
|
4864
5016
|
}
|
|
4865
|
-
}),
|
|
4866
|
-
}, [
|
|
4867
|
-
let n =
|
|
5017
|
+
}), X(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
5018
|
+
}, [X]), Ft = useCallback((e, t) => {
|
|
5019
|
+
let n = P.current;
|
|
4868
5020
|
if (!n) return;
|
|
4869
5021
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
4870
5022
|
if (!r || !i) return;
|
|
@@ -4901,11 +5053,11 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4901
5053
|
properties: {}
|
|
4902
5054
|
}))
|
|
4903
5055
|
});
|
|
4904
|
-
let o =
|
|
5056
|
+
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
4905
5057
|
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);
|
|
4906
5058
|
let d = n.getSource("polygon-preview-measure-source");
|
|
4907
5059
|
if (d) {
|
|
4908
|
-
let e =
|
|
5060
|
+
let e = Tn.current, t = [];
|
|
4909
5061
|
if (e?.showArea && a.length >= 3) {
|
|
4910
5062
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
4911
5063
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -4947,8 +5099,8 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4947
5099
|
features: t
|
|
4948
5100
|
});
|
|
4949
5101
|
}
|
|
4950
|
-
}, []),
|
|
4951
|
-
let e =
|
|
5102
|
+
}, []), It = useCallback(() => {
|
|
5103
|
+
let e = P.current;
|
|
4952
5104
|
if (!e) return;
|
|
4953
5105
|
let t = e.getSource("polygon-preview-source");
|
|
4954
5106
|
t && t.setData({
|
|
@@ -4965,10 +5117,10 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4965
5117
|
type: "FeatureCollection",
|
|
4966
5118
|
features: []
|
|
4967
5119
|
});
|
|
4968
|
-
}, []),
|
|
4969
|
-
|
|
4970
|
-
}, [
|
|
4971
|
-
let e =
|
|
5120
|
+
}, []), Lt = useCallback(() => {
|
|
5121
|
+
ct.current = [], It();
|
|
5122
|
+
}, [It]), Rt = useCallback(() => {
|
|
5123
|
+
let e = P.current;
|
|
4972
5124
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
4973
5125
|
type: "geojson",
|
|
4974
5126
|
data: {
|
|
@@ -4992,8 +5144,8 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
4992
5144
|
"line-width": 2,
|
|
4993
5145
|
"line-dasharray": [4, 4]
|
|
4994
5146
|
}
|
|
4995
|
-
}),
|
|
4996
|
-
}, [
|
|
5147
|
+
}), X(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
5148
|
+
}, [X]), zt = useCallback((e, t) => {
|
|
4997
5149
|
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);
|
|
4998
5150
|
return [
|
|
4999
5151
|
[n - s, r + o],
|
|
@@ -5002,12 +5154,12 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5002
5154
|
[n - s, r - o],
|
|
5003
5155
|
[n - s, r + o]
|
|
5004
5156
|
];
|
|
5005
|
-
}, []),
|
|
5006
|
-
let n =
|
|
5157
|
+
}, []), Bt = useCallback((e, t) => {
|
|
5158
|
+
let n = P.current;
|
|
5007
5159
|
if (!n) return;
|
|
5008
5160
|
let r = n.getSource("square-preview-source");
|
|
5009
5161
|
if (!r) return;
|
|
5010
|
-
let i =
|
|
5162
|
+
let i = At(e, t) * 2, a = zt(e, i);
|
|
5011
5163
|
r.setData({
|
|
5012
5164
|
type: "Feature",
|
|
5013
5165
|
geometry: {
|
|
@@ -5016,11 +5168,11 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5016
5168
|
},
|
|
5017
5169
|
properties: {}
|
|
5018
5170
|
});
|
|
5019
|
-
let o =
|
|
5171
|
+
let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
5020
5172
|
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));
|
|
5021
5173
|
let d = n.getSource("square-preview-measure-source");
|
|
5022
5174
|
if (d) {
|
|
5023
|
-
let t =
|
|
5175
|
+
let t = Tn.current, n = [];
|
|
5024
5176
|
if (t?.showArea && n.push({
|
|
5025
5177
|
type: "Feature",
|
|
5026
5178
|
geometry: {
|
|
@@ -5044,8 +5196,8 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5044
5196
|
features: n
|
|
5045
5197
|
});
|
|
5046
5198
|
}
|
|
5047
|
-
}, [
|
|
5048
|
-
let e =
|
|
5199
|
+
}, [At, zt]), Vt = useCallback(() => {
|
|
5200
|
+
let e = P.current;
|
|
5049
5201
|
if (!e) return;
|
|
5050
5202
|
let t = e.getSource("square-preview-source");
|
|
5051
5203
|
t && t.setData({
|
|
@@ -5057,10 +5209,10 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5057
5209
|
type: "FeatureCollection",
|
|
5058
5210
|
features: []
|
|
5059
5211
|
});
|
|
5060
|
-
}, []),
|
|
5061
|
-
|
|
5062
|
-
}, [
|
|
5063
|
-
let e =
|
|
5212
|
+
}, []), Ht = useCallback(() => {
|
|
5213
|
+
lt.current = null, Vt();
|
|
5214
|
+
}, [Vt]), Ut = useCallback(() => {
|
|
5215
|
+
let e = P.current;
|
|
5064
5216
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
5065
5217
|
type: "geojson",
|
|
5066
5218
|
data: {
|
|
@@ -5092,9 +5244,9 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5092
5244
|
"circle-stroke-color": "#ffffff",
|
|
5093
5245
|
"circle-stroke-width": 2
|
|
5094
5246
|
}
|
|
5095
|
-
}),
|
|
5096
|
-
}, [
|
|
5097
|
-
let n =
|
|
5247
|
+
}), X(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
5248
|
+
}, [X]), Wt = useCallback((e, t) => {
|
|
5249
|
+
let n = P.current;
|
|
5098
5250
|
if (!n) return;
|
|
5099
5251
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
5100
5252
|
if (!r || !i) return;
|
|
@@ -5120,11 +5272,11 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5120
5272
|
properties: {}
|
|
5121
5273
|
}))
|
|
5122
5274
|
});
|
|
5123
|
-
let o =
|
|
5275
|
+
let o = q.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
5124
5276
|
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);
|
|
5125
5277
|
let l = n.getSource("polyline-preview-measure-source");
|
|
5126
5278
|
if (l) {
|
|
5127
|
-
let e =
|
|
5279
|
+
let e = Tn.current, t = [];
|
|
5128
5280
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
5129
5281
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
5130
5282
|
t.push({
|
|
@@ -5141,8 +5293,8 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5141
5293
|
features: t
|
|
5142
5294
|
});
|
|
5143
5295
|
}
|
|
5144
|
-
}, []),
|
|
5145
|
-
let e =
|
|
5296
|
+
}, []), Gt = useCallback(() => {
|
|
5297
|
+
let e = P.current;
|
|
5146
5298
|
if (!e) return;
|
|
5147
5299
|
let t = e.getSource("polyline-preview-source");
|
|
5148
5300
|
t && t.setData({
|
|
@@ -5159,147 +5311,147 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5159
5311
|
type: "FeatureCollection",
|
|
5160
5312
|
features: []
|
|
5161
5313
|
});
|
|
5162
|
-
}, []),
|
|
5163
|
-
|
|
5164
|
-
}, [
|
|
5165
|
-
|
|
5314
|
+
}, []), Q = useCallback(() => {
|
|
5315
|
+
ut.current = [], Gt();
|
|
5316
|
+
}, [Gt]), Kt = useCallback((e) => {
|
|
5317
|
+
z(e), wt(e), e ? (B("marker"), Z(), Nt(), Lt(), Ht(), Q()) : B(null);
|
|
5166
5318
|
}, [
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
kt,
|
|
5319
|
+
wt,
|
|
5320
|
+
Z,
|
|
5170
5321
|
Nt,
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5322
|
+
Lt,
|
|
5323
|
+
Ht,
|
|
5324
|
+
Q
|
|
5325
|
+
]), qt = useCallback((e) => {
|
|
5326
|
+
if (B(e), e === "rectangle") {
|
|
5327
|
+
z(null), Y(), Nt(), Lt(), Ht(), Q();
|
|
5328
|
+
let e = P.current;
|
|
5177
5329
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5178
5330
|
} else if (e === "circle") {
|
|
5179
|
-
|
|
5180
|
-
let e =
|
|
5331
|
+
z(null), Y(), Z(), Lt(), Ht(), Q();
|
|
5332
|
+
let e = P.current;
|
|
5181
5333
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5182
5334
|
} else if (e === "polygon") {
|
|
5183
|
-
|
|
5184
|
-
let e =
|
|
5335
|
+
z(null), Y(), Z(), Nt(), Ht(), Q();
|
|
5336
|
+
let e = P.current;
|
|
5185
5337
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5186
5338
|
} else if (e === "square") {
|
|
5187
|
-
|
|
5188
|
-
let e =
|
|
5339
|
+
z(null), Y(), Z(), Nt(), Lt(), Q();
|
|
5340
|
+
let e = P.current;
|
|
5189
5341
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5190
5342
|
} else if (e === "polyline") {
|
|
5191
|
-
|
|
5192
|
-
let e =
|
|
5343
|
+
z(null), Y(), Z(), Nt(), Lt(), Ht();
|
|
5344
|
+
let e = P.current;
|
|
5193
5345
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5194
|
-
} else e === "marker" ? (
|
|
5346
|
+
} else e === "marker" ? (Z(), Nt(), Lt(), Ht(), Q()) : (z(null), Y(), Z(), Nt(), Lt(), Ht(), Q());
|
|
5195
5347
|
}, [
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
kt,
|
|
5348
|
+
Y,
|
|
5349
|
+
Z,
|
|
5199
5350
|
Nt,
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5351
|
+
Lt,
|
|
5352
|
+
Ht,
|
|
5353
|
+
Q
|
|
5354
|
+
]), Jt = useCallback((e) => {
|
|
5355
|
+
e !== "picker" && (St(), tt(null)), e !== "edit" && (z(null), B(null), Z(), Q(), Y()), $e(e);
|
|
5204
5356
|
}, [
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
]),
|
|
5210
|
-
|
|
5211
|
-
}, [
|
|
5357
|
+
St,
|
|
5358
|
+
Y,
|
|
5359
|
+
Z,
|
|
5360
|
+
Q
|
|
5361
|
+
]), Yt = useCallback(() => R, [R]), Xt = useCallback(() => et, [et]), Zt = useCallback(() => {
|
|
5362
|
+
St(), tt(null);
|
|
5363
|
+
}, [St]);
|
|
5212
5364
|
useEffect(() => {
|
|
5213
|
-
if (!
|
|
5214
|
-
let e =
|
|
5365
|
+
if (!Ze || R !== "picker") return;
|
|
5366
|
+
let e = y.value;
|
|
5215
5367
|
if (e) {
|
|
5216
5368
|
let t = [e.lng, e.lat];
|
|
5217
|
-
|
|
5369
|
+
tt(e), xt(t);
|
|
5218
5370
|
}
|
|
5219
5371
|
}, [
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5372
|
+
y.value,
|
|
5373
|
+
R,
|
|
5374
|
+
xt,
|
|
5375
|
+
Ze
|
|
5224
5376
|
]);
|
|
5225
|
-
let
|
|
5226
|
-
if (
|
|
5227
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
5377
|
+
let Qt = (e) => "mode" in e, $t = useCallback((e) => {
|
|
5378
|
+
if ($e("edit"), St(), tt(null), V.current = !0, Qt(e)) {
|
|
5379
|
+
if (e.mode === "marker") e.markerStyle ? (U.current = e.markerStyle, H.current = null, W.current = null, G.current = null, K.current = null, q.current = null, z(null), B("marker"), e.markerStyle.src && e.markerStyle.width ? wt({
|
|
5228
5380
|
id: "custom",
|
|
5229
5381
|
name: e.markerStyle.name || "Marker",
|
|
5230
5382
|
icon: e.markerStyle.src,
|
|
5231
5383
|
width: e.markerStyle.width
|
|
5232
|
-
}) :
|
|
5384
|
+
}) : Y()) : e.template && (U.current = null, H.current = null, W.current = null, G.current = null, K.current = null, q.current = null, z(e.template), B("marker"), wt(e.template));
|
|
5233
5385
|
else if (e.mode === "rectangle") {
|
|
5234
|
-
|
|
5235
|
-
let t =
|
|
5386
|
+
H.current = e.rectangleStyle || null, U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, z(null), B("rectangle"), Y();
|
|
5387
|
+
let t = P.current;
|
|
5236
5388
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5237
5389
|
} else if (e.mode === "circle") {
|
|
5238
|
-
|
|
5239
|
-
let t =
|
|
5390
|
+
W.current = e.circleStyle || null, H.current = null, U.current = null, G.current = null, K.current = null, q.current = null, z(null), B("circle"), Y();
|
|
5391
|
+
let t = P.current;
|
|
5240
5392
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5241
5393
|
} else if (e.mode === "polygon") {
|
|
5242
|
-
|
|
5243
|
-
let t =
|
|
5394
|
+
G.current = e.polygonStyle || null, H.current = null, U.current = null, W.current = null, K.current = null, q.current = null, z(null), B("polygon"), Y();
|
|
5395
|
+
let t = P.current;
|
|
5244
5396
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5245
5397
|
} else if (e.mode === "square") {
|
|
5246
|
-
|
|
5247
|
-
let t =
|
|
5398
|
+
K.current = e.squareStyle || null, H.current = null, U.current = null, W.current = null, G.current = null, q.current = null, z(null), B("square"), Y();
|
|
5399
|
+
let t = P.current;
|
|
5248
5400
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5249
5401
|
} else if (e.mode === "polyline") {
|
|
5250
|
-
|
|
5251
|
-
let t =
|
|
5402
|
+
q.current = e.polylineStyle || null, H.current = null, U.current = null, W.current = null, G.current = null, K.current = null, z(null), B("polyline"), Y();
|
|
5403
|
+
let t = P.current;
|
|
5252
5404
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5253
5405
|
}
|
|
5254
|
-
} else
|
|
5406
|
+
} else z(e), B("marker"), wt(e), H.current = null, U.current = null, W.current = null, G.current = null, K.current = null, q.current = null;
|
|
5255
5407
|
}, [
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5408
|
+
St,
|
|
5409
|
+
wt,
|
|
5410
|
+
Y
|
|
5259
5411
|
]);
|
|
5260
|
-
useImperativeHandle(
|
|
5261
|
-
startAnimation:
|
|
5262
|
-
stopAnimation:
|
|
5263
|
-
toggleAnimation:
|
|
5264
|
-
getMap: () =>
|
|
5265
|
-
openPopup: (e) =>
|
|
5266
|
-
closePopup:
|
|
5267
|
-
closeAllPopups:
|
|
5268
|
-
isPopupOpen:
|
|
5269
|
-
toggleUnitTrajectory:
|
|
5270
|
-
flyTo:
|
|
5271
|
-
flyToEntities:
|
|
5272
|
-
getMode:
|
|
5273
|
-
setMode:
|
|
5274
|
-
getPickedLocation:
|
|
5275
|
-
clearPickedLocation:
|
|
5276
|
-
startDrawing:
|
|
5277
|
-
getRenderer: (e) =>
|
|
5412
|
+
useImperativeHandle(c, () => ({
|
|
5413
|
+
startAnimation: dt,
|
|
5414
|
+
stopAnimation: ft,
|
|
5415
|
+
toggleAnimation: pt,
|
|
5416
|
+
getMap: () => P.current,
|
|
5417
|
+
openPopup: (e) => ht(e, "programmatic"),
|
|
5418
|
+
closePopup: gt,
|
|
5419
|
+
closeAllPopups: _t,
|
|
5420
|
+
isPopupOpen: vt,
|
|
5421
|
+
toggleUnitTrajectory: mt,
|
|
5422
|
+
flyTo: yt,
|
|
5423
|
+
flyToEntities: bt,
|
|
5424
|
+
getMode: Yt,
|
|
5425
|
+
setMode: Jt,
|
|
5426
|
+
getPickedLocation: Xt,
|
|
5427
|
+
clearPickedLocation: Zt,
|
|
5428
|
+
startDrawing: $t,
|
|
5429
|
+
getRenderer: (e) => F.current.get(e)
|
|
5278
5430
|
}), [
|
|
5279
|
-
st,
|
|
5280
|
-
ct,
|
|
5281
|
-
lt,
|
|
5282
5431
|
dt,
|
|
5283
5432
|
ft,
|
|
5284
5433
|
pt,
|
|
5285
|
-
mt,
|
|
5286
|
-
ut,
|
|
5287
5434
|
ht,
|
|
5288
5435
|
gt,
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5436
|
+
_t,
|
|
5437
|
+
vt,
|
|
5438
|
+
mt,
|
|
5439
|
+
yt,
|
|
5440
|
+
bt,
|
|
5441
|
+
Yt,
|
|
5442
|
+
Jt,
|
|
5443
|
+
Xt,
|
|
5444
|
+
Zt,
|
|
5445
|
+
$t
|
|
5294
5446
|
]);
|
|
5295
|
-
let
|
|
5296
|
-
let e =
|
|
5447
|
+
let en = useCallback(() => {
|
|
5448
|
+
let e = P.current;
|
|
5297
5449
|
if (!e) return;
|
|
5298
|
-
let t = new Set(
|
|
5299
|
-
for (let e of n) t.has(e) || (
|
|
5300
|
-
let r = new Set(
|
|
5301
|
-
for (let t of
|
|
5302
|
-
let n = applyEntityConfig(t,
|
|
5450
|
+
let t = new Set(T.map((e) => e.id)), n = new Set(F.current.keys());
|
|
5451
|
+
for (let e of n) t.has(e) || (F.current.get(e)?.destroy(), F.current.delete(e));
|
|
5452
|
+
let r = new Set(E.map(String));
|
|
5453
|
+
for (let t of T) {
|
|
5454
|
+
let n = applyEntityConfig(t, D), i = F.current.get(n.id);
|
|
5303
5455
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
5304
5456
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
5305
5457
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -5308,34 +5460,34 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5308
5460
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
5309
5461
|
else {
|
|
5310
5462
|
i.destroy();
|
|
5311
|
-
let t = new CanvasCircleRenderer(e, n,
|
|
5312
|
-
|
|
5463
|
+
let t = new CanvasCircleRenderer(e, n, O, k, A, j);
|
|
5464
|
+
F.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
5313
5465
|
}
|
|
5314
5466
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
5315
5467
|
else {
|
|
5316
5468
|
i.destroy();
|
|
5317
|
-
let t = new CircleRenderer(e, n,
|
|
5318
|
-
|
|
5469
|
+
let t = new CircleRenderer(e, n, O, k, A, j);
|
|
5470
|
+
F.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
5319
5471
|
}
|
|
5320
5472
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
5321
5473
|
else {
|
|
5322
5474
|
let t = null;
|
|
5323
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n,
|
|
5475
|
+
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 && (F.current.set(n.id, t), t.setSelected(r.has(String(n.id))));
|
|
5324
5476
|
}
|
|
5325
5477
|
}
|
|
5326
5478
|
}, [
|
|
5327
|
-
x,
|
|
5328
|
-
S,
|
|
5329
|
-
C,
|
|
5330
|
-
w,
|
|
5331
5479
|
T,
|
|
5332
5480
|
E,
|
|
5333
5481
|
D,
|
|
5334
|
-
O
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5482
|
+
O,
|
|
5483
|
+
k,
|
|
5484
|
+
A,
|
|
5485
|
+
j,
|
|
5486
|
+
M
|
|
5487
|
+
]), tn = useCallback(() => {
|
|
5488
|
+
for (let e of F.current.values()) e.destroy();
|
|
5489
|
+
F.current.clear();
|
|
5490
|
+
}, []), nn = useCallback((e) => {
|
|
5339
5491
|
let t = e.getStyle();
|
|
5340
5492
|
if (!t?.layers) return;
|
|
5341
5493
|
let n = [
|
|
@@ -5350,31 +5502,32 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5350
5502
|
"marker-"
|
|
5351
5503
|
];
|
|
5352
5504
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
5353
|
-
}, []),
|
|
5354
|
-
let n =
|
|
5355
|
-
|
|
5505
|
+
}, []), rn = useCallback((e) => {
|
|
5506
|
+
let t = C, n = { "raster-opacity": e.opacity ?? 1 }, r = e.brightness ?? t?.brightness, i = e.saturation ?? t?.saturation, a = e.contrast ?? t?.contrast, o = e.hueRotate ?? t?.hueRotate;
|
|
5507
|
+
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;
|
|
5508
|
+
}, [C]), an = useCallback((e, t) => {
|
|
5509
|
+
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
5356
5510
|
type: "raster",
|
|
5357
5511
|
tiles: [t.url],
|
|
5358
5512
|
tileSize: t.tileSize ?? 256,
|
|
5359
5513
|
minzoom: t.minzoom ?? 0,
|
|
5360
5514
|
maxzoom: t.maxzoom ?? 22,
|
|
5361
|
-
scheme: t.scheme ?? "xyz"
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
let i = Qt(e);
|
|
5515
|
+
scheme: t.scheme ?? "xyz"
|
|
5516
|
+
};
|
|
5517
|
+
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
5518
|
+
let a = nn(e);
|
|
5366
5519
|
e.addLayer({
|
|
5367
5520
|
id: r,
|
|
5368
5521
|
type: "raster",
|
|
5369
5522
|
source: n,
|
|
5370
|
-
paint:
|
|
5523
|
+
paint: rn(t),
|
|
5371
5524
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
5372
|
-
},
|
|
5373
|
-
}, [
|
|
5525
|
+
}, a);
|
|
5526
|
+
}, [nn, rn]), on = useCallback(async (e, t) => {
|
|
5374
5527
|
try {
|
|
5375
5528
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
5376
|
-
if (!
|
|
5377
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
5529
|
+
if (!He.current.has(t.id)) return;
|
|
5530
|
+
let a = n.format === "pbf" || n.vector_layers, o = nn(e);
|
|
5378
5531
|
a ? (e.addSource(r, {
|
|
5379
5532
|
type: "vector",
|
|
5380
5533
|
tiles: n.tiles,
|
|
@@ -5394,21 +5547,21 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5394
5547
|
id: i,
|
|
5395
5548
|
type: "raster",
|
|
5396
5549
|
source: r,
|
|
5397
|
-
paint:
|
|
5550
|
+
paint: rn(t),
|
|
5398
5551
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
5399
5552
|
}, o));
|
|
5400
5553
|
} catch (e) {
|
|
5401
5554
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
5402
5555
|
}
|
|
5403
|
-
}, [
|
|
5556
|
+
}, [nn, rn]), sn = useCallback(async (e, t) => {
|
|
5404
5557
|
try {
|
|
5405
5558
|
let n = await (await fetch(t.url)).json();
|
|
5406
|
-
if (!
|
|
5559
|
+
if (!He.current.has(t.id)) return;
|
|
5407
5560
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
5408
5561
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
5409
5562
|
e.getSource(n) || e.addSource(n, i);
|
|
5410
5563
|
}
|
|
5411
|
-
let r =
|
|
5564
|
+
let r = nn(e);
|
|
5412
5565
|
if (n.layers) for (let i of n.layers) {
|
|
5413
5566
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
5414
5567
|
if (e.getLayer(n)) continue;
|
|
@@ -5417,57 +5570,65 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5417
5570
|
id: n,
|
|
5418
5571
|
source: i.source ? `base-layer-source-${t.id}-${i.source}` : void 0
|
|
5419
5572
|
};
|
|
5420
|
-
i.type === "raster" &&
|
|
5573
|
+
i.type === "raster" && (a.paint = {
|
|
5421
5574
|
...a.paint,
|
|
5422
|
-
|
|
5575
|
+
...rn(t)
|
|
5423
5576
|
}), t.visible === !1 && (a.layout = {
|
|
5424
5577
|
...a.layout,
|
|
5425
5578
|
visibility: "none"
|
|
5426
5579
|
}), e.addLayer(a, r);
|
|
5427
5580
|
}
|
|
5428
|
-
n.glyphs &&
|
|
5581
|
+
if (n.glyphs && !e.getStyle().glyphs) {
|
|
5582
|
+
let t = e.style;
|
|
5583
|
+
t.glyphs = n.glyphs, t.stylesheet && (t.stylesheet.glyphs = n.glyphs);
|
|
5584
|
+
}
|
|
5429
5585
|
} catch (e) {
|
|
5430
5586
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
5431
5587
|
}
|
|
5432
|
-
}, [
|
|
5588
|
+
}, [nn, rn]), cn = useCallback((e, t) => {
|
|
5433
5589
|
let n = e.getStyle();
|
|
5434
5590
|
if (!n) return;
|
|
5435
5591
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
5436
5592
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
5437
5593
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
5438
5594
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
5439
|
-
}, []),
|
|
5440
|
-
let t =
|
|
5595
|
+
}, []), ln = useCallback((e) => {
|
|
5596
|
+
let t = P.current;
|
|
5441
5597
|
if (!t) return;
|
|
5442
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
5443
|
-
for (let e of r) n.has(e) || (
|
|
5598
|
+
let n = new Set(e.map((e) => e.id)), r = He.current;
|
|
5599
|
+
for (let e of r) n.has(e) || (cn(t, e), r.delete(e));
|
|
5444
5600
|
for (let n of e) if (r.has(n.id)) {
|
|
5445
5601
|
let e = `base-layer-${n.id}`;
|
|
5446
|
-
|
|
5602
|
+
if (t.getLayer(e)) {
|
|
5603
|
+
let r = rn(n);
|
|
5604
|
+
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
5605
|
+
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
5606
|
+
}
|
|
5447
5607
|
} else switch (r.add(n.id), n.type) {
|
|
5448
5608
|
case "raster":
|
|
5449
|
-
|
|
5609
|
+
an(t, n);
|
|
5450
5610
|
break;
|
|
5451
5611
|
case "tilejson":
|
|
5452
|
-
|
|
5612
|
+
on(t, n);
|
|
5453
5613
|
break;
|
|
5454
5614
|
case "style":
|
|
5455
|
-
|
|
5615
|
+
sn(t, n);
|
|
5456
5616
|
break;
|
|
5457
5617
|
default: {
|
|
5458
5618
|
let e = n;
|
|
5459
|
-
e.url &&
|
|
5619
|
+
e.url && an(t, {
|
|
5460
5620
|
...e,
|
|
5461
5621
|
type: "raster"
|
|
5462
5622
|
});
|
|
5463
5623
|
}
|
|
5464
5624
|
}
|
|
5465
5625
|
}, [
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5626
|
+
an,
|
|
5627
|
+
on,
|
|
5628
|
+
sn,
|
|
5629
|
+
cn,
|
|
5630
|
+
rn
|
|
5631
|
+
]), un = useCallback((e) => {
|
|
5471
5632
|
let t = e;
|
|
5472
5633
|
for (; t;) {
|
|
5473
5634
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -5475,293 +5636,293 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5475
5636
|
t = t.parentElement;
|
|
5476
5637
|
}
|
|
5477
5638
|
return null;
|
|
5478
|
-
}, []),
|
|
5639
|
+
}, []), dn = useCallback((e) => {
|
|
5479
5640
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
5480
5641
|
x: e.point.x,
|
|
5481
5642
|
y: e.point.y
|
|
5482
|
-
}, r =
|
|
5643
|
+
}, r = yn.current;
|
|
5483
5644
|
if (r === "picker") {
|
|
5484
5645
|
let e = {
|
|
5485
5646
|
lng: t[0],
|
|
5486
5647
|
lat: t[1]
|
|
5487
5648
|
};
|
|
5488
|
-
|
|
5649
|
+
tt(e), xt(t), bn.current?.(e);
|
|
5489
5650
|
return;
|
|
5490
5651
|
}
|
|
5491
5652
|
if (r === "edit") {
|
|
5492
|
-
let e =
|
|
5653
|
+
let e = Sn.current;
|
|
5493
5654
|
if (e === "rectangle") {
|
|
5494
|
-
let e =
|
|
5495
|
-
if (!e)
|
|
5655
|
+
let e = Cn.current;
|
|
5656
|
+
if (!e) ot(t);
|
|
5496
5657
|
else {
|
|
5497
|
-
let n =
|
|
5658
|
+
let n = H.current, r = applyEntityConfig({
|
|
5498
5659
|
...n,
|
|
5499
|
-
id: n?.id ??
|
|
5660
|
+
id: n?.id ?? Ct(),
|
|
5500
5661
|
type: "rectangle",
|
|
5501
5662
|
bounds: [e, t]
|
|
5502
|
-
},
|
|
5503
|
-
|
|
5504
|
-
let i =
|
|
5505
|
-
if (i && !
|
|
5506
|
-
let e = new RectangleRenderer(i, r,
|
|
5507
|
-
|
|
5663
|
+
}, D);
|
|
5664
|
+
Dt();
|
|
5665
|
+
let i = P.current;
|
|
5666
|
+
if (i && !F.current.has(r.id)) {
|
|
5667
|
+
let e = new RectangleRenderer(i, r, O, k, A, M);
|
|
5668
|
+
F.current.set(r.id, e);
|
|
5508
5669
|
}
|
|
5509
|
-
|
|
5670
|
+
wn.current.onRectangleAdd?.(r), ot(null), H.current = null, V.current && (V.current = !1, B(null), i && (i.getCanvas().style.cursor = ""));
|
|
5510
5671
|
}
|
|
5511
5672
|
return;
|
|
5512
5673
|
}
|
|
5513
5674
|
if (e === "circle") {
|
|
5514
|
-
let e =
|
|
5515
|
-
if (!e)
|
|
5675
|
+
let e = st.current;
|
|
5676
|
+
if (!e) st.current = { center: t };
|
|
5516
5677
|
else {
|
|
5517
|
-
let n =
|
|
5678
|
+
let n = At(e.center, t), r = W.current, i = applyEntityConfig({
|
|
5518
5679
|
...r,
|
|
5519
|
-
id: r?.id ??
|
|
5680
|
+
id: r?.id ?? Ct(),
|
|
5520
5681
|
type: "circle",
|
|
5521
5682
|
center: e.center,
|
|
5522
5683
|
radius: n
|
|
5523
|
-
},
|
|
5524
|
-
|
|
5525
|
-
let a =
|
|
5526
|
-
if (a && !
|
|
5527
|
-
let e = new CircleRenderer(a, i,
|
|
5528
|
-
|
|
5684
|
+
}, D);
|
|
5685
|
+
Mt();
|
|
5686
|
+
let a = P.current;
|
|
5687
|
+
if (a && !F.current.has(i.id)) {
|
|
5688
|
+
let e = new CircleRenderer(a, i, O, k, A, j);
|
|
5689
|
+
F.current.set(i.id, e);
|
|
5529
5690
|
}
|
|
5530
|
-
|
|
5691
|
+
wn.current.onCircleAdd?.(i), st.current = null, W.current = null, V.current && (V.current = !1, B(null), a && (a.getCanvas().style.cursor = ""));
|
|
5531
5692
|
}
|
|
5532
5693
|
return;
|
|
5533
5694
|
}
|
|
5534
5695
|
if (e === "polygon") {
|
|
5535
|
-
let e =
|
|
5696
|
+
let e = ct.current;
|
|
5536
5697
|
if (e.length >= 3) {
|
|
5537
5698
|
let n = e[0];
|
|
5538
|
-
if (
|
|
5539
|
-
let t =
|
|
5699
|
+
if (At(n, t) < 20) {
|
|
5700
|
+
let t = G.current, n = applyEntityConfig({
|
|
5540
5701
|
...t,
|
|
5541
|
-
id: t?.id ??
|
|
5702
|
+
id: t?.id ?? Ct(),
|
|
5542
5703
|
type: "polygon",
|
|
5543
5704
|
coordinates: [...e]
|
|
5544
|
-
},
|
|
5545
|
-
|
|
5546
|
-
let r =
|
|
5547
|
-
if (r && !
|
|
5548
|
-
let e = new PolygonRenderer(r, n,
|
|
5549
|
-
|
|
5705
|
+
}, D);
|
|
5706
|
+
It();
|
|
5707
|
+
let r = P.current;
|
|
5708
|
+
if (r && !F.current.has(n.id)) {
|
|
5709
|
+
let e = new PolygonRenderer(r, n, O, k, A, M);
|
|
5710
|
+
F.current.set(n.id, e);
|
|
5550
5711
|
}
|
|
5551
|
-
|
|
5712
|
+
wn.current.onPolygonAdd?.(n), ct.current = [], G.current = null, V.current && (V.current = !1, B(null), r && (r.getCanvas().style.cursor = ""));
|
|
5552
5713
|
return;
|
|
5553
5714
|
}
|
|
5554
5715
|
}
|
|
5555
|
-
|
|
5716
|
+
ct.current = [...e, t];
|
|
5556
5717
|
return;
|
|
5557
5718
|
}
|
|
5558
5719
|
if (e === "square") {
|
|
5559
|
-
let e =
|
|
5560
|
-
if (!e)
|
|
5720
|
+
let e = lt.current;
|
|
5721
|
+
if (!e) lt.current = { center: t };
|
|
5561
5722
|
else {
|
|
5562
|
-
let n =
|
|
5723
|
+
let n = At(e.center, t) * 2, r = K.current, i = applyEntityConfig({
|
|
5563
5724
|
...r,
|
|
5564
|
-
id: r?.id ??
|
|
5725
|
+
id: r?.id ?? Ct(),
|
|
5565
5726
|
type: "square",
|
|
5566
5727
|
center: e.center,
|
|
5567
5728
|
length: n
|
|
5568
|
-
},
|
|
5569
|
-
|
|
5570
|
-
let a =
|
|
5571
|
-
if (a && !
|
|
5572
|
-
let e = new SquareRenderer(a, i,
|
|
5573
|
-
|
|
5729
|
+
}, D);
|
|
5730
|
+
Vt();
|
|
5731
|
+
let a = P.current;
|
|
5732
|
+
if (a && !F.current.has(i.id)) {
|
|
5733
|
+
let e = new SquareRenderer(a, i, O, k, A, M);
|
|
5734
|
+
F.current.set(i.id, e);
|
|
5574
5735
|
}
|
|
5575
|
-
|
|
5736
|
+
wn.current.onSquareAdd?.(i), lt.current = null, K.current = null, V.current && (V.current = !1, B(null), a && (a.getCanvas().style.cursor = ""));
|
|
5576
5737
|
}
|
|
5577
5738
|
return;
|
|
5578
5739
|
}
|
|
5579
5740
|
if (e === "polyline") {
|
|
5580
|
-
|
|
5741
|
+
ut.current = [...ut.current, t];
|
|
5581
5742
|
return;
|
|
5582
5743
|
}
|
|
5583
|
-
let n =
|
|
5744
|
+
let n = U.current;
|
|
5584
5745
|
if (n && n.src && n.width) {
|
|
5585
5746
|
let e = {
|
|
5586
5747
|
...n,
|
|
5587
|
-
id: n.id ??
|
|
5748
|
+
id: n.id ?? Ct(),
|
|
5588
5749
|
type: "marker",
|
|
5589
5750
|
center: t,
|
|
5590
5751
|
src: n.src,
|
|
5591
5752
|
width: n.width
|
|
5592
5753
|
};
|
|
5593
|
-
|
|
5754
|
+
wn.current.onMarkerAdd?.(e), z(null), B(null), Y(), U.current = null, V.current = !1;
|
|
5594
5755
|
return;
|
|
5595
5756
|
}
|
|
5596
|
-
let r =
|
|
5757
|
+
let r = xn.current;
|
|
5597
5758
|
if (r) {
|
|
5598
5759
|
let e = {
|
|
5599
|
-
id:
|
|
5760
|
+
id: Ct(),
|
|
5600
5761
|
type: "marker",
|
|
5601
5762
|
name: r.name,
|
|
5602
5763
|
center: t,
|
|
5603
5764
|
src: r.icon,
|
|
5604
5765
|
width: r.size || r.width || 32
|
|
5605
5766
|
};
|
|
5606
|
-
r.customData !== void 0 && (e.customData = r.customData),
|
|
5767
|
+
r.customData !== void 0 && (e.customData = r.customData), wn.current.onMarkerAdd?.(e), z(null), B(null), Y(), V.current = !1;
|
|
5607
5768
|
return;
|
|
5608
5769
|
}
|
|
5609
5770
|
}
|
|
5610
|
-
let i =
|
|
5771
|
+
let i = gn.current, a = _n.current, o = vn.current, s = un(e.originalEvent.target);
|
|
5611
5772
|
if (s) {
|
|
5612
5773
|
let e = i.find((e) => String(e.id) === s);
|
|
5613
5774
|
if (e) {
|
|
5614
5775
|
if (a?.(e), e.popup) {
|
|
5615
|
-
let t = e.popup.content ??
|
|
5616
|
-
t && mergePopupConfig(e.popup,
|
|
5776
|
+
let t = e.popup.content ?? Pe?.(e);
|
|
5777
|
+
t && mergePopupConfig(e.popup, N, t).trigger === "click" && o(s, "click", n);
|
|
5617
5778
|
}
|
|
5618
5779
|
return;
|
|
5619
5780
|
}
|
|
5620
5781
|
}
|
|
5621
|
-
for (let [t, r] of
|
|
5782
|
+
for (let [t, r] of F.current) {
|
|
5622
5783
|
let s = r.getLabelLayerId();
|
|
5623
|
-
if (s &&
|
|
5784
|
+
if (s && P.current?.getLayer(s) && P.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
5624
5785
|
let e = i.find((e) => e.id === t);
|
|
5625
5786
|
if (e) {
|
|
5626
5787
|
if (a?.(e), e.popup) {
|
|
5627
|
-
let r = e.popup.content ??
|
|
5628
|
-
r && mergePopupConfig(e.popup,
|
|
5788
|
+
let r = e.popup.content ?? Pe?.(e);
|
|
5789
|
+
r && mergePopupConfig(e.popup, N, r).trigger === "click" && o(t, "click", n);
|
|
5629
5790
|
}
|
|
5630
5791
|
return;
|
|
5631
5792
|
}
|
|
5632
5793
|
}
|
|
5633
5794
|
}
|
|
5634
|
-
for (let [e, r] of
|
|
5795
|
+
for (let [e, r] of F.current) if (r.isPointInEntity(t)) {
|
|
5635
5796
|
let t = i.find((t) => t.id === e);
|
|
5636
5797
|
if (t) {
|
|
5637
5798
|
if (a?.(t), t.popup) {
|
|
5638
|
-
let r = t.popup.content ??
|
|
5639
|
-
r && mergePopupConfig(t.popup,
|
|
5799
|
+
let r = t.popup.content ?? Pe?.(t);
|
|
5800
|
+
r && mergePopupConfig(t.popup, N, r).trigger === "click" && o(e, "click", n);
|
|
5640
5801
|
}
|
|
5641
5802
|
return;
|
|
5642
5803
|
}
|
|
5643
5804
|
}
|
|
5644
5805
|
}, [
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
]),
|
|
5649
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5650
|
-
n === "rectangle" && r &&
|
|
5651
|
-
let i =
|
|
5652
|
-
n === "circle" && i &&
|
|
5653
|
-
let a =
|
|
5654
|
-
n === "polygon" && a.length > 0 &&
|
|
5655
|
-
let o =
|
|
5656
|
-
n === "square" && o &&
|
|
5657
|
-
let s =
|
|
5658
|
-
n === "polyline" && s.length > 0 &&
|
|
5659
|
-
let c =
|
|
5660
|
-
for (let [e, n] of
|
|
5806
|
+
N,
|
|
5807
|
+
Pe,
|
|
5808
|
+
un
|
|
5809
|
+
]), fn = useCallback((e) => {
|
|
5810
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = Sn.current, r = Cn.current;
|
|
5811
|
+
n === "rectangle" && r && Et(r, t);
|
|
5812
|
+
let i = st.current;
|
|
5813
|
+
n === "circle" && i && jt(i.center, t);
|
|
5814
|
+
let a = ct.current;
|
|
5815
|
+
n === "polygon" && a.length > 0 && Ft(a, t);
|
|
5816
|
+
let o = lt.current;
|
|
5817
|
+
n === "square" && o && Bt(o.center, t);
|
|
5818
|
+
let s = ut.current;
|
|
5819
|
+
n === "polyline" && s.length > 0 && Wt(s, t);
|
|
5820
|
+
let c = gn.current, l = vn.current;
|
|
5821
|
+
for (let [e, n] of F.current) if (n.isPointInEntity(t)) {
|
|
5661
5822
|
let t = c.find((t) => t.id === e);
|
|
5662
5823
|
if (!t?.popup) continue;
|
|
5663
|
-
let n = t.popup.content ??
|
|
5824
|
+
let n = t.popup.content ?? Pe?.(t);
|
|
5664
5825
|
if (!n) continue;
|
|
5665
|
-
let r = mergePopupConfig(t.popup,
|
|
5826
|
+
let r = mergePopupConfig(t.popup, N, n);
|
|
5666
5827
|
if (r.trigger === "hover") {
|
|
5667
|
-
|
|
5828
|
+
Ke.current && clearTimeout(Ke.current), Ke.current = window.setTimeout(() => {
|
|
5668
5829
|
l(e, "hover");
|
|
5669
5830
|
}, r.hoverDelay);
|
|
5670
5831
|
return;
|
|
5671
5832
|
}
|
|
5672
5833
|
}
|
|
5673
|
-
if (
|
|
5674
|
-
let e =
|
|
5675
|
-
e && !e.isPointInEntity(t) &&
|
|
5834
|
+
if (Ke.current &&= (clearTimeout(Ke.current), null), L?.openedBy === "hover") {
|
|
5835
|
+
let e = F.current.get(L.entityId);
|
|
5836
|
+
e && !e.isPointInEntity(t) && gt(L.entityId);
|
|
5676
5837
|
}
|
|
5677
5838
|
}, [
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
Dt,
|
|
5839
|
+
N,
|
|
5840
|
+
Pe,
|
|
5841
|
+
L,
|
|
5842
|
+
gt,
|
|
5843
|
+
Et,
|
|
5684
5844
|
jt,
|
|
5685
|
-
|
|
5686
|
-
Bt
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
if (
|
|
5690
|
-
|
|
5845
|
+
Ft,
|
|
5846
|
+
Bt,
|
|
5847
|
+
Wt
|
|
5848
|
+
]), pn = useCallback((e) => {
|
|
5849
|
+
if (e.preventDefault(), yn.current !== "edit") return;
|
|
5850
|
+
if (xn.current) {
|
|
5851
|
+
z(null), B(null), Y();
|
|
5691
5852
|
return;
|
|
5692
5853
|
}
|
|
5693
|
-
let t =
|
|
5854
|
+
let t = Sn.current;
|
|
5694
5855
|
if (t === "rectangle") {
|
|
5695
|
-
if (
|
|
5856
|
+
if (Cn.current) ot(null), Dt();
|
|
5696
5857
|
else {
|
|
5697
|
-
|
|
5698
|
-
let e =
|
|
5858
|
+
B(null);
|
|
5859
|
+
let e = P.current;
|
|
5699
5860
|
e && (e.getCanvas().style.cursor = "");
|
|
5700
5861
|
}
|
|
5701
5862
|
return;
|
|
5702
5863
|
}
|
|
5703
5864
|
if (t === "circle") {
|
|
5704
|
-
if (
|
|
5865
|
+
if (st.current) st.current = null, Mt();
|
|
5705
5866
|
else {
|
|
5706
|
-
|
|
5707
|
-
let e =
|
|
5867
|
+
B(null);
|
|
5868
|
+
let e = P.current;
|
|
5708
5869
|
e && (e.getCanvas().style.cursor = "");
|
|
5709
5870
|
}
|
|
5710
5871
|
return;
|
|
5711
5872
|
}
|
|
5712
5873
|
if (t === "polygon") {
|
|
5713
|
-
let e =
|
|
5874
|
+
let e = ct.current;
|
|
5714
5875
|
if (e.length >= 3) {
|
|
5715
|
-
let t =
|
|
5876
|
+
let t = G.current, n = applyEntityConfig({
|
|
5716
5877
|
...t,
|
|
5717
|
-
id: t?.id ??
|
|
5878
|
+
id: t?.id ?? Ct(),
|
|
5718
5879
|
type: "polygon",
|
|
5719
5880
|
coordinates: [...e]
|
|
5720
|
-
},
|
|
5721
|
-
|
|
5722
|
-
let r =
|
|
5723
|
-
if (r && !
|
|
5724
|
-
let e = new PolygonRenderer(r, n,
|
|
5725
|
-
|
|
5881
|
+
}, D);
|
|
5882
|
+
It();
|
|
5883
|
+
let r = P.current;
|
|
5884
|
+
if (r && !F.current.has(n.id)) {
|
|
5885
|
+
let e = new PolygonRenderer(r, n, O, k, A, M);
|
|
5886
|
+
F.current.set(n.id, e);
|
|
5726
5887
|
}
|
|
5727
|
-
|
|
5728
|
-
} else if (e.length > 0)
|
|
5888
|
+
wn.current.onPolygonAdd?.(n), ct.current = [], G.current = null, V.current && (V.current = !1, B(null), r && (r.getCanvas().style.cursor = ""));
|
|
5889
|
+
} else if (e.length > 0) ct.current = [], It();
|
|
5729
5890
|
else {
|
|
5730
|
-
|
|
5731
|
-
let e =
|
|
5891
|
+
B(null);
|
|
5892
|
+
let e = P.current;
|
|
5732
5893
|
e && (e.getCanvas().style.cursor = "");
|
|
5733
5894
|
}
|
|
5734
5895
|
return;
|
|
5735
5896
|
}
|
|
5736
5897
|
if (t === "square") {
|
|
5737
|
-
if (
|
|
5898
|
+
if (lt.current) lt.current = null, Vt();
|
|
5738
5899
|
else {
|
|
5739
|
-
|
|
5740
|
-
let e =
|
|
5900
|
+
B(null);
|
|
5901
|
+
let e = P.current;
|
|
5741
5902
|
e && (e.getCanvas().style.cursor = "");
|
|
5742
5903
|
}
|
|
5743
5904
|
return;
|
|
5744
5905
|
}
|
|
5745
5906
|
if (t === "polyline") {
|
|
5746
|
-
let e =
|
|
5907
|
+
let e = ut.current;
|
|
5747
5908
|
if (e.length >= 2) {
|
|
5748
|
-
let t =
|
|
5909
|
+
let t = q.current, n = applyEntityConfig({
|
|
5749
5910
|
...t,
|
|
5750
|
-
id: t?.id ??
|
|
5911
|
+
id: t?.id ?? Ct(),
|
|
5751
5912
|
type: "polyline",
|
|
5752
5913
|
coordinates: [...e]
|
|
5753
|
-
},
|
|
5754
|
-
|
|
5755
|
-
let r =
|
|
5756
|
-
if (r && !
|
|
5757
|
-
let e = new PolylineRenderer(r, n,
|
|
5758
|
-
|
|
5914
|
+
}, D);
|
|
5915
|
+
Gt();
|
|
5916
|
+
let r = P.current;
|
|
5917
|
+
if (r && !F.current.has(n.id)) {
|
|
5918
|
+
let e = new PolylineRenderer(r, n, O, k, M);
|
|
5919
|
+
F.current.set(n.id, e);
|
|
5759
5920
|
}
|
|
5760
|
-
|
|
5761
|
-
} else if (e.length > 0)
|
|
5921
|
+
wn.current.onPolylineAdd?.(n), ut.current = [], q.current = null, V.current && (V.current = !1, B(null), r && (r.getCanvas().style.cursor = ""));
|
|
5922
|
+
} else if (e.length > 0) ut.current = [], Gt();
|
|
5762
5923
|
else {
|
|
5763
|
-
|
|
5764
|
-
let e =
|
|
5924
|
+
B(null);
|
|
5925
|
+
let e = P.current;
|
|
5765
5926
|
e && (e.getCanvas().style.cursor = "");
|
|
5766
5927
|
}
|
|
5767
5928
|
return;
|
|
@@ -5769,45 +5930,45 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5769
5930
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
5770
5931
|
x: e.point.x,
|
|
5771
5932
|
y: e.point.y
|
|
5772
|
-
}, i =
|
|
5933
|
+
}, i = gn.current, a = un(e.originalEvent.target);
|
|
5773
5934
|
if (a) {
|
|
5774
5935
|
let e = i.find((e) => String(e.id) === a);
|
|
5775
5936
|
if (e) {
|
|
5776
|
-
|
|
5937
|
+
mn(e, r, n);
|
|
5777
5938
|
return;
|
|
5778
5939
|
}
|
|
5779
5940
|
}
|
|
5780
|
-
for (let [t, a] of
|
|
5941
|
+
for (let [t, a] of F.current) {
|
|
5781
5942
|
let o = a.getLabelLayerId();
|
|
5782
|
-
if (o &&
|
|
5943
|
+
if (o && P.current?.getLayer(o) && P.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
5783
5944
|
let e = i.find((e) => e.id === t);
|
|
5784
5945
|
if (e) {
|
|
5785
|
-
|
|
5946
|
+
mn(e, r, n);
|
|
5786
5947
|
return;
|
|
5787
5948
|
}
|
|
5788
5949
|
}
|
|
5789
5950
|
}
|
|
5790
|
-
for (let [e, t] of
|
|
5951
|
+
for (let [e, t] of F.current) if (t.isPointInEntity(n)) {
|
|
5791
5952
|
let t = i.find((t) => t.id === e);
|
|
5792
5953
|
if (t) {
|
|
5793
|
-
|
|
5954
|
+
mn(t, r, n);
|
|
5794
5955
|
return;
|
|
5795
5956
|
}
|
|
5796
5957
|
}
|
|
5797
5958
|
}, [
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
Ot,
|
|
5959
|
+
un,
|
|
5960
|
+
Y,
|
|
5961
|
+
Dt,
|
|
5802
5962
|
Mt,
|
|
5803
|
-
|
|
5804
|
-
Vt
|
|
5805
|
-
|
|
5806
|
-
|
|
5963
|
+
It,
|
|
5964
|
+
Vt,
|
|
5965
|
+
Gt
|
|
5966
|
+
]), mn = useCallback((e, t, n) => {
|
|
5967
|
+
let r = Ve.current?.getBoundingClientRect(), i = r ? {
|
|
5807
5968
|
x: t.x + r.left,
|
|
5808
5969
|
y: t.y + r.top
|
|
5809
5970
|
} : t;
|
|
5810
|
-
|
|
5971
|
+
Je({
|
|
5811
5972
|
position: i,
|
|
5812
5973
|
lngLat: n,
|
|
5813
5974
|
items: [{
|
|
@@ -5823,12 +5984,12 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5823
5984
|
}),
|
|
5824
5985
|
danger: !0,
|
|
5825
5986
|
onClick: () => {
|
|
5826
|
-
|
|
5987
|
+
wn.current.onEntityDelete?.(e);
|
|
5827
5988
|
}
|
|
5828
5989
|
}]
|
|
5829
5990
|
});
|
|
5830
|
-
}, []),
|
|
5831
|
-
|
|
5991
|
+
}, []), hn = useCallback(() => {
|
|
5992
|
+
Je(null);
|
|
5832
5993
|
}, []);
|
|
5833
5994
|
useEffect(() => {
|
|
5834
5995
|
let e = document.createElement("div");
|
|
@@ -5839,11 +6000,11 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5839
6000
|
width: 100%;
|
|
5840
6001
|
pointer-events: none;
|
|
5841
6002
|
height: 100%;
|
|
5842
|
-
z-index: ${
|
|
5843
|
-
`, document.body.appendChild(e),
|
|
6003
|
+
z-index: ${N?.zIndex ?? 1e3};
|
|
6004
|
+
`, document.body.appendChild(e), We.current = e, () => {
|
|
5844
6005
|
document.body.contains(e) && document.body.removeChild(e);
|
|
5845
6006
|
};
|
|
5846
|
-
}, [
|
|
6007
|
+
}, [N?.zIndex]), useEffect(() => {
|
|
5847
6008
|
let e = document.createElement("div");
|
|
5848
6009
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
5849
6010
|
position: fixed;
|
|
@@ -5852,61 +6013,61 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5852
6013
|
width: 100%;
|
|
5853
6014
|
pointer-events: none;
|
|
5854
6015
|
height: 100%;
|
|
5855
|
-
z-index: ${(
|
|
5856
|
-
`, document.body.appendChild(e),
|
|
6016
|
+
z-index: ${(N?.zIndex ?? 1e3) + 100};
|
|
6017
|
+
`, document.body.appendChild(e), Ye.current = e, () => {
|
|
5857
6018
|
document.body.contains(e) && document.body.removeChild(e);
|
|
5858
6019
|
};
|
|
5859
|
-
}, [
|
|
5860
|
-
let
|
|
5861
|
-
|
|
5862
|
-
let
|
|
5863
|
-
|
|
5864
|
-
let
|
|
5865
|
-
|
|
5866
|
-
let
|
|
5867
|
-
|
|
5868
|
-
let
|
|
5869
|
-
|
|
5870
|
-
let
|
|
5871
|
-
|
|
5872
|
-
let
|
|
5873
|
-
|
|
5874
|
-
let
|
|
5875
|
-
|
|
5876
|
-
let
|
|
5877
|
-
|
|
5878
|
-
let
|
|
5879
|
-
|
|
6020
|
+
}, [N?.zIndex]);
|
|
6021
|
+
let gn = useRef(T);
|
|
6022
|
+
gn.current = T;
|
|
6023
|
+
let _n = useRef(Ie);
|
|
6024
|
+
_n.current = Ie;
|
|
6025
|
+
let vn = useRef(ht);
|
|
6026
|
+
vn.current = ht;
|
|
6027
|
+
let yn = useRef(R);
|
|
6028
|
+
yn.current = R;
|
|
6029
|
+
let bn = useRef(b);
|
|
6030
|
+
bn.current = b;
|
|
6031
|
+
let xn = useRef(rt);
|
|
6032
|
+
xn.current = rt;
|
|
6033
|
+
let Sn = useRef(it);
|
|
6034
|
+
Sn.current = it;
|
|
6035
|
+
let Cn = useRef(at);
|
|
6036
|
+
Cn.current = at;
|
|
6037
|
+
let wn = useRef(v);
|
|
6038
|
+
wn.current = v;
|
|
6039
|
+
let Tn = useRef(D);
|
|
6040
|
+
Tn.current = D, useEffect(() => {
|
|
5880
6041
|
let e = (e) => {
|
|
5881
|
-
if (e.key === "Escape" &&
|
|
5882
|
-
if (
|
|
6042
|
+
if (e.key === "Escape" && R === "edit") {
|
|
6043
|
+
if (rt && (z(null), B(null), Y()), it === "rectangle") if (at) ot(null), Dt();
|
|
5883
6044
|
else {
|
|
5884
|
-
|
|
5885
|
-
let e =
|
|
6045
|
+
B(null);
|
|
6046
|
+
let e = P.current;
|
|
5886
6047
|
e && (e.getCanvas().style.cursor = "");
|
|
5887
6048
|
}
|
|
5888
|
-
if (
|
|
6049
|
+
if (it === "circle") if (st.current) st.current = null, Mt();
|
|
5889
6050
|
else {
|
|
5890
|
-
|
|
5891
|
-
let e =
|
|
6051
|
+
B(null);
|
|
6052
|
+
let e = P.current;
|
|
5892
6053
|
e && (e.getCanvas().style.cursor = "");
|
|
5893
6054
|
}
|
|
5894
|
-
if (
|
|
6055
|
+
if (it === "polygon") if (ct.current.length > 0) ct.current = [], It();
|
|
5895
6056
|
else {
|
|
5896
|
-
|
|
5897
|
-
let e =
|
|
6057
|
+
B(null);
|
|
6058
|
+
let e = P.current;
|
|
5898
6059
|
e && (e.getCanvas().style.cursor = "");
|
|
5899
6060
|
}
|
|
5900
|
-
if (
|
|
6061
|
+
if (it === "square") if (lt.current) lt.current = null, Vt();
|
|
5901
6062
|
else {
|
|
5902
|
-
|
|
5903
|
-
let e =
|
|
6063
|
+
B(null);
|
|
6064
|
+
let e = P.current;
|
|
5904
6065
|
e && (e.getCanvas().style.cursor = "");
|
|
5905
6066
|
}
|
|
5906
|
-
if (
|
|
6067
|
+
if (it === "polyline") if (ut.current.length > 0) ut.current = [], Gt();
|
|
5907
6068
|
else {
|
|
5908
|
-
|
|
5909
|
-
let e =
|
|
6069
|
+
B(null);
|
|
6070
|
+
let e = P.current;
|
|
5910
6071
|
e && (e.getCanvas().style.cursor = "");
|
|
5911
6072
|
}
|
|
5912
6073
|
}
|
|
@@ -5915,71 +6076,71 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5915
6076
|
document.removeEventListener("keydown", e);
|
|
5916
6077
|
};
|
|
5917
6078
|
}, [
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
Ot,
|
|
6079
|
+
R,
|
|
6080
|
+
rt,
|
|
6081
|
+
it,
|
|
6082
|
+
at,
|
|
6083
|
+
Y,
|
|
6084
|
+
Dt,
|
|
5925
6085
|
Mt,
|
|
5926
|
-
|
|
5927
|
-
Vt
|
|
6086
|
+
It,
|
|
6087
|
+
Vt,
|
|
6088
|
+
Gt
|
|
5928
6089
|
]), useEffect(() => {
|
|
5929
|
-
let e =
|
|
5930
|
-
if (!e || !
|
|
5931
|
-
let t =
|
|
5932
|
-
let r =
|
|
6090
|
+
let e = P.current;
|
|
6091
|
+
if (!e || !L) return;
|
|
6092
|
+
let t = L.entityId, n = L.config, r = () => {
|
|
6093
|
+
let r = gn.current.find((e) => e.id === t);
|
|
5933
6094
|
if (!r) {
|
|
5934
|
-
|
|
6095
|
+
_t();
|
|
5935
6096
|
return;
|
|
5936
6097
|
}
|
|
5937
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
5938
|
-
|
|
6098
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Ge.current);
|
|
6099
|
+
Ge.current && (Ge.current.style.left = `${i.x}px`, Ge.current.style.top = `${i.y}px`);
|
|
5939
6100
|
}, i = setTimeout(() => {
|
|
5940
6101
|
r();
|
|
5941
6102
|
}, 50);
|
|
5942
6103
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
5943
6104
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
5944
6105
|
};
|
|
5945
|
-
}, [
|
|
5946
|
-
let e =
|
|
5947
|
-
if (!e || !
|
|
5948
|
-
let n =
|
|
6106
|
+
}, [L?.entityId, _t]), useEffect(() => {
|
|
6107
|
+
let e = P.current, t = Ve.current;
|
|
6108
|
+
if (!e || !qe || !t) return;
|
|
6109
|
+
let n = qe.lngLat, r = () => {
|
|
5949
6110
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
5950
6111
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
5951
|
-
|
|
6112
|
+
hn();
|
|
5952
6113
|
return;
|
|
5953
6114
|
}
|
|
5954
6115
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
5955
|
-
|
|
6116
|
+
Xe.current && (Xe.current.style.left = `${s}px`, Xe.current.style.top = `${c}px`);
|
|
5956
6117
|
};
|
|
5957
6118
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
5958
6119
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
5959
6120
|
};
|
|
5960
|
-
}, [
|
|
5961
|
-
if (!
|
|
6121
|
+
}, [qe?.lngLat, hn]), useEffect(() => {
|
|
6122
|
+
if (!Ve.current) return;
|
|
5962
6123
|
let e = {
|
|
5963
6124
|
version: 8,
|
|
5964
6125
|
sources: {},
|
|
5965
6126
|
layers: []
|
|
5966
|
-
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate:
|
|
5967
|
-
container:
|
|
5968
|
-
style:
|
|
5969
|
-
center:
|
|
5970
|
-
zoom:
|
|
5971
|
-
pitch:
|
|
5972
|
-
bearing:
|
|
5973
|
-
maxBounds:
|
|
6127
|
+
}, { 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({
|
|
6128
|
+
container: Ve.current,
|
|
6129
|
+
style: h || e,
|
|
6130
|
+
center: l,
|
|
6131
|
+
zoom: u,
|
|
6132
|
+
pitch: d,
|
|
6133
|
+
bearing: f,
|
|
6134
|
+
maxBounds: g,
|
|
5974
6135
|
dragPan: t,
|
|
5975
6136
|
scrollZoom: n,
|
|
5976
6137
|
doubleClickZoom: r,
|
|
5977
6138
|
touchZoomRotate: i,
|
|
5978
6139
|
keyboard: a,
|
|
5979
|
-
dragRotate:
|
|
5980
|
-
pitchWithRotate:
|
|
6140
|
+
dragRotate: o,
|
|
6141
|
+
pitchWithRotate: c,
|
|
5981
6142
|
touchPitch: p,
|
|
5982
|
-
boxZoom:
|
|
6143
|
+
boxZoom: m,
|
|
5983
6144
|
transformRequest: (e, t) => {
|
|
5984
6145
|
if (t === "Glyphs") {
|
|
5985
6146
|
let t = e.match(/\/fonts\/([^/]+)\/(\d+-\d+)\.pbf/);
|
|
@@ -5991,156 +6152,181 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
5991
6152
|
return { url: e };
|
|
5992
6153
|
}
|
|
5993
6154
|
});
|
|
5994
|
-
return
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6155
|
+
return P.current = _, _.on("load", () => {
|
|
6156
|
+
if (!_.getStyle().glyphs) {
|
|
6157
|
+
let e = _.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
6158
|
+
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
6159
|
+
}
|
|
6160
|
+
I.current.clear(), T.forEach((e) => {
|
|
6161
|
+
I.current.set(e.id, e);
|
|
6162
|
+
}), ln(S), en(), Tt(), Ot(), Pt(), Rt(), Ut(), Qe(_), Fe?.(_);
|
|
6163
|
+
}), _.on("click", dn), _.on("mousemove", fn), _.on("contextmenu", pn), () => {
|
|
6164
|
+
_.off("click", dn), _.off("mousemove", fn), _.off("contextmenu", pn), tn(), St(), Y(), Z(), Q(), _.remove(), P.current = null;
|
|
6000
6165
|
};
|
|
6001
6166
|
}, []), useEffect(() => {
|
|
6002
|
-
if (
|
|
6003
|
-
if (!
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
}),
|
|
6167
|
+
if (P.current) {
|
|
6168
|
+
if (!P.current.isStyleLoaded()) {
|
|
6169
|
+
P.current.once("load", () => {
|
|
6170
|
+
I.current.clear(), T.forEach((e) => {
|
|
6171
|
+
I.current.set(e.id, e);
|
|
6172
|
+
}), en();
|
|
6008
6173
|
});
|
|
6009
6174
|
return;
|
|
6010
6175
|
}
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
}),
|
|
6176
|
+
I.current.clear(), T.forEach((e) => {
|
|
6177
|
+
I.current.set(e.id, e);
|
|
6178
|
+
}), en();
|
|
6014
6179
|
}
|
|
6015
|
-
}, [
|
|
6016
|
-
!
|
|
6180
|
+
}, [T, en]), useEffect(() => {
|
|
6181
|
+
!P.current || !P.current.isStyleLoaded() || (tn(), en());
|
|
6017
6182
|
}, [
|
|
6018
|
-
w,
|
|
6019
|
-
T,
|
|
6020
|
-
E,
|
|
6021
|
-
D,
|
|
6022
6183
|
O,
|
|
6023
|
-
|
|
6024
|
-
|
|
6184
|
+
k,
|
|
6185
|
+
A,
|
|
6186
|
+
j,
|
|
6187
|
+
M,
|
|
6188
|
+
tn,
|
|
6189
|
+
en
|
|
6025
6190
|
]), useEffect(() => {
|
|
6026
|
-
if (
|
|
6027
|
-
if (!
|
|
6028
|
-
|
|
6029
|
-
|
|
6191
|
+
if (P.current) {
|
|
6192
|
+
if (!P.current.isStyleLoaded()) {
|
|
6193
|
+
P.current.once("load", () => {
|
|
6194
|
+
ln(S);
|
|
6030
6195
|
});
|
|
6031
6196
|
return;
|
|
6032
6197
|
}
|
|
6033
|
-
|
|
6198
|
+
ln(S);
|
|
6034
6199
|
}
|
|
6035
|
-
}, [
|
|
6036
|
-
let
|
|
6037
|
-
|
|
6038
|
-
let
|
|
6039
|
-
|
|
6040
|
-
let
|
|
6041
|
-
|
|
6042
|
-
let
|
|
6043
|
-
|
|
6044
|
-
let
|
|
6045
|
-
|
|
6046
|
-
let
|
|
6047
|
-
|
|
6048
|
-
let
|
|
6049
|
-
|
|
6050
|
-
let
|
|
6051
|
-
|
|
6052
|
-
let
|
|
6053
|
-
|
|
6054
|
-
let e =
|
|
6200
|
+
}, [S, ln]);
|
|
6201
|
+
let En = useRef(void 0), Dn = useRef(!0), On = useRef(S);
|
|
6202
|
+
On.current = S;
|
|
6203
|
+
let kn = useRef(ln);
|
|
6204
|
+
kn.current = ln;
|
|
6205
|
+
let An = useRef(tn);
|
|
6206
|
+
An.current = tn;
|
|
6207
|
+
let jn = useRef(en);
|
|
6208
|
+
jn.current = en;
|
|
6209
|
+
let Mn = useRef(Tt);
|
|
6210
|
+
Mn.current = Tt;
|
|
6211
|
+
let Nn = useRef(Ot);
|
|
6212
|
+
Nn.current = Ot;
|
|
6213
|
+
let Pn = useRef(Pt);
|
|
6214
|
+
Pn.current = Pt;
|
|
6215
|
+
let Fn = useRef(Rt);
|
|
6216
|
+
Fn.current = Rt;
|
|
6217
|
+
let In = useRef(Ut);
|
|
6218
|
+
In.current = Ut, useEffect(() => {
|
|
6219
|
+
let e = P.current;
|
|
6055
6220
|
if (!e) return;
|
|
6056
|
-
let t =
|
|
6221
|
+
let t = h || {
|
|
6057
6222
|
version: 8,
|
|
6058
6223
|
sources: {},
|
|
6059
6224
|
layers: []
|
|
6060
6225
|
};
|
|
6061
|
-
if (
|
|
6062
|
-
|
|
6226
|
+
if (Dn.current) {
|
|
6227
|
+
Dn.current = !1, En.current = h;
|
|
6063
6228
|
return;
|
|
6064
6229
|
}
|
|
6065
|
-
|
|
6066
|
-
|
|
6230
|
+
En.current !== h && (En.current = h, e.setStyle(t), e.once("style.load", () => {
|
|
6231
|
+
if (!e.getStyle().glyphs) {
|
|
6232
|
+
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
6233
|
+
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
6234
|
+
}
|
|
6235
|
+
He.current.clear(), kn.current(On.current), An.current(), jn.current(), Mn.current(), Nn.current(), Pn.current(), Fn.current(), In.current();
|
|
6067
6236
|
}));
|
|
6068
|
-
}, [
|
|
6069
|
-
let e = new Set(
|
|
6070
|
-
for (let [t, n] of
|
|
6071
|
-
}, [
|
|
6072
|
-
let
|
|
6237
|
+
}, [h]), useEffect(() => {
|
|
6238
|
+
let e = new Set(E.map(String));
|
|
6239
|
+
for (let [t, n] of F.current) n.setSelected(e.has(String(t)));
|
|
6240
|
+
}, [E]);
|
|
6241
|
+
let Ln = useRef({});
|
|
6073
6242
|
useEffect(() => {
|
|
6074
|
-
let e =
|
|
6243
|
+
let e = P.current;
|
|
6075
6244
|
if (!e) return;
|
|
6076
|
-
let t =
|
|
6077
|
-
!n && !r && !i && !a || (
|
|
6078
|
-
center:
|
|
6079
|
-
zoom:
|
|
6080
|
-
pitch:
|
|
6081
|
-
bearing:
|
|
6245
|
+
let t = Ln.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;
|
|
6246
|
+
!n && !r && !i && !a || (Ln.current = {
|
|
6247
|
+
center: l,
|
|
6248
|
+
zoom: u,
|
|
6249
|
+
pitch: d,
|
|
6250
|
+
bearing: f
|
|
6082
6251
|
}, e.jumpTo({
|
|
6083
|
-
center:
|
|
6084
|
-
zoom:
|
|
6085
|
-
pitch:
|
|
6086
|
-
bearing:
|
|
6252
|
+
center: l,
|
|
6253
|
+
zoom: u,
|
|
6254
|
+
pitch: d,
|
|
6255
|
+
bearing: f
|
|
6087
6256
|
}));
|
|
6088
6257
|
}, [
|
|
6089
|
-
c,
|
|
6090
6258
|
l,
|
|
6091
6259
|
u,
|
|
6092
|
-
d
|
|
6260
|
+
d,
|
|
6261
|
+
f
|
|
6093
6262
|
]);
|
|
6094
|
-
let
|
|
6095
|
-
if (
|
|
6263
|
+
let Rn = (() => be === !1 ? null : be === !0 ? { enabled: !0 } : be)(), zn = (() => Se === !1 ? null : Se === !0 ? { enabled: !0 } : Se)(), Bn = (() => Ee === !1 ? null : Ee === !0 ? { enabled: !0 } : Ee)(), $ = (() => {
|
|
6264
|
+
if (De === !1) return null;
|
|
6096
6265
|
let e, t;
|
|
6097
|
-
if (
|
|
6098
|
-
let n =
|
|
6099
|
-
|
|
6266
|
+
if (S && S.length > 0) {
|
|
6267
|
+
let n = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
6268
|
+
if (n.type === "style") {
|
|
6269
|
+
let t = P.current?.getStyle();
|
|
6270
|
+
if (t?.sources) {
|
|
6271
|
+
let r = `base-layer-source-${n.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(r));
|
|
6272
|
+
i && (e = i);
|
|
6273
|
+
}
|
|
6274
|
+
} else e = `base-layer-source-${n.id}`;
|
|
6275
|
+
t = n.roadNetworkSourceLayer || "road";
|
|
6100
6276
|
}
|
|
6101
|
-
return
|
|
6277
|
+
return De === !0 ? {
|
|
6102
6278
|
enabled: !0,
|
|
6103
6279
|
source: e,
|
|
6104
6280
|
sourceLayer: t
|
|
6105
6281
|
} : {
|
|
6106
|
-
...
|
|
6107
|
-
source:
|
|
6108
|
-
sourceLayer:
|
|
6282
|
+
...De,
|
|
6283
|
+
source: De.source || e,
|
|
6284
|
+
sourceLayer: De.sourceLayer || t
|
|
6109
6285
|
};
|
|
6110
|
-
})(),
|
|
6286
|
+
})(), Vn = (() => Oe ? Oe === !0 ? { enabled: !0 } : Oe : null)(), Hn = (() => Ae ? Ae === !0 ? { enabled: !0 } : Ae : null)(), Un = useMemo(() => {
|
|
6287
|
+
let e = [];
|
|
6288
|
+
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
6289
|
+
let n = P.current;
|
|
6290
|
+
if (n) {
|
|
6291
|
+
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
6292
|
+
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
6293
|
+
}
|
|
6294
|
+
} else e.push(`base-layer-${t.id}`);
|
|
6295
|
+
return e;
|
|
6296
|
+
}, [S, Ze]);
|
|
6111
6297
|
return /* @__PURE__ */ jsxs("div", {
|
|
6112
|
-
className: `comp-mapbox ${
|
|
6113
|
-
style:
|
|
6298
|
+
className: `comp-mapbox ${R === "picker" ? "comp-mapbox--picker-mode" : ""} ${ze}`,
|
|
6299
|
+
style: Be,
|
|
6114
6300
|
children: [
|
|
6115
6301
|
/* @__PURE__ */ jsx("div", {
|
|
6116
|
-
ref:
|
|
6302
|
+
ref: Ve,
|
|
6117
6303
|
className: "comp-mapbox__map"
|
|
6118
6304
|
}),
|
|
6119
|
-
|
|
6305
|
+
R === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
6120
6306
|
className: "comp-mapbox__crosshair",
|
|
6121
6307
|
children: [/* @__PURE__ */ jsx("div", {
|
|
6122
6308
|
className: "comp-mapbox__crosshair-h",
|
|
6123
|
-
style:
|
|
6309
|
+
style: y.crosshairColor ? { backgroundColor: y.crosshairColor } : void 0
|
|
6124
6310
|
}), /* @__PURE__ */ jsx("div", {
|
|
6125
6311
|
className: "comp-mapbox__crosshair-v",
|
|
6126
|
-
style:
|
|
6312
|
+
style: y.crosshairColor ? { backgroundColor: y.crosshairColor } : void 0
|
|
6127
6313
|
})]
|
|
6128
6314
|
}),
|
|
6129
|
-
|
|
6315
|
+
R === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
|
|
6130
6316
|
className: "comp-mapbox__edit-controls",
|
|
6131
|
-
children: [
|
|
6132
|
-
markerTemplates:
|
|
6133
|
-
selectedTemplate:
|
|
6134
|
-
onTemplateSelect:
|
|
6135
|
-
drawMode:
|
|
6136
|
-
onDrawModeChange:
|
|
6137
|
-
showRectangleTool:
|
|
6138
|
-
showCircleTool:
|
|
6139
|
-
showPolygonTool:
|
|
6140
|
-
showSquareTool:
|
|
6141
|
-
showPolylineTool:
|
|
6317
|
+
children: [R === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
6318
|
+
markerTemplates: v.markerTemplates || [],
|
|
6319
|
+
selectedTemplate: rt,
|
|
6320
|
+
onTemplateSelect: Kt,
|
|
6321
|
+
drawMode: it,
|
|
6322
|
+
onDrawModeChange: qt,
|
|
6323
|
+
showRectangleTool: v.showRectangleTool,
|
|
6324
|
+
showCircleTool: v.showCircleTool,
|
|
6325
|
+
showPolygonTool: v.showPolygonTool,
|
|
6326
|
+
showSquareTool: v.showSquareTool,
|
|
6327
|
+
showPolylineTool: v.showPolylineTool
|
|
6142
6328
|
}), $ && $.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
6143
|
-
map:
|
|
6329
|
+
map: Ze,
|
|
6144
6330
|
highlightWidth: $.highlightWidth,
|
|
6145
6331
|
defaultRoadTypes: $.defaultRoadTypes,
|
|
6146
6332
|
defaultMinWidth: $.defaultMinWidth,
|
|
@@ -6150,51 +6336,59 @@ const Mapbox = forwardRef((e, s) => {
|
|
|
6150
6336
|
style: $.style
|
|
6151
6337
|
})]
|
|
6152
6338
|
}) : null,
|
|
6153
|
-
(
|
|
6339
|
+
(Rn?.enabled !== !1 || zn?.enabled !== !1 || Bn?.enabled !== !1 || Vn && Vn.enabled !== !1 || Hn && Hn.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
6154
6340
|
className: "comp-mapbox__controls",
|
|
6155
6341
|
children: [
|
|
6156
|
-
|
|
6157
|
-
map:
|
|
6158
|
-
precision:
|
|
6159
|
-
className:
|
|
6160
|
-
style:
|
|
6342
|
+
Rn && Rn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
6343
|
+
map: Ze,
|
|
6344
|
+
precision: Rn.precision,
|
|
6345
|
+
className: Rn.className,
|
|
6346
|
+
style: Rn.style
|
|
6347
|
+
}),
|
|
6348
|
+
zn && zn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
6349
|
+
map: Ze,
|
|
6350
|
+
maxWidth: zn.maxWidth,
|
|
6351
|
+
unit: zn.unit,
|
|
6352
|
+
className: zn.className,
|
|
6353
|
+
style: zn.style
|
|
6161
6354
|
}),
|
|
6162
|
-
|
|
6163
|
-
map:
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
style: Nn.style
|
|
6355
|
+
Vn && Vn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
6356
|
+
map: Ze,
|
|
6357
|
+
entityConfig: D,
|
|
6358
|
+
className: Vn.className,
|
|
6359
|
+
style: Vn.style
|
|
6168
6360
|
}),
|
|
6169
|
-
|
|
6170
|
-
map:
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6361
|
+
Hn && Hn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
6362
|
+
map: Ze,
|
|
6363
|
+
value: C,
|
|
6364
|
+
onChange: je,
|
|
6365
|
+
rasterPaintLayerIds: Un,
|
|
6366
|
+
className: Hn.className,
|
|
6367
|
+
style: Hn.style
|
|
6174
6368
|
}),
|
|
6175
|
-
|
|
6176
|
-
map:
|
|
6177
|
-
initialCenter:
|
|
6178
|
-
initialZoom:
|
|
6179
|
-
initialPitch:
|
|
6180
|
-
initialBearing:
|
|
6181
|
-
duration:
|
|
6182
|
-
className:
|
|
6183
|
-
style:
|
|
6369
|
+
Bn && Bn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
6370
|
+
map: Ze,
|
|
6371
|
+
initialCenter: l,
|
|
6372
|
+
initialZoom: u,
|
|
6373
|
+
initialPitch: d,
|
|
6374
|
+
initialBearing: f,
|
|
6375
|
+
duration: Bn.duration,
|
|
6376
|
+
className: Bn.className,
|
|
6377
|
+
style: Bn.style
|
|
6184
6378
|
})
|
|
6185
6379
|
]
|
|
6186
6380
|
}),
|
|
6187
|
-
|
|
6188
|
-
popupState:
|
|
6189
|
-
onClose: () =>
|
|
6190
|
-
portalContainer:
|
|
6191
|
-
popupRef:
|
|
6381
|
+
L && We.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
6382
|
+
popupState: L,
|
|
6383
|
+
onClose: () => gt(L.entityId),
|
|
6384
|
+
portalContainer: We.current,
|
|
6385
|
+
popupRef: Ge
|
|
6192
6386
|
}),
|
|
6193
|
-
|
|
6194
|
-
menuState:
|
|
6195
|
-
onClose:
|
|
6196
|
-
portalContainer:
|
|
6197
|
-
menuRef:
|
|
6387
|
+
qe && Ye.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
6388
|
+
menuState: qe,
|
|
6389
|
+
onClose: hn,
|
|
6390
|
+
portalContainer: Ye.current,
|
|
6391
|
+
menuRef: Xe
|
|
6198
6392
|
})
|
|
6199
6393
|
]
|
|
6200
6394
|
});
|