bbl-mapbox-react 0.0.31 → 0.0.32
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/AttackDirectionRenderer.d.ts +47 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +896 -520
- package/dist/types.d.ts +30 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1582,6 +1582,371 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
1582
1582
|
destroy() {
|
|
1583
1583
|
this.initialized &&= (this.removeEditLayers(), 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);
|
|
1584
1584
|
}
|
|
1585
|
+
};
|
|
1586
|
+
function bezierPoint(e, t, n, r) {
|
|
1587
|
+
let i = 1 - r;
|
|
1588
|
+
return [i * i * e[0] + 2 * i * r * t[0] + r * r * n[0], i * i * e[1] + 2 * i * r * t[1] + r * r * n[1]];
|
|
1589
|
+
}
|
|
1590
|
+
function bezierTangentBearing(e, t, n, r) {
|
|
1591
|
+
let i = .001, a = Math.max(0, r - i), o = Math.min(1, r + i);
|
|
1592
|
+
return bearing(bezierPoint(e, t, n, a), bezierPoint(e, t, n, o));
|
|
1593
|
+
}
|
|
1594
|
+
function generateArrowShape(e, t, n, r, i = 64) {
|
|
1595
|
+
let a = .92, o = r / 6, s = o * 3, c = [], l = [], u = Math.round(i * a);
|
|
1596
|
+
for (let i = 0; i <= u; i++) {
|
|
1597
|
+
let s = i / u * a, d = bezierPoint(e, t, n, s), f = bezierTangentBearing(e, t, n, s), p = 1 - s / a, m = (o + (r - o) * p * p) / 2;
|
|
1598
|
+
c.push(destinationPoint(d, m, f + 90)), l.push(destinationPoint(d, m, f - 90));
|
|
1599
|
+
}
|
|
1600
|
+
let d = bezierPoint(e, t, n, 1), f = c[c.length - 1], p = l[l.length - 1], m = a - .01, h = bezierPoint(e, t, n, m), g = bezierTangentBearing(e, t, n, m), _ = destinationPoint(h, s / 2, g + 90), v = destinationPoint(h, s / 2, g - 90), y = [...l].reverse(), b = [
|
|
1601
|
+
...c,
|
|
1602
|
+
_,
|
|
1603
|
+
d,
|
|
1604
|
+
v,
|
|
1605
|
+
...y,
|
|
1606
|
+
c[0]
|
|
1607
|
+
], x = [
|
|
1608
|
+
[...c],
|
|
1609
|
+
[...l],
|
|
1610
|
+
[
|
|
1611
|
+
f,
|
|
1612
|
+
_,
|
|
1613
|
+
d,
|
|
1614
|
+
v,
|
|
1615
|
+
p
|
|
1616
|
+
]
|
|
1617
|
+
];
|
|
1618
|
+
return {
|
|
1619
|
+
polygon: b,
|
|
1620
|
+
strokes: x
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
var AttackDirectionRenderer = class e {
|
|
1624
|
+
static {
|
|
1625
|
+
this.DEFAULTS = {
|
|
1626
|
+
strokeColor: "#FF0000",
|
|
1627
|
+
strokeWidth: 2,
|
|
1628
|
+
strokeOpacity: 1,
|
|
1629
|
+
fillColor: "#FF0000",
|
|
1630
|
+
fillOpacity: .35,
|
|
1631
|
+
tailWidthRatio: .18
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
constructor(e, t, n, r) {
|
|
1635
|
+
this.isSelected = !1, this.initialized = !1, this.cachedPolygon = [], this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.sourceId = `attack-direction-source-${t.id}`, this.fillLayerId = `attack-direction-fill-${t.id}`, this.strokeLayerId = `attack-direction-stroke-${t.id}`, this.labelLayerId = `attack-direction-label-${t.id}`, this.editSourceId = `attack-direction-edit-source-${t.id}`, this.editHandleLayerId = `attack-direction-edit-handles-${t.id}`, this.editMoveLayerId = `attack-direction-edit-move-${t.id}`, this.initLayers();
|
|
1636
|
+
}
|
|
1637
|
+
resolveTailWidth(t) {
|
|
1638
|
+
let n = t ?? this.entity.coordinates;
|
|
1639
|
+
return this.entity.tailWidthRatio == null ? this.entity.tailWidth == null ? distance(n[0], n[2]) * e.DEFAULTS.tailWidthRatio : this.entity.tailWidth : distance(n[0], n[2]) * this.entity.tailWidthRatio;
|
|
1640
|
+
}
|
|
1641
|
+
get nameStyle() {
|
|
1642
|
+
return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
|
|
1643
|
+
}
|
|
1644
|
+
get selectNameStyle() {
|
|
1645
|
+
return resolveNameConfig(this.entity.selectNameConfig, this.globalSelectNameConfig, DEFAULT_SELECT_NAME_CONFIG);
|
|
1646
|
+
}
|
|
1647
|
+
initLayers() {
|
|
1648
|
+
if (!this.initialized) try {
|
|
1649
|
+
let t = this.getGeoJSON();
|
|
1650
|
+
this.map.addSource(this.sourceId, {
|
|
1651
|
+
type: "geojson",
|
|
1652
|
+
data: t
|
|
1653
|
+
});
|
|
1654
|
+
let n = this.entity.confidence ?? 1, r = confidenceToOpacity(n);
|
|
1655
|
+
this.map.addLayer({
|
|
1656
|
+
id: this.fillLayerId,
|
|
1657
|
+
type: "fill",
|
|
1658
|
+
source: this.sourceId,
|
|
1659
|
+
filter: [
|
|
1660
|
+
"==",
|
|
1661
|
+
"$type",
|
|
1662
|
+
"Polygon"
|
|
1663
|
+
],
|
|
1664
|
+
paint: {
|
|
1665
|
+
"fill-color": this.entity.fillColor ?? e.DEFAULTS.fillColor,
|
|
1666
|
+
"fill-opacity": (this.entity.fillOpacity ?? e.DEFAULTS.fillOpacity) * r
|
|
1667
|
+
}
|
|
1668
|
+
}), this.map.addLayer({
|
|
1669
|
+
id: this.strokeLayerId,
|
|
1670
|
+
type: "line",
|
|
1671
|
+
source: this.sourceId,
|
|
1672
|
+
filter: [
|
|
1673
|
+
"==",
|
|
1674
|
+
"$type",
|
|
1675
|
+
"LineString"
|
|
1676
|
+
],
|
|
1677
|
+
layout: {
|
|
1678
|
+
"line-join": "round",
|
|
1679
|
+
"line-cap": "round"
|
|
1680
|
+
},
|
|
1681
|
+
paint: {
|
|
1682
|
+
"line-color": this.isSelected ? "#ffcc00" : this.entity.strokeColor ?? e.DEFAULTS.strokeColor,
|
|
1683
|
+
"line-width": this.entity.strokeWidth ?? e.DEFAULTS.strokeWidth,
|
|
1684
|
+
"line-opacity": (this.entity.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * r
|
|
1685
|
+
}
|
|
1686
|
+
}), this.entity.name && this.map.addLayer({
|
|
1687
|
+
id: this.labelLayerId,
|
|
1688
|
+
type: "symbol",
|
|
1689
|
+
source: this.sourceId,
|
|
1690
|
+
filter: [
|
|
1691
|
+
"==",
|
|
1692
|
+
["get", "pointType"],
|
|
1693
|
+
"label"
|
|
1694
|
+
],
|
|
1695
|
+
layout: {
|
|
1696
|
+
"text-field": ["get", "name"],
|
|
1697
|
+
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
1698
|
+
"text-size": 14,
|
|
1699
|
+
"text-anchor": "top",
|
|
1700
|
+
"text-offset": [0, .8],
|
|
1701
|
+
"text-allow-overlap": !0
|
|
1702
|
+
},
|
|
1703
|
+
paint: {
|
|
1704
|
+
"text-color": this.isSelected ? this.selectNameStyle.fillColor : this.nameStyle.fillColor,
|
|
1705
|
+
"text-halo-color": this.isSelected ? this.selectNameStyle.strokeColor : this.nameStyle.strokeColor,
|
|
1706
|
+
"text-halo-width": this.isSelected ? this.selectNameStyle.strokeWidth : this.nameStyle.strokeWidth,
|
|
1707
|
+
"text-opacity": r
|
|
1708
|
+
}
|
|
1709
|
+
}), this.initialized = !0;
|
|
1710
|
+
} catch {
|
|
1711
|
+
this.map.once("idle", () => this.initLayers());
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
getGeoJSON(e) {
|
|
1715
|
+
let t = e ?? this.entity.coordinates;
|
|
1716
|
+
if (!t || t.length < 3) return {
|
|
1717
|
+
type: "FeatureCollection",
|
|
1718
|
+
features: []
|
|
1719
|
+
};
|
|
1720
|
+
let n = this.resolveTailWidth(t), r = generateArrowShape(t[0], t[1], t[2], n);
|
|
1721
|
+
this.cachedPolygon = r.polygon;
|
|
1722
|
+
let i = [{
|
|
1723
|
+
type: "Feature",
|
|
1724
|
+
geometry: {
|
|
1725
|
+
type: "Polygon",
|
|
1726
|
+
coordinates: [r.polygon]
|
|
1727
|
+
},
|
|
1728
|
+
properties: {}
|
|
1729
|
+
}, ...r.strokes.map((e, t) => ({
|
|
1730
|
+
type: "Feature",
|
|
1731
|
+
geometry: {
|
|
1732
|
+
type: "LineString",
|
|
1733
|
+
coordinates: e
|
|
1734
|
+
},
|
|
1735
|
+
properties: { strokeIndex: t }
|
|
1736
|
+
}))];
|
|
1737
|
+
return this.entity.name && i.push({
|
|
1738
|
+
type: "Feature",
|
|
1739
|
+
geometry: {
|
|
1740
|
+
type: "Point",
|
|
1741
|
+
coordinates: t[0]
|
|
1742
|
+
},
|
|
1743
|
+
properties: {
|
|
1744
|
+
pointType: "label",
|
|
1745
|
+
name: this.entity.name
|
|
1746
|
+
}
|
|
1747
|
+
}), {
|
|
1748
|
+
type: "FeatureCollection",
|
|
1749
|
+
features: i
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
getEntityId() {
|
|
1753
|
+
return this.entity.id;
|
|
1754
|
+
}
|
|
1755
|
+
getCenter() {
|
|
1756
|
+
if (this.entity.center) return this.entity.center;
|
|
1757
|
+
let e = this.entity.coordinates;
|
|
1758
|
+
return [(e[0][0] + e[1][0] + e[2][0]) / 3, (e[0][1] + e[1][1] + e[2][1]) / 3];
|
|
1759
|
+
}
|
|
1760
|
+
getBounds() {
|
|
1761
|
+
let e = this.cachedPolygon;
|
|
1762
|
+
if (!e || e.length === 0) {
|
|
1763
|
+
let e = this.getCenter();
|
|
1764
|
+
return [e, e];
|
|
1765
|
+
}
|
|
1766
|
+
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity;
|
|
1767
|
+
for (let a of e) t = Math.min(t, a[0]), n = Math.max(n, a[0]), r = Math.min(r, a[1]), i = Math.max(i, a[1]);
|
|
1768
|
+
return [[t, r], [n, i]];
|
|
1769
|
+
}
|
|
1770
|
+
getLayerId() {
|
|
1771
|
+
return this.fillLayerId;
|
|
1772
|
+
}
|
|
1773
|
+
getLabelLayerId() {
|
|
1774
|
+
return this.entity.name ? this.labelLayerId : null;
|
|
1775
|
+
}
|
|
1776
|
+
setSelected(t) {
|
|
1777
|
+
this.isSelected !== t && (this.isSelected = t, this.initialized && (this.map.getLayer(this.strokeLayerId) && this.map.setPaintProperty(this.strokeLayerId, "line-color", t ? "#ffcc00" : this.entity.strokeColor ?? e.DEFAULTS.strokeColor), this.map.getLayer(this.labelLayerId) && (this.map.setPaintProperty(this.labelLayerId, "text-color", t ? this.selectNameStyle.fillColor : this.nameStyle.fillColor), this.map.setPaintProperty(this.labelLayerId, "text-halo-color", t ? this.selectNameStyle.strokeColor : this.nameStyle.strokeColor), this.map.setPaintProperty(this.labelLayerId, "text-halo-width", t ? this.selectNameStyle.strokeWidth : this.nameStyle.strokeWidth))));
|
|
1778
|
+
}
|
|
1779
|
+
isPointInEntity(e) {
|
|
1780
|
+
return !this.cachedPolygon || this.cachedPolygon.length < 3 ? !1 : this.pointInPolygon(e, this.cachedPolygon);
|
|
1781
|
+
}
|
|
1782
|
+
pointInPolygon(e, t) {
|
|
1783
|
+
let [n, r] = e, i = !1;
|
|
1784
|
+
for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
|
|
1785
|
+
let [o, s] = t[e], [c, l] = t[a];
|
|
1786
|
+
s > r != l > r && n < (c - o) * (r - s) / (l - s) + o && (i = !i);
|
|
1787
|
+
}
|
|
1788
|
+
return i;
|
|
1789
|
+
}
|
|
1790
|
+
update(t) {
|
|
1791
|
+
let n = this.entity;
|
|
1792
|
+
if (this.entity = t, !this.initialized) return;
|
|
1793
|
+
let r = t.confidence ?? 1, i = confidenceToOpacity(r);
|
|
1794
|
+
if (n.coordinates !== t.coordinates || n.tailWidth !== t.tailWidth || n.shape !== t.shape || n.name !== t.name) {
|
|
1795
|
+
let e = this.map.getSource(this.sourceId);
|
|
1796
|
+
e && e.setData(this.getGeoJSON()), !n.name && t.name && !this.map.getLayer(this.labelLayerId) ? this.map.addLayer({
|
|
1797
|
+
id: this.labelLayerId,
|
|
1798
|
+
type: "symbol",
|
|
1799
|
+
source: this.sourceId,
|
|
1800
|
+
filter: [
|
|
1801
|
+
"==",
|
|
1802
|
+
["get", "pointType"],
|
|
1803
|
+
"label"
|
|
1804
|
+
],
|
|
1805
|
+
layout: {
|
|
1806
|
+
"text-field": ["get", "name"],
|
|
1807
|
+
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
1808
|
+
"text-size": 14,
|
|
1809
|
+
"text-anchor": "top",
|
|
1810
|
+
"text-offset": [0, .8],
|
|
1811
|
+
"text-allow-overlap": !0
|
|
1812
|
+
},
|
|
1813
|
+
paint: {
|
|
1814
|
+
"text-color": this.isSelected ? this.selectNameStyle.fillColor : this.nameStyle.fillColor,
|
|
1815
|
+
"text-halo-color": this.isSelected ? this.selectNameStyle.strokeColor : this.nameStyle.strokeColor,
|
|
1816
|
+
"text-halo-width": this.isSelected ? this.selectNameStyle.strokeWidth : this.nameStyle.strokeWidth,
|
|
1817
|
+
"text-opacity": i
|
|
1818
|
+
}
|
|
1819
|
+
}) : n.name && !t.name && this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId);
|
|
1820
|
+
}
|
|
1821
|
+
(n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i);
|
|
1822
|
+
}
|
|
1823
|
+
getEditHandleGeoJSON(e) {
|
|
1824
|
+
let t = e ?? this.entity.coordinates, n = [];
|
|
1825
|
+
for (let e = 0; e < 3; e++) n.push({
|
|
1826
|
+
type: "Feature",
|
|
1827
|
+
geometry: {
|
|
1828
|
+
type: "Point",
|
|
1829
|
+
coordinates: t[e]
|
|
1830
|
+
},
|
|
1831
|
+
properties: {
|
|
1832
|
+
handleType: "vertex",
|
|
1833
|
+
index: e
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
let r = bezierTangentBearing(t[0], t[1], t[2], 0) + 90, i = this.resolveTailWidth(e), a = destinationPoint(t[0], i * .6, r);
|
|
1837
|
+
return n.push({
|
|
1838
|
+
type: "Feature",
|
|
1839
|
+
geometry: {
|
|
1840
|
+
type: "Point",
|
|
1841
|
+
coordinates: a
|
|
1842
|
+
},
|
|
1843
|
+
properties: {
|
|
1844
|
+
handleType: "move",
|
|
1845
|
+
index: 0
|
|
1846
|
+
}
|
|
1847
|
+
}), {
|
|
1848
|
+
type: "FeatureCollection",
|
|
1849
|
+
features: n
|
|
1850
|
+
};
|
|
1851
|
+
}
|
|
1852
|
+
createEditLayers() {
|
|
1853
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
1854
|
+
type: "geojson",
|
|
1855
|
+
data: this.getEditHandleGeoJSON()
|
|
1856
|
+
}), this.map.addLayer({
|
|
1857
|
+
id: this.editHandleLayerId,
|
|
1858
|
+
type: "circle",
|
|
1859
|
+
source: this.editSourceId,
|
|
1860
|
+
filter: [
|
|
1861
|
+
"==",
|
|
1862
|
+
["get", "handleType"],
|
|
1863
|
+
"vertex"
|
|
1864
|
+
],
|
|
1865
|
+
paint: {
|
|
1866
|
+
"circle-radius": 6,
|
|
1867
|
+
"circle-color": "#ffffff",
|
|
1868
|
+
"circle-stroke-color": "#3388ff",
|
|
1869
|
+
"circle-stroke-width": 2
|
|
1870
|
+
}
|
|
1871
|
+
}), this.map.addLayer({
|
|
1872
|
+
id: this.editMoveLayerId,
|
|
1873
|
+
type: "symbol",
|
|
1874
|
+
source: this.editSourceId,
|
|
1875
|
+
filter: [
|
|
1876
|
+
"==",
|
|
1877
|
+
["get", "handleType"],
|
|
1878
|
+
"move"
|
|
1879
|
+
],
|
|
1880
|
+
layout: {
|
|
1881
|
+
"icon-image": MOVE_ICON_ID,
|
|
1882
|
+
"icon-allow-overlap": !0,
|
|
1883
|
+
"icon-ignore-placement": !0
|
|
1884
|
+
}
|
|
1885
|
+
}));
|
|
1886
|
+
}
|
|
1887
|
+
removeEditLayers() {
|
|
1888
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
1889
|
+
}
|
|
1890
|
+
refreshEditHandles(e) {
|
|
1891
|
+
let t = this.map.getSource(this.editSourceId);
|
|
1892
|
+
t && t.setData(this.getEditHandleGeoJSON(e));
|
|
1893
|
+
}
|
|
1894
|
+
setEditing(e) {
|
|
1895
|
+
this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
|
|
1896
|
+
}
|
|
1897
|
+
getEditHandleAt(e, t) {
|
|
1898
|
+
if (!this.isEditing) return null;
|
|
1899
|
+
let n = this.entity.coordinates, r = this.map.project(e), i = bezierTangentBearing(n[0], n[1], n[2], 0) + 90, a = this.resolveTailWidth(), o = destinationPoint(n[0], a * .6, i), s = this.map.project(o), c = r.x - s.x, l = r.y - s.y;
|
|
1900
|
+
if (c * c + l * l <= 144) return {
|
|
1901
|
+
type: "move",
|
|
1902
|
+
index: 0,
|
|
1903
|
+
position: o
|
|
1904
|
+
};
|
|
1905
|
+
for (let e = 0; e < 3; e++) {
|
|
1906
|
+
let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
|
|
1907
|
+
if (i * i + a * a <= 100) return {
|
|
1908
|
+
type: "vertex",
|
|
1909
|
+
index: e,
|
|
1910
|
+
position: n[e]
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
return null;
|
|
1914
|
+
}
|
|
1915
|
+
applyHandleMove(e, t) {
|
|
1916
|
+
let n;
|
|
1917
|
+
if (e.type === "move") {
|
|
1918
|
+
let r = t[0] - e.position[0], i = t[1] - e.position[1];
|
|
1919
|
+
n = this.entity.coordinates.map((e) => [e[0] + r, e[1] + i]);
|
|
1920
|
+
} else n = [...this.entity.coordinates], n[e.index] = t;
|
|
1921
|
+
let r = {
|
|
1922
|
+
...this.entity,
|
|
1923
|
+
coordinates: n
|
|
1924
|
+
};
|
|
1925
|
+
this.entity = r;
|
|
1926
|
+
let i = this.map.getSource(this.sourceId);
|
|
1927
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
1928
|
+
}
|
|
1929
|
+
updateEditPreview(e, t) {
|
|
1930
|
+
let n;
|
|
1931
|
+
if (e.type === "move") {
|
|
1932
|
+
let r = t[0] - e.position[0], i = t[1] - e.position[1];
|
|
1933
|
+
n = this.entity.coordinates.map((e) => [e[0] + r, e[1] + i]);
|
|
1934
|
+
} else n = [...this.entity.coordinates], n[e.index] = t;
|
|
1935
|
+
let r = this.entity;
|
|
1936
|
+
this.entity = {
|
|
1937
|
+
...this.entity,
|
|
1938
|
+
coordinates: n
|
|
1939
|
+
};
|
|
1940
|
+
let i = this.map.getSource(this.sourceId);
|
|
1941
|
+
i && i.setData(this.getGeoJSON(n)), this.entity = r, this.refreshEditHandles(n);
|
|
1942
|
+
}
|
|
1943
|
+
cancelEditPreview() {
|
|
1944
|
+
let e = this.map.getSource(this.sourceId);
|
|
1945
|
+
e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
|
|
1946
|
+
}
|
|
1947
|
+
destroy() {
|
|
1948
|
+
this.initialized &&= (this.removeEditLayers(), 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);
|
|
1949
|
+
}
|
|
1585
1950
|
}, PolylineRenderer = class e {
|
|
1586
1951
|
static {
|
|
1587
1952
|
this.DEFAULTS = {
|
|
@@ -4187,7 +4552,7 @@ function detectVectorSource(e) {
|
|
|
4187
4552
|
return null;
|
|
4188
4553
|
}
|
|
4189
4554
|
const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaultRoadTypes: c = [], defaultMinWidth: l = 0, source: u, sourceLayer: d, classField: _ = "class", className: v = "", style: y, showButton: b = !0 }, x) => {
|
|
4190
|
-
let [S, C] = useState(!1), [w,
|
|
4555
|
+
let [S, C] = useState(!1), [w, ye] = useState(c), [T, E] = useState(!1), [D, be] = useState(null), xe = useRef(!1), k = useRef(null), Se = useRef(null), A = useRef(null), Ce = useCallback((e, t, n) => {
|
|
4191
4556
|
if (!e.isStyleLoaded() || !e.getSource(t)) return !1;
|
|
4192
4557
|
let r = !0;
|
|
4193
4558
|
return ROAD_TYPE_OPTIONS.forEach((a) => {
|
|
@@ -4223,13 +4588,13 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4223
4588
|
let r = detectVectorSource(e);
|
|
4224
4589
|
r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
|
|
4225
4590
|
}
|
|
4226
|
-
t && n ?
|
|
4591
|
+
t && n ? Ce(e, t, n) && (xe.current = !0, E(!0)) : console.warn("No vector source found for road highlighting");
|
|
4227
4592
|
};
|
|
4228
4593
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4229
4594
|
let n = () => {
|
|
4230
4595
|
e.isStyleLoaded() && t();
|
|
4231
4596
|
}, r = () => {
|
|
4232
|
-
|
|
4597
|
+
xe.current || t();
|
|
4233
4598
|
};
|
|
4234
4599
|
return e.on("styledata", n), e.on("sourcedata", r), () => {
|
|
4235
4600
|
if (e) try {
|
|
@@ -4240,7 +4605,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4240
4605
|
e,
|
|
4241
4606
|
u,
|
|
4242
4607
|
d,
|
|
4243
|
-
|
|
4608
|
+
Ce
|
|
4244
4609
|
]), useEffect(() => {
|
|
4245
4610
|
!e || !T || ROAD_TYPE_OPTIONS.forEach((t) => {
|
|
4246
4611
|
let n = `${LAYER_ID_PREFIX}${t.class}`;
|
|
@@ -4258,7 +4623,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4258
4623
|
]), useEffect(() => {
|
|
4259
4624
|
if (!S) return;
|
|
4260
4625
|
let e = (e) => {
|
|
4261
|
-
k.current && !k.current.contains(e.target) &&
|
|
4626
|
+
k.current && !k.current.contains(e.target) && Se.current && !Se.current.contains(e.target) && C(!1);
|
|
4262
4627
|
}, t = setTimeout(() => {
|
|
4263
4628
|
document.addEventListener("mousedown", e);
|
|
4264
4629
|
}, 0);
|
|
@@ -4358,10 +4723,10 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4358
4723
|
M
|
|
4359
4724
|
]);
|
|
4360
4725
|
let N = (e, t) => {
|
|
4361
|
-
|
|
4362
|
-
},
|
|
4363
|
-
|
|
4364
|
-
}, P = w.length > 0,
|
|
4726
|
+
ye((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
4727
|
+
}, we = (e) => {
|
|
4728
|
+
ye(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
|
|
4729
|
+
}, P = w.length > 0, Te = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4365
4730
|
/* @__PURE__ */ jsxs("div", {
|
|
4366
4731
|
className: "mapbox-road-highlight-control__panel-header",
|
|
4367
4732
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -4370,7 +4735,7 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4370
4735
|
}), /* @__PURE__ */ jsx(Checkbox, {
|
|
4371
4736
|
checked: w.length === ROAD_TYPE_OPTIONS.length,
|
|
4372
4737
|
indeterminate: w.length > 0 && w.length < ROAD_TYPE_OPTIONS.length,
|
|
4373
|
-
onChange:
|
|
4738
|
+
onChange: we,
|
|
4374
4739
|
style: {
|
|
4375
4740
|
"--color-text-1": "#fff",
|
|
4376
4741
|
"--color-border-2": "rgba(255, 255, 255, 0.3)"
|
|
@@ -4421,11 +4786,11 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4421
4786
|
children: "正在初始化图层..."
|
|
4422
4787
|
})
|
|
4423
4788
|
] });
|
|
4424
|
-
return useImperativeHandle(x, () => ({ setPortalContainer:
|
|
4789
|
+
return useImperativeHandle(x, () => ({ setPortalContainer: be })), /* @__PURE__ */ jsxs(Fragment, { children: [b && /* @__PURE__ */ jsxs("div", {
|
|
4425
4790
|
className: `mapbox-road-highlight-control ${v}`,
|
|
4426
4791
|
style: y,
|
|
4427
4792
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
4428
|
-
ref:
|
|
4793
|
+
ref: Se,
|
|
4429
4794
|
className: `mapbox-control-btn mapbox-road-highlight-control__btn ${P ? "mapbox-road-highlight-control__btn--active" : ""}`,
|
|
4430
4795
|
onClick: () => C(!S),
|
|
4431
4796
|
title: `路网高亮${w.length > 0 ? ` (已选 ${w.length})` : ""}`,
|
|
@@ -4437,9 +4802,9 @@ const RoadHighlightControl = forwardRef(({ map: e, highlightWidth: i = 3, defaul
|
|
|
4437
4802
|
}), S && /* @__PURE__ */ jsx("div", {
|
|
4438
4803
|
ref: k,
|
|
4439
4804
|
className: "mapbox-road-highlight-control__panel",
|
|
4440
|
-
children:
|
|
4805
|
+
children: Te()
|
|
4441
4806
|
})]
|
|
4442
|
-
}), D && createPortal(
|
|
4807
|
+
}), D && createPortal(Te(), D)] });
|
|
4443
4808
|
});
|
|
4444
4809
|
RoadHighlightControl.displayName = "RoadHighlightControl";
|
|
4445
4810
|
var measure_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773733446763'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1802'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M110.34624%20352.01024a30.72%2030.72%200%201%200%2061.44%200v-38.46144h680.42752v38.5024a30.72%2030.72%200%200%200%2061.44%200V213.72928a30.72%2030.72%200%200%200-61.44%200v38.33856H171.78624v-38.33856a30.72%2030.72%200%200%200-61.44%200v138.28096z%20m34.816%20127.22176a34.816%2034.816%200%200%200-34.816%2034.816v312.60672c0%2019.2512%2015.5648%2034.816%2034.816%2034.816h733.5936c19.2512%200%2034.816-15.5648%2034.816-34.816V514.048a34.816%2034.816%200%200%200-34.816-34.816H145.2032z%20m26.624%20320.79872V540.672h680.3456v259.35872H171.8272z'%20fill='white'%20p-id='1804'%3e%3c/path%3e%3c/svg%3e", square_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e", rectangle_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e", circle_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e", polygon_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e", polyline_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e", delete_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e", SHAPE_LABELS = {
|
|
@@ -4693,23 +5058,23 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4693
5058
|
showRadius: r.showRadius ?? !0
|
|
4694
5059
|
} : _, [x, S] = useState([]), C = useRef(/* @__PURE__ */ new Map()), w = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), j = useRef([]), M = useRef([]), N = useRef(b);
|
|
4695
5060
|
N.current = b;
|
|
4696
|
-
let
|
|
4697
|
-
|
|
5061
|
+
let we = useRef(f);
|
|
5062
|
+
we.current = f;
|
|
4698
5063
|
let P = useCallback(() => `measure-${++w.current}`, []);
|
|
4699
5064
|
useEffect(() => {
|
|
4700
5065
|
s?.(f !== null);
|
|
4701
5066
|
}, [f, s]);
|
|
4702
|
-
let
|
|
4703
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
5067
|
+
let Te = useRef(!1), Ee = useCallback(() => {
|
|
5068
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), Te.current = !0);
|
|
4704
5069
|
}, [e]);
|
|
4705
5070
|
useEffect(() => {
|
|
4706
5071
|
if (!e) return;
|
|
4707
5072
|
let t = () => {
|
|
4708
|
-
initAllPreviewLayers(e),
|
|
5073
|
+
initAllPreviewLayers(e), Te.current = !0;
|
|
4709
5074
|
};
|
|
4710
5075
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4711
5076
|
let n = () => {
|
|
4712
|
-
|
|
5077
|
+
Te.current = !1;
|
|
4713
5078
|
};
|
|
4714
5079
|
return e.on("style.load", n), () => {
|
|
4715
5080
|
if (e) try {
|
|
@@ -4735,12 +5100,12 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4735
5100
|
};
|
|
4736
5101
|
S((t) => [...t, e]);
|
|
4737
5102
|
}
|
|
4738
|
-
}, [e]),
|
|
5103
|
+
}, [e]), De = useCallback((e) => {
|
|
4739
5104
|
let t = C.current.get(e);
|
|
4740
5105
|
t && (t.destroy(), C.current.delete(e)), S((t) => t.filter((t) => t.entity.id !== e));
|
|
4741
|
-
}, []),
|
|
5106
|
+
}, []), Oe = useCallback(() => {
|
|
4742
5107
|
C.current.forEach((e) => e.destroy()), C.current.clear(), S([]);
|
|
4743
|
-
}, []),
|
|
5108
|
+
}, []), ke = useCallback((t) => {
|
|
4744
5109
|
if (!e) return;
|
|
4745
5110
|
let n = C.current.get(t);
|
|
4746
5111
|
if (!n) return;
|
|
@@ -4750,7 +5115,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4750
5115
|
maxZoom: 18,
|
|
4751
5116
|
duration: 1e3
|
|
4752
5117
|
});
|
|
4753
|
-
}, [e]),
|
|
5118
|
+
}, [e]), Ae = useCallback((e, t) => {
|
|
4754
5119
|
let n = {
|
|
4755
5120
|
...N.current,
|
|
4756
5121
|
[e]: t
|
|
@@ -4764,7 +5129,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4764
5129
|
entity: i
|
|
4765
5130
|
};
|
|
4766
5131
|
}));
|
|
4767
|
-
}, [y, i]),
|
|
5132
|
+
}, [y, i]), je = useCallback((t, n) => {
|
|
4768
5133
|
if (!e) return;
|
|
4769
5134
|
let [r, i] = t, [a, o] = n, s = [
|
|
4770
5135
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -4814,7 +5179,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4814
5179
|
features: t
|
|
4815
5180
|
});
|
|
4816
5181
|
}
|
|
4817
|
-
}, [e]),
|
|
5182
|
+
}, [e]), Me = useCallback((t, n) => {
|
|
4818
5183
|
if (!e) return;
|
|
4819
5184
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
4820
5185
|
a && a.setData({
|
|
@@ -4861,7 +5226,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4861
5226
|
type: "FeatureCollection",
|
|
4862
5227
|
features: c
|
|
4863
5228
|
});
|
|
4864
|
-
}, [e]),
|
|
5229
|
+
}, [e]), Ne = useCallback((t, n) => {
|
|
4865
5230
|
if (!e) return;
|
|
4866
5231
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
4867
5232
|
a && a.setData({
|
|
@@ -4975,7 +5340,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4975
5340
|
features: t
|
|
4976
5341
|
});
|
|
4977
5342
|
}
|
|
4978
|
-
}, [e]),
|
|
5343
|
+
}, [e]), Pe = useCallback((t, n) => {
|
|
4979
5344
|
if (!e) return;
|
|
4980
5345
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
4981
5346
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -5023,9 +5388,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5023
5388
|
}, [e]);
|
|
5024
5389
|
useEffect(() => {
|
|
5025
5390
|
if (!e || !f) return;
|
|
5026
|
-
|
|
5391
|
+
Ee(), e.getCanvas().style.cursor = "crosshair";
|
|
5027
5392
|
let t = (t) => {
|
|
5028
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
5393
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = we.current;
|
|
5029
5394
|
if (r === "rectangle") {
|
|
5030
5395
|
let t = D.current;
|
|
5031
5396
|
if (!t) D.current = n;
|
|
@@ -5075,20 +5440,20 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5075
5440
|
j.current = [...t, n];
|
|
5076
5441
|
} else r === "polyline" && (M.current = [...M.current, n]);
|
|
5077
5442
|
}, n = (e) => {
|
|
5078
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
5079
|
-
if (n === "rectangle" && D.current)
|
|
5080
|
-
else if (n === "circle" && O.current)
|
|
5081
|
-
else if (n === "square" && k.current)
|
|
5443
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = we.current;
|
|
5444
|
+
if (n === "rectangle" && D.current) je(D.current, t);
|
|
5445
|
+
else if (n === "circle" && O.current) Me(O.current.center, t);
|
|
5446
|
+
else if (n === "square" && k.current) Ne(k.current.center, t);
|
|
5082
5447
|
else if (n === "polygon") {
|
|
5083
5448
|
let e = j.current;
|
|
5084
5449
|
e.length > 0 && I(e, t);
|
|
5085
5450
|
} else if (n === "polyline") {
|
|
5086
5451
|
let e = M.current;
|
|
5087
|
-
e.length > 0 &&
|
|
5452
|
+
e.length > 0 && Pe(e, t);
|
|
5088
5453
|
}
|
|
5089
5454
|
}, r = (t) => {
|
|
5090
5455
|
t.preventDefault();
|
|
5091
|
-
let n =
|
|
5456
|
+
let n = we.current;
|
|
5092
5457
|
if (n === "polygon") {
|
|
5093
5458
|
let t = j.current;
|
|
5094
5459
|
if (t.length >= 3) {
|
|
@@ -5114,7 +5479,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5114
5479
|
t.key === "Escape" && (D.current = null, O.current = null, k.current = null, j.current = [], M.current = [], clearAllPreviewSources(e), p(null));
|
|
5115
5480
|
}, a = (t) => {
|
|
5116
5481
|
t.preventDefault();
|
|
5117
|
-
let n =
|
|
5482
|
+
let n = we.current;
|
|
5118
5483
|
if (n === "polygon") {
|
|
5119
5484
|
let t = j.current;
|
|
5120
5485
|
if (t.length >= 3) {
|
|
@@ -5147,16 +5512,16 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5147
5512
|
f,
|
|
5148
5513
|
P,
|
|
5149
5514
|
F,
|
|
5150
|
-
|
|
5151
|
-
Ae,
|
|
5515
|
+
Ee,
|
|
5152
5516
|
je,
|
|
5153
5517
|
Me,
|
|
5518
|
+
Ne,
|
|
5154
5519
|
I,
|
|
5155
|
-
|
|
5520
|
+
Pe
|
|
5156
5521
|
]), useEffect(() => () => {
|
|
5157
5522
|
C.current.forEach((e) => e.destroy()), C.current.clear();
|
|
5158
5523
|
}, []);
|
|
5159
|
-
let
|
|
5524
|
+
let Fe = useCallback((t) => {
|
|
5160
5525
|
p((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null, j.current = [], M.current = [], e && clearAllPreviewSources(e);
|
|
5161
5526
|
}, [e]);
|
|
5162
5527
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -5193,17 +5558,17 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5193
5558
|
children: [
|
|
5194
5559
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5195
5560
|
checked: b.showArea,
|
|
5196
|
-
onChange: (e) =>
|
|
5561
|
+
onChange: (e) => Ae("showArea", e),
|
|
5197
5562
|
children: "面积"
|
|
5198
5563
|
}),
|
|
5199
5564
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5200
5565
|
checked: b.showLength,
|
|
5201
|
-
onChange: (e) =>
|
|
5566
|
+
onChange: (e) => Ae("showLength", e),
|
|
5202
5567
|
children: "长度"
|
|
5203
5568
|
}),
|
|
5204
5569
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5205
5570
|
checked: b.showRadius,
|
|
5206
|
-
onChange: (e) =>
|
|
5571
|
+
onChange: (e) => Ae("showRadius", e),
|
|
5207
5572
|
children: "半径"
|
|
5208
5573
|
})
|
|
5209
5574
|
]
|
|
@@ -5216,7 +5581,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5216
5581
|
className: "mapbox-measure-control__tools",
|
|
5217
5582
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
5218
5583
|
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5219
|
-
onClick: () =>
|
|
5584
|
+
onClick: () => Fe(e.mode),
|
|
5220
5585
|
title: e.label,
|
|
5221
5586
|
children: /* @__PURE__ */ jsx("img", {
|
|
5222
5587
|
src: e.icon,
|
|
@@ -5224,7 +5589,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5224
5589
|
})
|
|
5225
5590
|
}, e.mode)), x.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
5226
5591
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
5227
|
-
onClick:
|
|
5592
|
+
onClick: Oe,
|
|
5228
5593
|
title: "清除全部",
|
|
5229
5594
|
children: /* @__PURE__ */ jsx("img", {
|
|
5230
5595
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e",
|
|
@@ -5244,7 +5609,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5244
5609
|
/* @__PURE__ */ jsx("th", {})
|
|
5245
5610
|
] }) }), /* @__PURE__ */ jsx("tbody", { children: x.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
5246
5611
|
className: "mapbox-measure-control__table-row",
|
|
5247
|
-
onClick: () =>
|
|
5612
|
+
onClick: () => ke(e.entity.id),
|
|
5248
5613
|
children: [
|
|
5249
5614
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
5250
5615
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -5253,7 +5618,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5253
5618
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
5254
5619
|
className: "mapbox-measure-control__delete-btn",
|
|
5255
5620
|
onClick: (t) => {
|
|
5256
|
-
t.stopPropagation(),
|
|
5621
|
+
t.stopPropagation(), De(e.entity.id);
|
|
5257
5622
|
},
|
|
5258
5623
|
title: "删除",
|
|
5259
5624
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -5348,7 +5713,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5348
5713
|
x,
|
|
5349
5714
|
p,
|
|
5350
5715
|
C
|
|
5351
|
-
]),
|
|
5716
|
+
]), ye = useCallback(() => {
|
|
5352
5717
|
b ? s?.({ ...DEFAULT_CONFIG }) : (g({ ...DEFAULT_CONFIG }), C({ ...DEFAULT_CONFIG }));
|
|
5353
5718
|
}, [
|
|
5354
5719
|
b,
|
|
@@ -5403,7 +5768,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5403
5768
|
]
|
|
5404
5769
|
}, e)), /* @__PURE__ */ jsx("button", {
|
|
5405
5770
|
className: "mapbox-raster-paint-control__reset",
|
|
5406
|
-
onClick:
|
|
5771
|
+
onClick: ye,
|
|
5407
5772
|
children: "重置"
|
|
5408
5773
|
})]
|
|
5409
5774
|
})]
|
|
@@ -5432,13 +5797,13 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5432
5797
|
i === "polyline" ? s(null) : (r(null), s("polyline"));
|
|
5433
5798
|
}, w = () => {
|
|
5434
5799
|
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), g(!p);
|
|
5435
|
-
},
|
|
5800
|
+
}, ye = (e) => e.size ? {
|
|
5436
5801
|
width: e.size,
|
|
5437
5802
|
height: e.size
|
|
5438
5803
|
} : {
|
|
5439
5804
|
width: e.width || 32,
|
|
5440
5805
|
height: e.height || 32
|
|
5441
|
-
}, T = p || t, E = i === "rectangle", D = i === "circle", O = i === "polygon",
|
|
5806
|
+
}, T = p || t, E = i === "rectangle", D = i === "circle", O = i === "polygon", be = i === "square", xe = i === "polyline";
|
|
5442
5807
|
return /* @__PURE__ */ jsxs("div", {
|
|
5443
5808
|
ref: _,
|
|
5444
5809
|
className: "mapbox-edit-control",
|
|
@@ -5460,7 +5825,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5460
5825
|
}), /* @__PURE__ */ jsx("span", { children: t ? t.name : "Marker" })]
|
|
5461
5826
|
}),
|
|
5462
5827
|
d && /* @__PURE__ */ jsxs("button", {
|
|
5463
|
-
className: `mapbox-control-btn ${
|
|
5828
|
+
className: `mapbox-control-btn ${be ? "mapbox-control-btn--active" : ""}`,
|
|
5464
5829
|
onClick: S,
|
|
5465
5830
|
title: "绘制正方形",
|
|
5466
5831
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -5500,7 +5865,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5500
5865
|
}), /* @__PURE__ */ jsx("span", { children: "多边形" })]
|
|
5501
5866
|
}),
|
|
5502
5867
|
f && /* @__PURE__ */ jsxs("button", {
|
|
5503
|
-
className: `mapbox-control-btn ${
|
|
5868
|
+
className: `mapbox-control-btn ${xe ? "mapbox-control-btn--active" : ""}`,
|
|
5504
5869
|
onClick: C,
|
|
5505
5870
|
title: "绘制折线",
|
|
5506
5871
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -5518,7 +5883,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5518
5883
|
}), /* @__PURE__ */ jsx("div", {
|
|
5519
5884
|
className: "mapbox-edit-control__template-list",
|
|
5520
5885
|
children: e.map((e) => {
|
|
5521
|
-
let n =
|
|
5886
|
+
let n = ye(e), r = t?.id === e.id;
|
|
5522
5887
|
return /* @__PURE__ */ jsxs("div", {
|
|
5523
5888
|
className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
|
|
5524
5889
|
onClick: () => v(e),
|
|
@@ -5590,7 +5955,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5590
5955
|
};
|
|
5591
5956
|
var route_planning_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e", SOURCE_ID = "route-planning-temp-line", LINE_LAYER_ID = "route-planning-temp-line-layer", POINT_LAYER_ID = "route-planning-temp-point-layer";
|
|
5592
5957
|
const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointCountInput: c = !1, visualType: l = "marker", onSelectFinished: u, showButton: d = !0 }, f) => {
|
|
5593
|
-
let [p, g] = useState("idle"), [_, v] = useState(0), [y, b] = useState(i), [x, S] = useState(!1), C = useRef(null), w = useRef(null),
|
|
5958
|
+
let [p, g] = useState("idle"), [_, v] = useState(0), [y, b] = useState(i), [x, S] = useState(!1), C = useRef(null), w = useRef(null), ye = useRef([]), T = useRef([]), E = useRef("idle"), D = useRef(null), O = useRef("");
|
|
5594
5959
|
useEffect(() => {
|
|
5595
5960
|
E.current = p;
|
|
5596
5961
|
}, [p]), useEffect(() => {
|
|
@@ -5606,12 +5971,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5606
5971
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
5607
5972
|
};
|
|
5608
5973
|
}, [x]);
|
|
5609
|
-
let
|
|
5974
|
+
let be = useCallback(() => {
|
|
5610
5975
|
for (let e of T.current) e.remove();
|
|
5611
5976
|
T.current = [], e && (e.getLayer(LINE_LAYER_ID) && e.removeLayer(LINE_LAYER_ID), e.getLayer(POINT_LAYER_ID) && e.removeLayer(POINT_LAYER_ID), e.getSource(SOURCE_ID) && e.removeSource(SOURCE_ID));
|
|
5612
|
-
}, [e]),
|
|
5977
|
+
}, [e]), xe = useCallback(() => {
|
|
5613
5978
|
if (!e) return;
|
|
5614
|
-
let t =
|
|
5979
|
+
let t = ye.current, n = {
|
|
5615
5980
|
type: "FeatureCollection",
|
|
5616
5981
|
features: [{
|
|
5617
5982
|
type: "Feature",
|
|
@@ -5667,18 +6032,18 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5667
6032
|
let { visualType: n } = D.current;
|
|
5668
6033
|
if (n === "marker") {
|
|
5669
6034
|
let n = document.createElement("div");
|
|
5670
|
-
n.className = "route-planning-temp-marker", n.textContent = String(
|
|
6035
|
+
n.className = "route-planning-temp-marker", n.textContent = String(ye.current.length);
|
|
5671
6036
|
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5672
6037
|
T.current.push(r);
|
|
5673
|
-
} else
|
|
5674
|
-
}, [e,
|
|
5675
|
-
if (
|
|
6038
|
+
} else xe();
|
|
6039
|
+
}, [e, xe]), Se = useCallback(() => {
|
|
6040
|
+
if (be(), ye.current = [], D.current = null, v(0), g("idle"), e) try {
|
|
5676
6041
|
e.getCanvas().style.cursor = O.current;
|
|
5677
6042
|
} catch {}
|
|
5678
|
-
}, [
|
|
5679
|
-
let e = D.current, t = [...
|
|
6043
|
+
}, [be, e]), A = useCallback(async () => {
|
|
6044
|
+
let e = D.current, t = [...ye.current];
|
|
5680
6045
|
if (!e || t.length < 2) {
|
|
5681
|
-
|
|
6046
|
+
Se();
|
|
5682
6047
|
return;
|
|
5683
6048
|
}
|
|
5684
6049
|
g("planning");
|
|
@@ -5687,48 +6052,48 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5687
6052
|
} catch (e) {
|
|
5688
6053
|
console.error("Route planning onSelectFinished failed:", e);
|
|
5689
6054
|
} finally {
|
|
5690
|
-
|
|
6055
|
+
Se();
|
|
5691
6056
|
}
|
|
5692
|
-
}, [
|
|
6057
|
+
}, [Se]), Ce = useCallback((e) => {
|
|
5693
6058
|
if (E.current !== "selecting" || !D.current) return;
|
|
5694
6059
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5695
|
-
|
|
5696
|
-
let n =
|
|
6060
|
+
ye.current.push(t);
|
|
6061
|
+
let n = ye.current.length;
|
|
5697
6062
|
v(n), k(t), n >= D.current.pointCount && A();
|
|
5698
6063
|
}, [k, A]), j = useCallback((e) => {
|
|
5699
|
-
E.current === "selecting" && (e.preventDefault(),
|
|
5700
|
-
}, [
|
|
6064
|
+
E.current === "selecting" && (e.preventDefault(), Se());
|
|
6065
|
+
}, [Se]);
|
|
5701
6066
|
useEffect(() => {
|
|
5702
|
-
if (e && p === "selecting") return e.on("click",
|
|
6067
|
+
if (e && p === "selecting") return e.on("click", Ce), e.on("contextmenu", j), () => {
|
|
5703
6068
|
if (e) try {
|
|
5704
|
-
e.off("click",
|
|
6069
|
+
e.off("click", Ce), e.off("contextmenu", j);
|
|
5705
6070
|
} catch {}
|
|
5706
6071
|
};
|
|
5707
6072
|
}, [
|
|
5708
6073
|
e,
|
|
5709
6074
|
p,
|
|
5710
|
-
|
|
6075
|
+
Ce,
|
|
5711
6076
|
j
|
|
5712
6077
|
]);
|
|
5713
6078
|
let M = useCallback((t) => {
|
|
5714
6079
|
if (!e) return;
|
|
5715
|
-
E.current !== "idle" &&
|
|
6080
|
+
E.current !== "idle" && Se();
|
|
5716
6081
|
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5717
6082
|
D.current = {
|
|
5718
6083
|
pointCount: n,
|
|
5719
6084
|
visualType: r,
|
|
5720
6085
|
onSelectFinished: t.onSelectFinished
|
|
5721
|
-
},
|
|
6086
|
+
}, ye.current = [], v(0), b(n), S(!1), O.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", g("selecting");
|
|
5722
6087
|
}, [
|
|
5723
6088
|
e,
|
|
5724
6089
|
i,
|
|
5725
6090
|
l,
|
|
5726
|
-
|
|
6091
|
+
Se
|
|
5727
6092
|
]);
|
|
5728
6093
|
useImperativeHandle(f, () => ({ startPlanning: M }), [M]);
|
|
5729
6094
|
let N = () => {
|
|
5730
|
-
p === "idle" ? S((e) => !e) : p === "selecting" &&
|
|
5731
|
-
},
|
|
6095
|
+
p === "idle" ? S((e) => !e) : p === "selecting" && Se();
|
|
6096
|
+
}, we = () => {
|
|
5732
6097
|
u && M({
|
|
5733
6098
|
pointCount: Math.max(2, y),
|
|
5734
6099
|
visualType: l,
|
|
@@ -5737,7 +6102,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5737
6102
|
}, P = (e) => {
|
|
5738
6103
|
let t = parseInt(e.target.value, 10);
|
|
5739
6104
|
!isNaN(t) && t >= 2 ? b(t) : e.target.value === "" && b(2);
|
|
5740
|
-
},
|
|
6105
|
+
}, Te = () => {
|
|
5741
6106
|
if (p === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5742
6107
|
if (p === "selecting") {
|
|
5743
6108
|
let e = D.current?.pointCount ?? y;
|
|
@@ -5748,12 +6113,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5748
6113
|
] });
|
|
5749
6114
|
}
|
|
5750
6115
|
return "路径规划";
|
|
5751
|
-
},
|
|
6116
|
+
}, Ee = p === "selecting", F = p === "planning";
|
|
5752
6117
|
return !d && p === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5753
6118
|
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5754
6119
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5755
6120
|
ref: C,
|
|
5756
|
-
className: `mapbox-control-btn mapbox-route-planning-control__btn${
|
|
6121
|
+
className: `mapbox-control-btn mapbox-route-planning-control__btn${Ee ? " mapbox-route-planning-control__btn--active" : ""}${F ? " mapbox-route-planning-control__btn--planning" : ""}${x ? " mapbox-route-planning-control__btn--active" : ""}`,
|
|
5757
6122
|
onClick: N,
|
|
5758
6123
|
disabled: F,
|
|
5759
6124
|
title: p === "idle" ? "路径规划" : p === "selecting" ? "取消选点" : "规划中...",
|
|
@@ -5761,7 +6126,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5761
6126
|
src: route_planning_default,
|
|
5762
6127
|
alt: "route",
|
|
5763
6128
|
className: "mapbox-route-planning-control__btn-icon"
|
|
5764
|
-
}),
|
|
6129
|
+
}), Te()]
|
|
5765
6130
|
}), x && p === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5766
6131
|
ref: w,
|
|
5767
6132
|
className: "mapbox-route-planning-control__panel",
|
|
@@ -5796,7 +6161,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5796
6161
|
}),
|
|
5797
6162
|
/* @__PURE__ */ jsx("button", {
|
|
5798
6163
|
className: "mapbox-route-planning-control__panel-start",
|
|
5799
|
-
onClick:
|
|
6164
|
+
onClick: we,
|
|
5800
6165
|
disabled: !u,
|
|
5801
6166
|
children: "开始规划"
|
|
5802
6167
|
})
|
|
@@ -5832,7 +6197,17 @@ function calculatePopupPosition(e, t, n, r, i) {
|
|
|
5832
6197
|
let [[t, n], [r, i]] = e.bounds;
|
|
5833
6198
|
o = [(t + r) / 2, (n + i) / 2];
|
|
5834
6199
|
}
|
|
5835
|
-
else
|
|
6200
|
+
else if (e.type === "attack-direction") {
|
|
6201
|
+
let t = e.coordinates;
|
|
6202
|
+
o = e.center ?? [(t[0][0] + t[1][0] + t[2][0]) / 3, (t[0][1] + t[1][1] + t[2][1]) / 3];
|
|
6203
|
+
} else o = e.center;
|
|
6204
|
+
if (!o) return {
|
|
6205
|
+
position: {
|
|
6206
|
+
x: 0,
|
|
6207
|
+
y: 0
|
|
6208
|
+
},
|
|
6209
|
+
actualPosition: t.position
|
|
6210
|
+
};
|
|
5836
6211
|
let s = n.project(o);
|
|
5837
6212
|
a = {
|
|
5838
6213
|
x: s.x,
|
|
@@ -5953,13 +6328,13 @@ function adjustPopupForBounds(e, t) {
|
|
|
5953
6328
|
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;
|
|
5954
6329
|
}
|
|
5955
6330
|
const Mapbox = forwardRef((e, c) => {
|
|
5956
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: j, circleConfig: M, lengthConfig: N, showCoordinates:
|
|
5957
|
-
|
|
6331
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: j, circleConfig: M, lengthConfig: N, showCoordinates: we = !0, showScale: P = !0, showResetView: Te = !0, showRoadHighlight: Ee = !1, showMeasure: F = !1, showRasterPaint: Oe = !1, showRoutePlanning: Me, onRasterPaintChange: Ne, popupDefaults: I, renderPopup: Fe, onMapLoad: Ie, onEntityClick: Le, onPopupOpen: Re, onPopupClose: ze, className: Be = "", containerStyle: Ve } = e, He = useRef(null), Ue = useRef(null), We = useRef(null), L = useRef(null), R = useRef(/* @__PURE__ */ new Map()), z = useRef(/* @__PURE__ */ new Map()), Ge = useRef(/* @__PURE__ */ new Set()), [B, Ke] = useState(null), qe = useRef(null), Je = useRef(null), Ye = useRef(null), [Xe, Ze] = useState(null), Qe = useRef(null), $e = useRef(null), [et, tt] = useState(null), [V, nt] = useState(_), [rt, it] = useState(null), at = useRef(null), [ot, H] = useState(null), [st, U] = useState(null), [ct, lt] = useState(null), W = useRef(!1), ut = useRef(null), dt = useRef(null), G = useRef(null), ft = useRef(null), K = useRef(null), pt = useRef([]), mt = useRef(null), ht = useRef(null), gt = useRef(null), _t = useRef([]), vt = useRef(null), yt = useRef(!1), [bt, xt] = useState([]), St = useRef([]);
|
|
6332
|
+
St.current = bt;
|
|
5958
6333
|
let q = useRef(null);
|
|
5959
6334
|
useEffect(() => {
|
|
5960
|
-
|
|
6335
|
+
nt(_);
|
|
5961
6336
|
}, [_]);
|
|
5962
|
-
let
|
|
6337
|
+
let Ct = useCallback((e) => {
|
|
5963
6338
|
let t = R.current.get(e), n = z.current.get(e);
|
|
5964
6339
|
if (t && n) {
|
|
5965
6340
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
@@ -5976,7 +6351,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5976
6351
|
z.current.set(e, r), t.startAnimation();
|
|
5977
6352
|
}
|
|
5978
6353
|
}
|
|
5979
|
-
}, []),
|
|
6354
|
+
}, []), wt = useCallback((e) => {
|
|
5980
6355
|
let t = R.current.get(e), n = z.current.get(e);
|
|
5981
6356
|
if (t && n) {
|
|
5982
6357
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
@@ -5993,10 +6368,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5993
6368
|
z.current.set(e, r), t.stopAnimation();
|
|
5994
6369
|
}
|
|
5995
6370
|
}
|
|
5996
|
-
}, []),
|
|
6371
|
+
}, []), Tt = useCallback((e) => {
|
|
5997
6372
|
let t = z.current.get(e);
|
|
5998
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
5999
|
-
}, [
|
|
6373
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? wt(e) : Ct(e));
|
|
6374
|
+
}, [Ct, wt]), Et = useCallback((e) => {
|
|
6000
6375
|
if (e === void 0) {
|
|
6001
6376
|
let e = !1;
|
|
6002
6377
|
for (let [, t] of R.current) if (t instanceof UnitRenderer) {
|
|
@@ -6012,36 +6387,36 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6012
6387
|
let t = new Set(e.map(String));
|
|
6013
6388
|
for (let [e, n] of R.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
6014
6389
|
}
|
|
6015
|
-
}, []),
|
|
6390
|
+
}, []), Dt = useCallback((e, t, n) => {
|
|
6016
6391
|
let r = T.find((t) => String(t.id) === String(e));
|
|
6017
6392
|
if (!r?.popup || !L.current) return;
|
|
6018
|
-
let i = r.popup.content ??
|
|
6393
|
+
let i = r.popup.content ?? Fe?.(r);
|
|
6019
6394
|
if (!i) return;
|
|
6020
6395
|
let a = mergePopupConfig(r.popup, I, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, L.current, n);
|
|
6021
|
-
|
|
6396
|
+
Ke({
|
|
6022
6397
|
entityId: e,
|
|
6023
6398
|
position: o,
|
|
6024
6399
|
config: a,
|
|
6025
6400
|
openedBy: t,
|
|
6026
6401
|
actualPosition: s
|
|
6027
|
-
}),
|
|
6402
|
+
}), Re?.(e);
|
|
6028
6403
|
}, [
|
|
6029
6404
|
T,
|
|
6030
6405
|
I,
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
]),
|
|
6034
|
-
B?.entityId === e && (
|
|
6035
|
-
}, [B,
|
|
6036
|
-
|
|
6037
|
-
}, [
|
|
6406
|
+
Fe,
|
|
6407
|
+
Re
|
|
6408
|
+
]), Ot = useCallback((e) => {
|
|
6409
|
+
B?.entityId === e && (Ke(null), ze?.(e));
|
|
6410
|
+
}, [B, ze]), kt = useCallback(() => {
|
|
6411
|
+
Ke((e) => (e && ze?.(e.entityId), null));
|
|
6412
|
+
}, [ze]), At = useCallback((e) => B?.entityId === e, [B]), jt = useCallback((e, t, n) => {
|
|
6038
6413
|
let r = L.current;
|
|
6039
6414
|
r && r.flyTo({
|
|
6040
6415
|
center: e,
|
|
6041
6416
|
zoom: t ?? r.getZoom(),
|
|
6042
6417
|
...n
|
|
6043
6418
|
});
|
|
6044
|
-
}, []),
|
|
6419
|
+
}, []), Mt = useCallback((e) => {
|
|
6045
6420
|
if (e.length === 0) return null;
|
|
6046
6421
|
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity, a = !1;
|
|
6047
6422
|
for (let o of e) {
|
|
@@ -6052,10 +6427,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6052
6427
|
}
|
|
6053
6428
|
}
|
|
6054
6429
|
return a ? [(t + n) / 2, (r + i) / 2] : null;
|
|
6055
|
-
}, []),
|
|
6430
|
+
}, []), Nt = useCallback((e, t, n) => {
|
|
6056
6431
|
let r = L.current;
|
|
6057
6432
|
if (!r || e.length === 0) return;
|
|
6058
|
-
let i =
|
|
6433
|
+
let i = Mt(e);
|
|
6059
6434
|
if (!i) return;
|
|
6060
6435
|
let a = [];
|
|
6061
6436
|
for (let t of e) {
|
|
@@ -6080,20 +6455,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6080
6455
|
pitch: n?.pitch ?? r.getPitch()
|
|
6081
6456
|
};
|
|
6082
6457
|
t !== void 0 && (f.maxZoom = t), n?.essential !== void 0 && (f.essential = n.essential), r.fitBounds(d, f);
|
|
6083
|
-
}, [
|
|
6458
|
+
}, [Mt]), Pt = useRef(null), Ft = useRef("display"), [It, Lt] = useState({}), J = useMemo(() => ({
|
|
6084
6459
|
...y,
|
|
6085
|
-
...
|
|
6086
|
-
}), [y,
|
|
6460
|
+
...It
|
|
6461
|
+
}), [y, It]), Rt = useCallback((e) => {
|
|
6087
6462
|
let t = L.current;
|
|
6088
6463
|
if (!t || !t.getContainer()) return;
|
|
6089
6464
|
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = J;
|
|
6090
6465
|
if (!n) {
|
|
6091
|
-
|
|
6466
|
+
at.current &&= (at.current.remove(), null);
|
|
6092
6467
|
return;
|
|
6093
6468
|
}
|
|
6094
|
-
if (
|
|
6095
|
-
|
|
6096
|
-
let t =
|
|
6469
|
+
if (at.current) {
|
|
6470
|
+
at.current.setLngLat(e);
|
|
6471
|
+
let t = at.current.getElement(), n = t.querySelector(".marker-label");
|
|
6097
6472
|
if (i) {
|
|
6098
6473
|
let e = resolveNameConfig(a, O);
|
|
6099
6474
|
if (n) n.textContent = i, n.style.color = e.fillColor, n.style.opacity = String(e.fillOpacity), n.style.webkitTextStrokeColor = e.strokeColor, n.style.webkitTextStrokeWidth = `${e.strokeWidth}px`;
|
|
@@ -6110,38 +6485,38 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6110
6485
|
let e = resolveNameConfig(a, O), t = document.createElement("div");
|
|
6111
6486
|
t.className = "marker-label", t.textContent = i, t.style.color = e.fillColor, t.style.opacity = String(e.fillOpacity), t.style.webkitTextStrokeColor = e.strokeColor, t.style.webkitTextStrokeWidth = `${e.strokeWidth}px`, n.appendChild(t);
|
|
6112
6487
|
}
|
|
6113
|
-
|
|
6488
|
+
at.current = new mapboxgl.Marker({
|
|
6114
6489
|
element: n,
|
|
6115
6490
|
anchor: "bottom"
|
|
6116
6491
|
}).setLngLat(e).addTo(t);
|
|
6117
6492
|
}
|
|
6118
|
-
}, [J, O]),
|
|
6119
|
-
|
|
6120
|
-
}, []),
|
|
6493
|
+
}, [J, O]), zt = useCallback(() => {
|
|
6494
|
+
at.current &&= (at.current.remove(), null);
|
|
6495
|
+
}, []), Bt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Vt = useCallback((e) => {
|
|
6121
6496
|
let t = L.current;
|
|
6122
|
-
if (
|
|
6497
|
+
if (He.current) if (vt.current &&= (vt.current.remove(), null), e && t) {
|
|
6123
6498
|
t.getCanvas().style.cursor = "none";
|
|
6124
6499
|
let n = document.createElement("div");
|
|
6125
6500
|
n.className = "mapbox-custom-cursor";
|
|
6126
6501
|
let r = e.size || e.width || 32;
|
|
6127
6502
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
6128
6503
|
let i = document.createElement("img");
|
|
6129
|
-
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),
|
|
6504
|
+
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), vt.current = n;
|
|
6130
6505
|
let a = (e) => {
|
|
6131
|
-
|
|
6506
|
+
vt.current && (vt.current.style.left = `${e.clientX}px`, vt.current.style.top = `${e.clientY}px`);
|
|
6132
6507
|
};
|
|
6133
6508
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
6134
6509
|
document.removeEventListener("mousemove", a);
|
|
6135
6510
|
};
|
|
6136
6511
|
} else t && (t.getCanvas().style.cursor = "");
|
|
6137
6512
|
}, []), Y = useCallback(() => {
|
|
6138
|
-
if (
|
|
6139
|
-
let e =
|
|
6140
|
-
e && e(),
|
|
6513
|
+
if (vt.current) {
|
|
6514
|
+
let e = vt.current._cleanup;
|
|
6515
|
+
e && e(), vt.current.remove(), vt.current = null;
|
|
6141
6516
|
}
|
|
6142
6517
|
let e = L.current;
|
|
6143
6518
|
e && (e.getCanvas().style.cursor = "");
|
|
6144
|
-
}, []),
|
|
6519
|
+
}, []), Ht = useCallback((e, t, n) => {
|
|
6145
6520
|
if (!e.getSource(t)) {
|
|
6146
6521
|
if (!e.getStyle().glyphs) {
|
|
6147
6522
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -6177,7 +6552,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6177
6552
|
}
|
|
6178
6553
|
});
|
|
6179
6554
|
}
|
|
6180
|
-
}, []),
|
|
6555
|
+
}, []), Ut = useCallback(() => {
|
|
6181
6556
|
let e = L.current;
|
|
6182
6557
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6183
6558
|
type: "geojson",
|
|
@@ -6202,8 +6577,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6202
6577
|
"line-width": 2,
|
|
6203
6578
|
"line-dasharray": [4, 4]
|
|
6204
6579
|
}
|
|
6205
|
-
}),
|
|
6206
|
-
}, [
|
|
6580
|
+
}), Ht(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6581
|
+
}, [Ht]), Wt = useCallback((e, t) => {
|
|
6207
6582
|
let n = L.current;
|
|
6208
6583
|
if (!n) return;
|
|
6209
6584
|
let r = n.getSource("rect-preview-source");
|
|
@@ -6223,11 +6598,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6223
6598
|
},
|
|
6224
6599
|
properties: {}
|
|
6225
6600
|
});
|
|
6226
|
-
let l =
|
|
6601
|
+
let l = ut.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6227
6602
|
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));
|
|
6228
6603
|
let m = n.getSource("rect-preview-measure-source");
|
|
6229
6604
|
if (m) {
|
|
6230
|
-
let e =
|
|
6605
|
+
let e = Un.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6231
6606
|
if (e?.showArea) {
|
|
6232
6607
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6233
6608
|
t.push({
|
|
@@ -6264,7 +6639,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6264
6639
|
features: t
|
|
6265
6640
|
});
|
|
6266
6641
|
}
|
|
6267
|
-
}, []),
|
|
6642
|
+
}, []), Gt = useCallback(() => {
|
|
6268
6643
|
let e = L.current;
|
|
6269
6644
|
if (!e) return;
|
|
6270
6645
|
let t = e.getSource("rect-preview-source");
|
|
@@ -6278,8 +6653,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6278
6653
|
features: []
|
|
6279
6654
|
});
|
|
6280
6655
|
}, []), X = useCallback(() => {
|
|
6281
|
-
|
|
6282
|
-
}, [
|
|
6656
|
+
lt(null), Gt();
|
|
6657
|
+
}, [Gt]), Kt = useCallback(() => {
|
|
6283
6658
|
let e = L.current;
|
|
6284
6659
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6285
6660
|
type: "geojson",
|
|
@@ -6304,7 +6679,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6304
6679
|
"line-width": 2,
|
|
6305
6680
|
"line-dasharray": [4, 4]
|
|
6306
6681
|
}
|
|
6307
|
-
}),
|
|
6682
|
+
}), Ht(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
6308
6683
|
type: "geojson",
|
|
6309
6684
|
data: {
|
|
6310
6685
|
type: "FeatureCollection",
|
|
@@ -6321,22 +6696,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6321
6696
|
"line-dasharray": [4, 4]
|
|
6322
6697
|
}
|
|
6323
6698
|
}))));
|
|
6324
|
-
}, [
|
|
6699
|
+
}, [Ht]), qt = useCallback((e, t, n = 64) => {
|
|
6325
6700
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
6326
6701
|
for (let e = 0; e <= n; e++) {
|
|
6327
6702
|
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;
|
|
6328
6703
|
a.push([d, u]);
|
|
6329
6704
|
}
|
|
6330
6705
|
return a;
|
|
6331
|
-
}, []),
|
|
6706
|
+
}, []), Jt = useCallback((e, t) => {
|
|
6332
6707
|
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);
|
|
6333
6708
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6334
|
-
}, []),
|
|
6709
|
+
}, []), Yt = useCallback((e, t) => {
|
|
6335
6710
|
let n = L.current;
|
|
6336
6711
|
if (!n) return;
|
|
6337
6712
|
let r = n.getSource("circle-preview-source");
|
|
6338
6713
|
if (!r) return;
|
|
6339
|
-
let i =
|
|
6714
|
+
let i = Jt(e, t), a = qt(e, i);
|
|
6340
6715
|
r.setData({
|
|
6341
6716
|
type: "Feature",
|
|
6342
6717
|
geometry: {
|
|
@@ -6347,7 +6722,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6347
6722
|
});
|
|
6348
6723
|
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6349
6724
|
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));
|
|
6350
|
-
let d =
|
|
6725
|
+
let d = Un.current, f = [], p = [];
|
|
6351
6726
|
if (d?.showArea) {
|
|
6352
6727
|
let t = Math.PI * i * i;
|
|
6353
6728
|
f.push({
|
|
@@ -6387,7 +6762,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6387
6762
|
type: "FeatureCollection",
|
|
6388
6763
|
features: p
|
|
6389
6764
|
});
|
|
6390
|
-
}, [
|
|
6765
|
+
}, [Jt, qt]), Xt = useCallback(() => {
|
|
6391
6766
|
let e = L.current;
|
|
6392
6767
|
if (!e) return;
|
|
6393
6768
|
let t = e.getSource("circle-preview-source");
|
|
@@ -6405,9 +6780,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6405
6780
|
type: "FeatureCollection",
|
|
6406
6781
|
features: []
|
|
6407
6782
|
});
|
|
6408
|
-
}, []),
|
|
6409
|
-
|
|
6410
|
-
}, [
|
|
6783
|
+
}, []), Zt = useCallback(() => {
|
|
6784
|
+
ft.current = null, Xt();
|
|
6785
|
+
}, [Xt]), Qt = useCallback(() => {
|
|
6411
6786
|
let e = L.current;
|
|
6412
6787
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6413
6788
|
type: "geojson",
|
|
@@ -6448,8 +6823,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6448
6823
|
"circle-stroke-color": "#ffffff",
|
|
6449
6824
|
"circle-stroke-width": 2
|
|
6450
6825
|
}
|
|
6451
|
-
}),
|
|
6452
|
-
}, [
|
|
6826
|
+
}), Ht(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6827
|
+
}, [Ht]), $t = useCallback((e, t) => {
|
|
6453
6828
|
let n = L.current;
|
|
6454
6829
|
if (!n) return;
|
|
6455
6830
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
@@ -6491,7 +6866,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6491
6866
|
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);
|
|
6492
6867
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6493
6868
|
if (d) {
|
|
6494
|
-
let e =
|
|
6869
|
+
let e = Un.current, t = [];
|
|
6495
6870
|
if (e?.showArea && a.length >= 3) {
|
|
6496
6871
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6497
6872
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6533,7 +6908,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6533
6908
|
features: t
|
|
6534
6909
|
});
|
|
6535
6910
|
}
|
|
6536
|
-
}, []),
|
|
6911
|
+
}, []), en = useCallback(() => {
|
|
6537
6912
|
let e = L.current;
|
|
6538
6913
|
if (!e) return;
|
|
6539
6914
|
let t = e.getSource("polygon-preview-source");
|
|
@@ -6551,9 +6926,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6551
6926
|
type: "FeatureCollection",
|
|
6552
6927
|
features: []
|
|
6553
6928
|
});
|
|
6554
|
-
}, []),
|
|
6555
|
-
|
|
6556
|
-
}, [
|
|
6929
|
+
}, []), tn = useCallback(() => {
|
|
6930
|
+
pt.current = [], en();
|
|
6931
|
+
}, [en]), nn = useCallback(() => {
|
|
6557
6932
|
let e = L.current;
|
|
6558
6933
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6559
6934
|
type: "geojson",
|
|
@@ -6578,8 +6953,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6578
6953
|
"line-width": 2,
|
|
6579
6954
|
"line-dasharray": [4, 4]
|
|
6580
6955
|
}
|
|
6581
|
-
}),
|
|
6582
|
-
}, [
|
|
6956
|
+
}), Ht(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6957
|
+
}, [Ht]), rn = useCallback((e, t) => {
|
|
6583
6958
|
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);
|
|
6584
6959
|
return [
|
|
6585
6960
|
[n - s, r + o],
|
|
@@ -6588,12 +6963,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6588
6963
|
[n - s, r - o],
|
|
6589
6964
|
[n - s, r + o]
|
|
6590
6965
|
];
|
|
6591
|
-
}, []),
|
|
6966
|
+
}, []), an = useCallback((e, t) => {
|
|
6592
6967
|
let n = L.current;
|
|
6593
6968
|
if (!n) return;
|
|
6594
6969
|
let r = n.getSource("square-preview-source");
|
|
6595
6970
|
if (!r) return;
|
|
6596
|
-
let i =
|
|
6971
|
+
let i = Jt(e, t) * 2, a = rn(e, i);
|
|
6597
6972
|
r.setData({
|
|
6598
6973
|
type: "Feature",
|
|
6599
6974
|
geometry: {
|
|
@@ -6602,11 +6977,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6602
6977
|
},
|
|
6603
6978
|
properties: {}
|
|
6604
6979
|
});
|
|
6605
|
-
let o =
|
|
6980
|
+
let o = mt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6606
6981
|
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));
|
|
6607
6982
|
let d = n.getSource("square-preview-measure-source");
|
|
6608
6983
|
if (d) {
|
|
6609
|
-
let t =
|
|
6984
|
+
let t = Un.current, n = [];
|
|
6610
6985
|
if (t?.showArea && n.push({
|
|
6611
6986
|
type: "Feature",
|
|
6612
6987
|
geometry: {
|
|
@@ -6630,7 +7005,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6630
7005
|
features: n
|
|
6631
7006
|
});
|
|
6632
7007
|
}
|
|
6633
|
-
}, [
|
|
7008
|
+
}, [Jt, rn]), on = useCallback(() => {
|
|
6634
7009
|
let e = L.current;
|
|
6635
7010
|
if (!e) return;
|
|
6636
7011
|
let t = e.getSource("square-preview-source");
|
|
@@ -6643,9 +7018,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6643
7018
|
type: "FeatureCollection",
|
|
6644
7019
|
features: []
|
|
6645
7020
|
});
|
|
6646
|
-
}, []),
|
|
6647
|
-
|
|
6648
|
-
}, [
|
|
7021
|
+
}, []), sn = useCallback(() => {
|
|
7022
|
+
ht.current = null, on();
|
|
7023
|
+
}, [on]), cn = useCallback(() => {
|
|
6649
7024
|
let e = L.current;
|
|
6650
7025
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6651
7026
|
type: "geojson",
|
|
@@ -6678,8 +7053,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6678
7053
|
"circle-stroke-color": "#ffffff",
|
|
6679
7054
|
"circle-stroke-width": 2
|
|
6680
7055
|
}
|
|
6681
|
-
}),
|
|
6682
|
-
}, [
|
|
7056
|
+
}), Ht(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
7057
|
+
}, [Ht]), ln = useCallback((e, t) => {
|
|
6683
7058
|
let n = L.current;
|
|
6684
7059
|
if (!n) return;
|
|
6685
7060
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
@@ -6706,11 +7081,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6706
7081
|
properties: {}
|
|
6707
7082
|
}))
|
|
6708
7083
|
});
|
|
6709
|
-
let o =
|
|
7084
|
+
let o = gt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
6710
7085
|
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);
|
|
6711
7086
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6712
7087
|
if (l) {
|
|
6713
|
-
let e =
|
|
7088
|
+
let e = Un.current, t = [];
|
|
6714
7089
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6715
7090
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6716
7091
|
t.push({
|
|
@@ -6727,7 +7102,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6727
7102
|
features: t
|
|
6728
7103
|
});
|
|
6729
7104
|
}
|
|
6730
|
-
}, []),
|
|
7105
|
+
}, []), un = useCallback(() => {
|
|
6731
7106
|
let e = L.current;
|
|
6732
7107
|
if (!e) return;
|
|
6733
7108
|
let t = e.getSource("polyline-preview-source");
|
|
@@ -6746,158 +7121,158 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6746
7121
|
features: []
|
|
6747
7122
|
});
|
|
6748
7123
|
}, []), Z = useCallback(() => {
|
|
6749
|
-
|
|
6750
|
-
}, [
|
|
6751
|
-
H(e),
|
|
7124
|
+
_t.current = [], un();
|
|
7125
|
+
}, [un]), dn = useCallback((e) => {
|
|
7126
|
+
H(e), Vt(e), e ? (U("marker"), X(), Zt(), tn(), sn(), Z()) : U(null);
|
|
6752
7127
|
}, [
|
|
6753
|
-
|
|
7128
|
+
Vt,
|
|
6754
7129
|
X,
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
7130
|
+
Zt,
|
|
7131
|
+
tn,
|
|
7132
|
+
sn,
|
|
6758
7133
|
Z
|
|
6759
|
-
]),
|
|
7134
|
+
]), fn = useCallback((e) => {
|
|
6760
7135
|
if (U(e), e === "rectangle") {
|
|
6761
|
-
H(null), Y(),
|
|
7136
|
+
H(null), Y(), Zt(), tn(), sn(), Z();
|
|
6762
7137
|
let e = L.current;
|
|
6763
7138
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6764
7139
|
} else if (e === "circle") {
|
|
6765
|
-
H(null), Y(), X(),
|
|
7140
|
+
H(null), Y(), X(), tn(), sn(), Z();
|
|
6766
7141
|
let e = L.current;
|
|
6767
7142
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6768
7143
|
} else if (e === "polygon") {
|
|
6769
|
-
H(null), Y(), X(),
|
|
7144
|
+
H(null), Y(), X(), Zt(), sn(), Z();
|
|
6770
7145
|
let e = L.current;
|
|
6771
7146
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6772
7147
|
} else if (e === "square") {
|
|
6773
|
-
H(null), Y(), X(),
|
|
7148
|
+
H(null), Y(), X(), Zt(), tn(), Z();
|
|
6774
7149
|
let e = L.current;
|
|
6775
7150
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6776
7151
|
} else if (e === "polyline") {
|
|
6777
|
-
H(null), Y(), X(),
|
|
7152
|
+
H(null), Y(), X(), Zt(), tn(), sn();
|
|
6778
7153
|
let e = L.current;
|
|
6779
7154
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6780
|
-
} else e === "marker" ? (X(),
|
|
7155
|
+
} else e === "marker" ? (X(), Zt(), tn(), sn(), Z()) : (H(null), Y(), X(), Zt(), tn(), sn(), Z());
|
|
6781
7156
|
}, [
|
|
6782
7157
|
Y,
|
|
6783
7158
|
X,
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
7159
|
+
Zt,
|
|
7160
|
+
tn,
|
|
7161
|
+
sn,
|
|
6787
7162
|
Z
|
|
6788
|
-
]),
|
|
7163
|
+
]), pn = useCallback((e) => {
|
|
6789
7164
|
if (e !== "picker") {
|
|
6790
7165
|
let e = J.value && isFinite(J.value.lng) && isFinite(J.value.lat), t = J.showMarker !== !1;
|
|
6791
|
-
(!e || !t) &&
|
|
7166
|
+
(!e || !t) && zt(), it(null);
|
|
6792
7167
|
}
|
|
6793
|
-
e !== "edit" && (H(null), U(null), X(), Z(), Y()),
|
|
7168
|
+
e !== "edit" && (H(null), U(null), X(), Z(), Y()), nt(e);
|
|
6794
7169
|
}, [
|
|
6795
|
-
|
|
7170
|
+
zt,
|
|
6796
7171
|
Y,
|
|
6797
7172
|
X,
|
|
6798
7173
|
Z
|
|
6799
|
-
]),
|
|
6800
|
-
|
|
6801
|
-
}, [
|
|
6802
|
-
|
|
6803
|
-
})), [
|
|
7174
|
+
]), mn = useCallback(() => V, [V]), hn = useCallback(() => rt, [rt]), gn = useCallback(() => {
|
|
7175
|
+
zt(), it(null);
|
|
7176
|
+
}, [zt]), _n = useCallback((e = {}) => (Pt.current &&= (Pt.current(null), null), new Promise((t) => {
|
|
7177
|
+
Pt.current = t, Ft.current = Rn.current, Lt(e), pn("picker");
|
|
7178
|
+
})), [pn]);
|
|
6804
7179
|
useEffect(() => {
|
|
6805
|
-
if (
|
|
7180
|
+
if (!et) return;
|
|
6806
7181
|
let e = J.value;
|
|
6807
7182
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6808
7183
|
let t = [e.lng, e.lat];
|
|
6809
|
-
|
|
7184
|
+
it(e), Rt(t);
|
|
6810
7185
|
}
|
|
6811
7186
|
}, [
|
|
6812
7187
|
J.value,
|
|
6813
|
-
|
|
6814
|
-
|
|
7188
|
+
Rt,
|
|
7189
|
+
et
|
|
6815
7190
|
]);
|
|
6816
|
-
let
|
|
6817
|
-
if (
|
|
6818
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
7191
|
+
let vn = (e) => "mode" in e, yn = useCallback((e, t = !0) => {
|
|
7192
|
+
if (nt("edit"), t && (zt(), it(null)), W.current = !0, vn(e)) {
|
|
7193
|
+
if (e.mode === "marker") e.markerStyle ? (dt.current = e.markerStyle, ut.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? Vt({
|
|
6819
7194
|
id: "custom",
|
|
6820
7195
|
name: e.markerStyle.name || "Marker",
|
|
6821
7196
|
icon: e.markerStyle.src,
|
|
6822
7197
|
width: e.markerStyle.width
|
|
6823
|
-
}) : Y()) : e.template && (
|
|
7198
|
+
}) : Y()) : e.template && (dt.current = null, ut.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null, H(e.template), U("marker"), Vt(e.template));
|
|
6824
7199
|
else if (e.mode === "rectangle") {
|
|
6825
|
-
|
|
7200
|
+
ut.current = e.rectangleStyle || null, dt.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null, H(null), U("rectangle"), Y();
|
|
6826
7201
|
let t = L.current;
|
|
6827
7202
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6828
7203
|
} else if (e.mode === "circle") {
|
|
6829
|
-
G.current = e.circleStyle || null,
|
|
7204
|
+
G.current = e.circleStyle || null, ut.current = null, dt.current = null, K.current = null, mt.current = null, gt.current = null, H(null), U("circle"), Y();
|
|
6830
7205
|
let t = L.current;
|
|
6831
7206
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6832
7207
|
} else if (e.mode === "polygon") {
|
|
6833
|
-
K.current = e.polygonStyle || null,
|
|
7208
|
+
K.current = e.polygonStyle || null, ut.current = null, dt.current = null, G.current = null, mt.current = null, gt.current = null, H(null), U("polygon"), Y();
|
|
6834
7209
|
let t = L.current;
|
|
6835
7210
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6836
7211
|
} else if (e.mode === "square") {
|
|
6837
|
-
|
|
7212
|
+
mt.current = e.squareStyle || null, ut.current = null, dt.current = null, G.current = null, K.current = null, gt.current = null, H(null), U("square"), Y();
|
|
6838
7213
|
let t = L.current;
|
|
6839
7214
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6840
7215
|
} else if (e.mode === "polyline") {
|
|
6841
|
-
|
|
7216
|
+
gt.current = e.polylineStyle || null, ut.current = null, dt.current = null, G.current = null, K.current = null, mt.current = null, H(null), U("polyline"), Y();
|
|
6842
7217
|
let t = L.current;
|
|
6843
7218
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6844
7219
|
}
|
|
6845
|
-
} else H(e), U("marker"),
|
|
7220
|
+
} else H(e), U("marker"), Vt(e), ut.current = null, dt.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null;
|
|
6846
7221
|
}, [
|
|
6847
|
-
|
|
6848
|
-
|
|
7222
|
+
zt,
|
|
7223
|
+
Vt,
|
|
6849
7224
|
Y
|
|
6850
7225
|
]);
|
|
6851
7226
|
useImperativeHandle(c, () => ({
|
|
6852
|
-
startAnimation:
|
|
6853
|
-
stopAnimation:
|
|
6854
|
-
toggleAnimation:
|
|
7227
|
+
startAnimation: Ct,
|
|
7228
|
+
stopAnimation: wt,
|
|
7229
|
+
toggleAnimation: Tt,
|
|
6855
7230
|
getMap: () => L.current,
|
|
6856
|
-
openPopup: (e) =>
|
|
6857
|
-
closePopup:
|
|
6858
|
-
closeAllPopups:
|
|
6859
|
-
isPopupOpen:
|
|
6860
|
-
toggleUnitTrajectory:
|
|
6861
|
-
flyTo:
|
|
6862
|
-
getCenterByIds:
|
|
6863
|
-
flyToEntities:
|
|
6864
|
-
getMode:
|
|
6865
|
-
setMode:
|
|
6866
|
-
getPickedLocation:
|
|
6867
|
-
clearPickedLocation:
|
|
6868
|
-
startDrawing:
|
|
7231
|
+
openPopup: (e) => Dt(e, "programmatic"),
|
|
7232
|
+
closePopup: Ot,
|
|
7233
|
+
closeAllPopups: kt,
|
|
7234
|
+
isPopupOpen: At,
|
|
7235
|
+
toggleUnitTrajectory: Et,
|
|
7236
|
+
flyTo: jt,
|
|
7237
|
+
getCenterByIds: Mt,
|
|
7238
|
+
flyToEntities: Nt,
|
|
7239
|
+
getMode: mn,
|
|
7240
|
+
setMode: pn,
|
|
7241
|
+
getPickedLocation: hn,
|
|
7242
|
+
clearPickedLocation: gn,
|
|
7243
|
+
startDrawing: yn,
|
|
6869
7244
|
getRenderer: (e) => R.current.get(e),
|
|
6870
7245
|
setEditingEntities: (e) => {
|
|
6871
|
-
for (let t of
|
|
7246
|
+
for (let t of St.current) e.map(String).includes(String(t)) || R.current.get(t)?.setEditing?.(!1);
|
|
6872
7247
|
for (let t of e) R.current.get(t)?.setEditing?.(!0);
|
|
6873
|
-
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null),
|
|
7248
|
+
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null), xt(e);
|
|
6874
7249
|
},
|
|
6875
|
-
getEditingEntities: () =>
|
|
6876
|
-
startPicking:
|
|
7250
|
+
getEditingEntities: () => St.current,
|
|
7251
|
+
startPicking: _n,
|
|
6877
7252
|
startRoutePlanning: (e) => {
|
|
6878
|
-
|
|
7253
|
+
Ue.current?.startPlanning(e);
|
|
6879
7254
|
},
|
|
6880
|
-
getRoadHighlightControl: () =>
|
|
7255
|
+
getRoadHighlightControl: () => We.current
|
|
6881
7256
|
}), [
|
|
6882
|
-
St,
|
|
6883
7257
|
Ct,
|
|
6884
7258
|
wt,
|
|
6885
|
-
|
|
7259
|
+
Tt,
|
|
6886
7260
|
Dt,
|
|
6887
7261
|
Ot,
|
|
6888
7262
|
kt,
|
|
6889
|
-
Tt,
|
|
6890
7263
|
At,
|
|
7264
|
+
Et,
|
|
6891
7265
|
jt,
|
|
6892
7266
|
Mt,
|
|
6893
|
-
|
|
6894
|
-
fn,
|
|
7267
|
+
Nt,
|
|
6895
7268
|
mn,
|
|
7269
|
+
pn,
|
|
6896
7270
|
hn,
|
|
6897
|
-
|
|
6898
|
-
|
|
7271
|
+
gn,
|
|
7272
|
+
yn,
|
|
7273
|
+
_n
|
|
6899
7274
|
]);
|
|
6900
|
-
let
|
|
7275
|
+
let bn = useCallback(() => {
|
|
6901
7276
|
let e = L.current;
|
|
6902
7277
|
if (!e) return;
|
|
6903
7278
|
let t = new Set(T.map((e) => e.id)), n = new Set(R.current.keys());
|
|
@@ -6922,13 +7297,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6922
7297
|
let t = new CircleRenderer(e, n, O, k, j, M);
|
|
6923
7298
|
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6924
7299
|
}
|
|
6925
|
-
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
7300
|
+
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer || n.type === "attack-direction" && i instanceof AttackDirectionRenderer) && i.update(n);
|
|
6926
7301
|
else {
|
|
6927
7302
|
let t = null;
|
|
6928
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, j, M) : new CircleRenderer(e, n, O, k, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, j, N) : n.type === "polyline"
|
|
7303
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, j, M) : new CircleRenderer(e, n, O, k, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, j, N) : n.type === "polyline" ? t = new PolylineRenderer(e, n, O, k, N) : n.type === "attack-direction" && (t = new AttackDirectionRenderer(e, n, O, k)), t && (R.current.set(n.id, t), t.setSelected(r.has(String(n.id))), St.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
6929
7304
|
}
|
|
6930
7305
|
}
|
|
6931
|
-
for (let e of
|
|
7306
|
+
for (let e of St.current) {
|
|
6932
7307
|
let t = R.current.get(e);
|
|
6933
7308
|
t && t.setEditing?.(!0);
|
|
6934
7309
|
}
|
|
@@ -6941,10 +7316,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6941
7316
|
j,
|
|
6942
7317
|
M,
|
|
6943
7318
|
N
|
|
6944
|
-
]),
|
|
7319
|
+
]), xn = useCallback(() => {
|
|
6945
7320
|
for (let e of R.current.values()) e.destroy();
|
|
6946
7321
|
R.current.clear();
|
|
6947
|
-
}, []),
|
|
7322
|
+
}, []), Sn = useCallback((e) => {
|
|
6948
7323
|
let t = e.getStyle();
|
|
6949
7324
|
if (!t?.layers) return;
|
|
6950
7325
|
let n = [
|
|
@@ -6956,13 +7331,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6956
7331
|
"radar-",
|
|
6957
7332
|
"image-",
|
|
6958
7333
|
"unit-",
|
|
6959
|
-
"marker-"
|
|
7334
|
+
"marker-",
|
|
7335
|
+
"attack-direction-"
|
|
6960
7336
|
];
|
|
6961
7337
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6962
|
-
}, []),
|
|
7338
|
+
}, []), Cn = useCallback((e) => {
|
|
6963
7339
|
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;
|
|
6964
7340
|
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;
|
|
6965
|
-
}, [C]),
|
|
7341
|
+
}, [C]), wn = useCallback((e, t) => {
|
|
6966
7342
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6967
7343
|
type: "raster",
|
|
6968
7344
|
tiles: [t.url],
|
|
@@ -6972,19 +7348,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6972
7348
|
scheme: t.scheme ?? "xyz"
|
|
6973
7349
|
};
|
|
6974
7350
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6975
|
-
let a =
|
|
7351
|
+
let a = Sn(e);
|
|
6976
7352
|
e.addLayer({
|
|
6977
7353
|
id: r,
|
|
6978
7354
|
type: "raster",
|
|
6979
7355
|
source: n,
|
|
6980
|
-
paint:
|
|
7356
|
+
paint: Cn(t),
|
|
6981
7357
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6982
7358
|
}, a);
|
|
6983
|
-
}, [
|
|
7359
|
+
}, [Sn, Cn]), Tn = useCallback(async (e, t) => {
|
|
6984
7360
|
try {
|
|
6985
7361
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6986
|
-
if (!
|
|
6987
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
7362
|
+
if (!Ge.current.has(t.id)) return;
|
|
7363
|
+
let a = n.format === "pbf" || n.vector_layers, o = Sn(e);
|
|
6988
7364
|
if (a) {
|
|
6989
7365
|
let t = {
|
|
6990
7366
|
type: "vector",
|
|
@@ -7005,21 +7381,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7005
7381
|
id: i,
|
|
7006
7382
|
type: "raster",
|
|
7007
7383
|
source: r,
|
|
7008
|
-
paint:
|
|
7384
|
+
paint: Cn(t),
|
|
7009
7385
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
7010
7386
|
}, o);
|
|
7011
7387
|
} catch (e) {
|
|
7012
7388
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
7013
7389
|
}
|
|
7014
|
-
}, [
|
|
7390
|
+
}, [Sn, Cn]), En = useCallback(async (e, t) => {
|
|
7015
7391
|
try {
|
|
7016
7392
|
let n = await (await fetch(t.url)).json();
|
|
7017
|
-
if (!
|
|
7393
|
+
if (!Ge.current.has(t.id)) return;
|
|
7018
7394
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
7019
7395
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
7020
7396
|
e.getSource(n) || e.addSource(n, i);
|
|
7021
7397
|
}
|
|
7022
|
-
let r =
|
|
7398
|
+
let r = Sn(e);
|
|
7023
7399
|
if (n.layers) for (let i of n.layers) {
|
|
7024
7400
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
7025
7401
|
if (e.getLayer(n)) continue;
|
|
@@ -7030,7 +7406,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7030
7406
|
};
|
|
7031
7407
|
i.type === "raster" && (a.paint = {
|
|
7032
7408
|
...a.paint,
|
|
7033
|
-
...
|
|
7409
|
+
...Cn(t)
|
|
7034
7410
|
}), t.visible === !1 && (a.layout = {
|
|
7035
7411
|
...a.layout,
|
|
7036
7412
|
visibility: "none"
|
|
@@ -7043,50 +7419,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7043
7419
|
} catch (e) {
|
|
7044
7420
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
7045
7421
|
}
|
|
7046
|
-
}, [
|
|
7422
|
+
}, [Sn, Cn]), Dn = useCallback((e, t) => {
|
|
7047
7423
|
let n = e.getStyle();
|
|
7048
7424
|
if (!n) return;
|
|
7049
7425
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
7050
7426
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
7051
7427
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7052
7428
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7053
|
-
}, []),
|
|
7429
|
+
}, []), On = useCallback((e) => {
|
|
7054
7430
|
let t = L.current;
|
|
7055
7431
|
if (!t) return;
|
|
7056
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
7057
|
-
for (let e of r) n.has(e) || (
|
|
7432
|
+
let n = new Set(e.map((e) => e.id)), r = Ge.current;
|
|
7433
|
+
for (let e of r) n.has(e) || (Dn(t, e), r.delete(e));
|
|
7058
7434
|
for (let n of e) if (r.has(n.id)) {
|
|
7059
7435
|
let e = `base-layer-${n.id}`;
|
|
7060
7436
|
if (t.getLayer(e)) {
|
|
7061
|
-
let r =
|
|
7437
|
+
let r = Cn(n);
|
|
7062
7438
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7063
7439
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7064
7440
|
}
|
|
7065
7441
|
} else switch (r.add(n.id), n.type) {
|
|
7066
7442
|
case "raster":
|
|
7067
|
-
|
|
7443
|
+
wn(t, n);
|
|
7068
7444
|
break;
|
|
7069
7445
|
case "tilejson":
|
|
7070
|
-
|
|
7446
|
+
Tn(t, n);
|
|
7071
7447
|
break;
|
|
7072
7448
|
case "style":
|
|
7073
|
-
|
|
7449
|
+
En(t, n);
|
|
7074
7450
|
break;
|
|
7075
7451
|
default: {
|
|
7076
7452
|
let e = n;
|
|
7077
|
-
e.url &&
|
|
7453
|
+
e.url && wn(t, {
|
|
7078
7454
|
...e,
|
|
7079
7455
|
type: "raster"
|
|
7080
7456
|
});
|
|
7081
7457
|
}
|
|
7082
7458
|
}
|
|
7083
7459
|
}, [
|
|
7084
|
-
Cn,
|
|
7085
7460
|
wn,
|
|
7086
7461
|
Tn,
|
|
7087
7462
|
En,
|
|
7088
|
-
|
|
7089
|
-
|
|
7463
|
+
Dn,
|
|
7464
|
+
Cn
|
|
7465
|
+
]), kn = useCallback((e) => {
|
|
7090
7466
|
let t = e;
|
|
7091
7467
|
for (; t;) {
|
|
7092
7468
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7094,129 +7470,129 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7094
7470
|
t = t.parentElement;
|
|
7095
7471
|
}
|
|
7096
7472
|
return null;
|
|
7097
|
-
}, []),
|
|
7473
|
+
}, []), An = useCallback((e) => {
|
|
7098
7474
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7099
7475
|
x: e.point.x,
|
|
7100
7476
|
y: e.point.y
|
|
7101
|
-
}, r =
|
|
7477
|
+
}, r = Rn.current;
|
|
7102
7478
|
if (r === "picker") {
|
|
7103
7479
|
let e = {
|
|
7104
7480
|
lng: t[0],
|
|
7105
7481
|
lat: t[1]
|
|
7106
7482
|
};
|
|
7107
|
-
|
|
7483
|
+
it(e), Rt(t), zn.current?.(e), Pt.current && (Pt.current(e), Pt.current = null, Lt({}), zt(), it(null), pn(Ft.current));
|
|
7108
7484
|
return;
|
|
7109
7485
|
}
|
|
7110
|
-
if (
|
|
7486
|
+
if (yt.current) return;
|
|
7111
7487
|
if (r === "edit") {
|
|
7112
|
-
let e =
|
|
7488
|
+
let e = Vn.current;
|
|
7113
7489
|
if (e === "rectangle") {
|
|
7114
|
-
let e =
|
|
7115
|
-
if (!e)
|
|
7490
|
+
let e = Hn.current;
|
|
7491
|
+
if (!e) lt(t);
|
|
7116
7492
|
else {
|
|
7117
|
-
let n =
|
|
7493
|
+
let n = ut.current, r = applyEntityConfig({
|
|
7118
7494
|
...n,
|
|
7119
|
-
id: n?.id ??
|
|
7495
|
+
id: n?.id ?? Bt(),
|
|
7120
7496
|
type: "rectangle",
|
|
7121
7497
|
bounds: [e, t]
|
|
7122
7498
|
}, D);
|
|
7123
|
-
|
|
7499
|
+
Gt();
|
|
7124
7500
|
let i = L.current;
|
|
7125
7501
|
if (i && !R.current.has(r.id)) {
|
|
7126
7502
|
let e = new RectangleRenderer(i, r, O, k, j, N);
|
|
7127
7503
|
R.current.set(r.id, e);
|
|
7128
7504
|
}
|
|
7129
|
-
Q.current.onRectangleAdd?.(r),
|
|
7505
|
+
Q.current.onRectangleAdd?.(r), lt(null), ut.current = null, W.current && (W.current = !1, U(null), i && (i.getCanvas().style.cursor = ""));
|
|
7130
7506
|
}
|
|
7131
7507
|
return;
|
|
7132
7508
|
}
|
|
7133
7509
|
if (e === "circle") {
|
|
7134
|
-
let e =
|
|
7135
|
-
if (!e)
|
|
7510
|
+
let e = ft.current;
|
|
7511
|
+
if (!e) ft.current = { center: t };
|
|
7136
7512
|
else {
|
|
7137
|
-
let n =
|
|
7513
|
+
let n = Jt(e.center, t), r = G.current, i = applyEntityConfig({
|
|
7138
7514
|
...r,
|
|
7139
|
-
id: r?.id ??
|
|
7515
|
+
id: r?.id ?? Bt(),
|
|
7140
7516
|
type: "circle",
|
|
7141
7517
|
center: e.center,
|
|
7142
7518
|
radius: n
|
|
7143
7519
|
}, D);
|
|
7144
|
-
|
|
7520
|
+
Xt();
|
|
7145
7521
|
let a = L.current;
|
|
7146
7522
|
if (a && !R.current.has(i.id)) {
|
|
7147
7523
|
let e = new CircleRenderer(a, i, O, k, j, M);
|
|
7148
7524
|
R.current.set(i.id, e);
|
|
7149
7525
|
}
|
|
7150
|
-
Q.current.onCircleAdd?.(i),
|
|
7526
|
+
Q.current.onCircleAdd?.(i), ft.current = null, G.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7151
7527
|
}
|
|
7152
7528
|
return;
|
|
7153
7529
|
}
|
|
7154
7530
|
if (e === "polygon") {
|
|
7155
|
-
let e =
|
|
7531
|
+
let e = pt.current;
|
|
7156
7532
|
if (e.length >= 3) {
|
|
7157
7533
|
let n = e[0];
|
|
7158
|
-
if (
|
|
7534
|
+
if (Jt(n, t) < 20) {
|
|
7159
7535
|
let t = K.current, n = applyEntityConfig({
|
|
7160
7536
|
...t,
|
|
7161
|
-
id: t?.id ??
|
|
7537
|
+
id: t?.id ?? Bt(),
|
|
7162
7538
|
type: "polygon",
|
|
7163
7539
|
coordinates: [...e]
|
|
7164
7540
|
}, D);
|
|
7165
|
-
|
|
7541
|
+
en();
|
|
7166
7542
|
let r = L.current;
|
|
7167
7543
|
if (r && !R.current.has(n.id)) {
|
|
7168
7544
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7169
7545
|
R.current.set(n.id, e);
|
|
7170
7546
|
}
|
|
7171
|
-
Q.current.onPolygonAdd?.(n),
|
|
7547
|
+
Q.current.onPolygonAdd?.(n), pt.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7172
7548
|
return;
|
|
7173
7549
|
}
|
|
7174
7550
|
}
|
|
7175
|
-
|
|
7551
|
+
pt.current = [...e, t];
|
|
7176
7552
|
return;
|
|
7177
7553
|
}
|
|
7178
7554
|
if (e === "square") {
|
|
7179
|
-
let e =
|
|
7180
|
-
if (!e)
|
|
7555
|
+
let e = ht.current;
|
|
7556
|
+
if (!e) ht.current = { center: t };
|
|
7181
7557
|
else {
|
|
7182
|
-
let n =
|
|
7558
|
+
let n = Jt(e.center, t) * 2, r = mt.current, i = applyEntityConfig({
|
|
7183
7559
|
...r,
|
|
7184
|
-
id: r?.id ??
|
|
7560
|
+
id: r?.id ?? Bt(),
|
|
7185
7561
|
type: "square",
|
|
7186
7562
|
center: e.center,
|
|
7187
7563
|
length: n
|
|
7188
7564
|
}, D);
|
|
7189
|
-
|
|
7565
|
+
on();
|
|
7190
7566
|
let a = L.current;
|
|
7191
7567
|
if (a && !R.current.has(i.id)) {
|
|
7192
7568
|
let e = new SquareRenderer(a, i, O, k, j, N);
|
|
7193
7569
|
R.current.set(i.id, e);
|
|
7194
7570
|
}
|
|
7195
|
-
Q.current.onSquareAdd?.(i),
|
|
7571
|
+
Q.current.onSquareAdd?.(i), ht.current = null, mt.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7196
7572
|
}
|
|
7197
7573
|
return;
|
|
7198
7574
|
}
|
|
7199
7575
|
if (e === "polyline") {
|
|
7200
|
-
|
|
7576
|
+
_t.current = [..._t.current, t];
|
|
7201
7577
|
return;
|
|
7202
7578
|
}
|
|
7203
|
-
let n =
|
|
7579
|
+
let n = dt.current;
|
|
7204
7580
|
if (n && n.src && n.width) {
|
|
7205
7581
|
let e = {
|
|
7206
7582
|
...n,
|
|
7207
|
-
id: n.id ??
|
|
7583
|
+
id: n.id ?? Bt(),
|
|
7208
7584
|
type: "marker",
|
|
7209
7585
|
center: t,
|
|
7210
7586
|
src: n.src,
|
|
7211
7587
|
width: n.width
|
|
7212
7588
|
};
|
|
7213
|
-
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(),
|
|
7589
|
+
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), dt.current = null, W.current = !1;
|
|
7214
7590
|
return;
|
|
7215
7591
|
}
|
|
7216
|
-
let r =
|
|
7592
|
+
let r = Bn.current;
|
|
7217
7593
|
if (r) {
|
|
7218
7594
|
let e = {
|
|
7219
|
-
id:
|
|
7595
|
+
id: Bt(),
|
|
7220
7596
|
type: "marker",
|
|
7221
7597
|
name: r.name,
|
|
7222
7598
|
center: t,
|
|
@@ -7227,7 +7603,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7227
7603
|
return;
|
|
7228
7604
|
}
|
|
7229
7605
|
}
|
|
7230
|
-
if (
|
|
7606
|
+
if (St.current.length > 0) {
|
|
7231
7607
|
let e = L.current?.getZoom() ?? 12;
|
|
7232
7608
|
if (q.current) {
|
|
7233
7609
|
let { entityId: e, activeHandle: n } = q.current, r = R.current.get(e);
|
|
@@ -7238,7 +7614,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7238
7614
|
q.current = null;
|
|
7239
7615
|
return;
|
|
7240
7616
|
}
|
|
7241
|
-
for (let n of
|
|
7617
|
+
for (let n of St.current) {
|
|
7242
7618
|
let r = R.current.get(n);
|
|
7243
7619
|
if (!r?.getEditHandleAt) continue;
|
|
7244
7620
|
let i = r.getEditHandleAt(t, e);
|
|
@@ -7261,12 +7637,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7261
7637
|
}
|
|
7262
7638
|
}
|
|
7263
7639
|
}
|
|
7264
|
-
let i =
|
|
7640
|
+
let i = Fn.current, a = In.current, o = Ln.current, s = kn(e.originalEvent.target);
|
|
7265
7641
|
if (s) {
|
|
7266
7642
|
let e = i.find((e) => String(e.id) === s);
|
|
7267
7643
|
if (e) {
|
|
7268
7644
|
if (a?.(e), e.popup) {
|
|
7269
|
-
let t = e.popup.content ??
|
|
7645
|
+
let t = e.popup.content ?? Fe?.(e);
|
|
7270
7646
|
t && mergePopupConfig(e.popup, I, t).trigger === "click" && o(s, "click", n);
|
|
7271
7647
|
}
|
|
7272
7648
|
return;
|
|
@@ -7278,7 +7654,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7278
7654
|
let e = i.find((e) => e.id === t);
|
|
7279
7655
|
if (e) {
|
|
7280
7656
|
if (a?.(e), e.popup) {
|
|
7281
|
-
let r = e.popup.content ??
|
|
7657
|
+
let r = e.popup.content ?? Fe?.(e);
|
|
7282
7658
|
r && mergePopupConfig(e.popup, I, r).trigger === "click" && o(t, "click", n);
|
|
7283
7659
|
}
|
|
7284
7660
|
return;
|
|
@@ -7289,7 +7665,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7289
7665
|
let t = i.find((t) => t.id === e);
|
|
7290
7666
|
if (t) {
|
|
7291
7667
|
if (a?.(t), t.popup) {
|
|
7292
|
-
let r = t.popup.content ??
|
|
7668
|
+
let r = t.popup.content ?? Fe?.(t);
|
|
7293
7669
|
r && mergePopupConfig(t.popup, I, r).trigger === "click" && o(e, "click", n);
|
|
7294
7670
|
}
|
|
7295
7671
|
return;
|
|
@@ -7297,67 +7673,67 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7297
7673
|
}
|
|
7298
7674
|
}, [
|
|
7299
7675
|
I,
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
]),
|
|
7676
|
+
Fe,
|
|
7677
|
+
kn
|
|
7678
|
+
]), jn = useCallback((e) => {
|
|
7303
7679
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7304
7680
|
if (q.current) {
|
|
7305
7681
|
let { entityId: e, activeHandle: n } = q.current;
|
|
7306
7682
|
R.current.get(e)?.updateEditPreview?.(n, t);
|
|
7307
7683
|
return;
|
|
7308
7684
|
}
|
|
7309
|
-
let n =
|
|
7310
|
-
n === "rectangle" && r &&
|
|
7311
|
-
let i =
|
|
7312
|
-
n === "circle" && i &&
|
|
7313
|
-
let a =
|
|
7314
|
-
n === "polygon" && a.length > 0 &&
|
|
7315
|
-
let o =
|
|
7316
|
-
n === "square" && o &&
|
|
7317
|
-
let s =
|
|
7318
|
-
n === "polyline" && s.length > 0 &&
|
|
7319
|
-
let c =
|
|
7685
|
+
let n = Vn.current, r = Hn.current;
|
|
7686
|
+
n === "rectangle" && r && Wt(r, t);
|
|
7687
|
+
let i = ft.current;
|
|
7688
|
+
n === "circle" && i && Yt(i.center, t);
|
|
7689
|
+
let a = pt.current;
|
|
7690
|
+
n === "polygon" && a.length > 0 && $t(a, t);
|
|
7691
|
+
let o = ht.current;
|
|
7692
|
+
n === "square" && o && an(o.center, t);
|
|
7693
|
+
let s = _t.current;
|
|
7694
|
+
n === "polyline" && s.length > 0 && ln(s, t);
|
|
7695
|
+
let c = Fn.current, l = Ln.current;
|
|
7320
7696
|
for (let [e, n] of R.current) if (n.isPointInEntity(t)) {
|
|
7321
7697
|
let t = c.find((t) => t.id === e);
|
|
7322
7698
|
if (!t?.popup) continue;
|
|
7323
|
-
let n = t.popup.content ??
|
|
7699
|
+
let n = t.popup.content ?? Fe?.(t);
|
|
7324
7700
|
if (!n) continue;
|
|
7325
7701
|
let r = mergePopupConfig(t.popup, I, n);
|
|
7326
7702
|
if (r.trigger === "hover") {
|
|
7327
|
-
|
|
7703
|
+
Ye.current && clearTimeout(Ye.current), Ye.current = window.setTimeout(() => {
|
|
7328
7704
|
l(e, "hover");
|
|
7329
7705
|
}, r.hoverDelay);
|
|
7330
7706
|
return;
|
|
7331
7707
|
}
|
|
7332
7708
|
}
|
|
7333
|
-
if (
|
|
7709
|
+
if (Ye.current &&= (clearTimeout(Ye.current), null), B?.openedBy === "hover") {
|
|
7334
7710
|
let e = R.current.get(B.entityId);
|
|
7335
|
-
e && !e.isPointInEntity(t) &&
|
|
7711
|
+
e && !e.isPointInEntity(t) && Ot(B.entityId);
|
|
7336
7712
|
}
|
|
7337
7713
|
}, [
|
|
7338
7714
|
I,
|
|
7339
|
-
|
|
7715
|
+
Fe,
|
|
7340
7716
|
B,
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
]),
|
|
7348
|
-
if (e.preventDefault(),
|
|
7349
|
-
|
|
7717
|
+
Ot,
|
|
7718
|
+
Wt,
|
|
7719
|
+
Yt,
|
|
7720
|
+
$t,
|
|
7721
|
+
an,
|
|
7722
|
+
ln
|
|
7723
|
+
]), Mn = useCallback((e) => {
|
|
7724
|
+
if (e.preventDefault(), Pt.current) {
|
|
7725
|
+
Pt.current(null), Pt.current = null, Lt({}), zt(), it(null), pn(Ft.current);
|
|
7350
7726
|
return;
|
|
7351
7727
|
}
|
|
7352
|
-
if (
|
|
7353
|
-
if (
|
|
7728
|
+
if (yt.current) return;
|
|
7729
|
+
if (St.current.length > 0) {
|
|
7354
7730
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7355
7731
|
if (q.current) {
|
|
7356
7732
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7357
7733
|
return;
|
|
7358
7734
|
}
|
|
7359
7735
|
let n = L.current?.getZoom() ?? 12;
|
|
7360
|
-
for (let e of
|
|
7736
|
+
for (let e of St.current) {
|
|
7361
7737
|
let r = R.current.get(e);
|
|
7362
7738
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7363
7739
|
let i = r.getEditHandleAt(t, n);
|
|
@@ -7368,14 +7744,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7368
7744
|
}
|
|
7369
7745
|
}
|
|
7370
7746
|
}
|
|
7371
|
-
if (
|
|
7372
|
-
if (
|
|
7747
|
+
if (Rn.current !== "edit") return;
|
|
7748
|
+
if (Bn.current) {
|
|
7373
7749
|
H(null), U(null), Y();
|
|
7374
7750
|
return;
|
|
7375
7751
|
}
|
|
7376
|
-
let t =
|
|
7752
|
+
let t = Vn.current;
|
|
7377
7753
|
if (t === "rectangle") {
|
|
7378
|
-
if (
|
|
7754
|
+
if (Hn.current) lt(null), Gt();
|
|
7379
7755
|
else {
|
|
7380
7756
|
U(null);
|
|
7381
7757
|
let e = L.current;
|
|
@@ -7384,7 +7760,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7384
7760
|
return;
|
|
7385
7761
|
}
|
|
7386
7762
|
if (t === "circle") {
|
|
7387
|
-
if (
|
|
7763
|
+
if (ft.current) ft.current = null, Xt();
|
|
7388
7764
|
else {
|
|
7389
7765
|
U(null);
|
|
7390
7766
|
let e = L.current;
|
|
@@ -7393,22 +7769,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7393
7769
|
return;
|
|
7394
7770
|
}
|
|
7395
7771
|
if (t === "polygon") {
|
|
7396
|
-
let e =
|
|
7772
|
+
let e = pt.current;
|
|
7397
7773
|
if (e.length >= 3) {
|
|
7398
7774
|
let t = K.current, n = applyEntityConfig({
|
|
7399
7775
|
...t,
|
|
7400
|
-
id: t?.id ??
|
|
7776
|
+
id: t?.id ?? Bt(),
|
|
7401
7777
|
type: "polygon",
|
|
7402
7778
|
coordinates: [...e]
|
|
7403
7779
|
}, D);
|
|
7404
|
-
|
|
7780
|
+
en();
|
|
7405
7781
|
let r = L.current;
|
|
7406
7782
|
if (r && !R.current.has(n.id)) {
|
|
7407
7783
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7408
7784
|
R.current.set(n.id, e);
|
|
7409
7785
|
}
|
|
7410
|
-
Q.current.onPolygonAdd?.(n),
|
|
7411
|
-
} else if (e.length > 0)
|
|
7786
|
+
Q.current.onPolygonAdd?.(n), pt.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7787
|
+
} else if (e.length > 0) pt.current = [], en();
|
|
7412
7788
|
else {
|
|
7413
7789
|
U(null);
|
|
7414
7790
|
let e = L.current;
|
|
@@ -7417,7 +7793,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7417
7793
|
return;
|
|
7418
7794
|
}
|
|
7419
7795
|
if (t === "square") {
|
|
7420
|
-
if (
|
|
7796
|
+
if (ht.current) ht.current = null, on();
|
|
7421
7797
|
else {
|
|
7422
7798
|
U(null);
|
|
7423
7799
|
let e = L.current;
|
|
@@ -7426,22 +7802,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7426
7802
|
return;
|
|
7427
7803
|
}
|
|
7428
7804
|
if (t === "polyline") {
|
|
7429
|
-
let e =
|
|
7805
|
+
let e = _t.current;
|
|
7430
7806
|
if (e.length >= 2) {
|
|
7431
|
-
let t =
|
|
7807
|
+
let t = gt.current, n = applyEntityConfig({
|
|
7432
7808
|
...t,
|
|
7433
|
-
id: t?.id ??
|
|
7809
|
+
id: t?.id ?? Bt(),
|
|
7434
7810
|
type: "polyline",
|
|
7435
7811
|
coordinates: [...e]
|
|
7436
7812
|
}, D);
|
|
7437
|
-
|
|
7813
|
+
un();
|
|
7438
7814
|
let r = L.current;
|
|
7439
7815
|
if (r && !R.current.has(n.id)) {
|
|
7440
7816
|
let e = new PolylineRenderer(r, n, O, k, N);
|
|
7441
7817
|
R.current.set(n.id, e);
|
|
7442
7818
|
}
|
|
7443
|
-
Q.current.onPolylineAdd?.(n),
|
|
7444
|
-
} else if (e.length > 0)
|
|
7819
|
+
Q.current.onPolylineAdd?.(n), _t.current = [], gt.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7820
|
+
} else if (e.length > 0) _t.current = [], un();
|
|
7445
7821
|
else {
|
|
7446
7822
|
U(null);
|
|
7447
7823
|
let e = L.current;
|
|
@@ -7452,11 +7828,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7452
7828
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7453
7829
|
x: e.point.x,
|
|
7454
7830
|
y: e.point.y
|
|
7455
|
-
}, i =
|
|
7831
|
+
}, i = Fn.current, a = kn(e.originalEvent.target);
|
|
7456
7832
|
if (a) {
|
|
7457
7833
|
let e = i.find((e) => String(e.id) === a);
|
|
7458
7834
|
if (e) {
|
|
7459
|
-
|
|
7835
|
+
Nn(e, r, n);
|
|
7460
7836
|
return;
|
|
7461
7837
|
}
|
|
7462
7838
|
}
|
|
@@ -7465,7 +7841,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7465
7841
|
if (o && L.current?.getLayer(o) && L.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7466
7842
|
let e = i.find((e) => e.id === t);
|
|
7467
7843
|
if (e) {
|
|
7468
|
-
|
|
7844
|
+
Nn(e, r, n);
|
|
7469
7845
|
return;
|
|
7470
7846
|
}
|
|
7471
7847
|
}
|
|
@@ -7473,24 +7849,24 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7473
7849
|
for (let [e, t] of R.current) if (t.isPointInEntity(n)) {
|
|
7474
7850
|
let t = i.find((t) => t.id === e);
|
|
7475
7851
|
if (t) {
|
|
7476
|
-
|
|
7852
|
+
Nn(t, r, n);
|
|
7477
7853
|
return;
|
|
7478
7854
|
}
|
|
7479
7855
|
}
|
|
7480
7856
|
}, [
|
|
7481
|
-
|
|
7857
|
+
kn,
|
|
7482
7858
|
Y,
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
]),
|
|
7489
|
-
let r =
|
|
7859
|
+
Gt,
|
|
7860
|
+
Xt,
|
|
7861
|
+
en,
|
|
7862
|
+
on,
|
|
7863
|
+
un
|
|
7864
|
+
]), Nn = useCallback((e, t, n) => {
|
|
7865
|
+
let r = He.current?.getBoundingClientRect(), i = r ? {
|
|
7490
7866
|
x: t.x + r.left,
|
|
7491
7867
|
y: t.y + r.top
|
|
7492
7868
|
} : t;
|
|
7493
|
-
|
|
7869
|
+
Ze({
|
|
7494
7870
|
position: i,
|
|
7495
7871
|
lngLat: n,
|
|
7496
7872
|
items: [{
|
|
@@ -7510,8 +7886,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7510
7886
|
}
|
|
7511
7887
|
}]
|
|
7512
7888
|
});
|
|
7513
|
-
}, []),
|
|
7514
|
-
|
|
7889
|
+
}, []), Pn = useCallback(() => {
|
|
7890
|
+
Ze(null);
|
|
7515
7891
|
}, []);
|
|
7516
7892
|
useEffect(() => {
|
|
7517
7893
|
let e = document.createElement("div");
|
|
@@ -7523,7 +7899,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7523
7899
|
pointer-events: none;
|
|
7524
7900
|
height: 100%;
|
|
7525
7901
|
z-index: ${I?.zIndex ?? 1e3};
|
|
7526
|
-
`, document.body.appendChild(e),
|
|
7902
|
+
`, document.body.appendChild(e), qe.current = e, () => {
|
|
7527
7903
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7528
7904
|
};
|
|
7529
7905
|
}, [I?.zIndex]), useEffect(() => {
|
|
@@ -7536,61 +7912,61 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7536
7912
|
pointer-events: none;
|
|
7537
7913
|
height: 100%;
|
|
7538
7914
|
z-index: ${(I?.zIndex ?? 1e3) + 100};
|
|
7539
|
-
`, document.body.appendChild(e),
|
|
7915
|
+
`, document.body.appendChild(e), Qe.current = e, () => {
|
|
7540
7916
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7541
7917
|
};
|
|
7542
7918
|
}, [I?.zIndex]);
|
|
7543
|
-
let
|
|
7544
|
-
|
|
7545
|
-
let
|
|
7546
|
-
|
|
7547
|
-
let
|
|
7548
|
-
|
|
7549
|
-
let
|
|
7550
|
-
|
|
7551
|
-
let
|
|
7552
|
-
|
|
7553
|
-
let zn = useRef(at);
|
|
7554
|
-
zn.current = at;
|
|
7919
|
+
let Fn = useRef(T);
|
|
7920
|
+
Fn.current = T;
|
|
7921
|
+
let In = useRef(Le);
|
|
7922
|
+
In.current = Le;
|
|
7923
|
+
let Ln = useRef(Dt);
|
|
7924
|
+
Ln.current = Dt;
|
|
7925
|
+
let Rn = useRef(V);
|
|
7926
|
+
Rn.current = V;
|
|
7927
|
+
let zn = useRef(b);
|
|
7928
|
+
zn.current = b;
|
|
7555
7929
|
let Bn = useRef(ot);
|
|
7556
7930
|
Bn.current = ot;
|
|
7557
7931
|
let Vn = useRef(st);
|
|
7558
7932
|
Vn.current = st;
|
|
7933
|
+
let Hn = useRef(ct);
|
|
7934
|
+
Hn.current = ct;
|
|
7559
7935
|
let Q = useRef(v);
|
|
7560
7936
|
Q.current = v;
|
|
7561
|
-
let
|
|
7562
|
-
|
|
7937
|
+
let Un = useRef(D);
|
|
7938
|
+
Un.current = D, useEffect(() => {
|
|
7563
7939
|
let e = (e) => {
|
|
7564
7940
|
if (e.key === "Escape" && q.current) {
|
|
7565
7941
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7566
7942
|
return;
|
|
7567
7943
|
}
|
|
7568
7944
|
if (e.key === "Escape" && V === "edit") {
|
|
7569
|
-
if (
|
|
7945
|
+
if (ot && (H(null), U(null), Y()), st === "rectangle") if (ct) lt(null), Gt();
|
|
7570
7946
|
else {
|
|
7571
7947
|
U(null);
|
|
7572
7948
|
let e = L.current;
|
|
7573
7949
|
e && (e.getCanvas().style.cursor = "");
|
|
7574
7950
|
}
|
|
7575
|
-
if (
|
|
7951
|
+
if (st === "circle") if (ft.current) ft.current = null, Xt();
|
|
7576
7952
|
else {
|
|
7577
7953
|
U(null);
|
|
7578
7954
|
let e = L.current;
|
|
7579
7955
|
e && (e.getCanvas().style.cursor = "");
|
|
7580
7956
|
}
|
|
7581
|
-
if (
|
|
7957
|
+
if (st === "polygon") if (pt.current.length > 0) pt.current = [], en();
|
|
7582
7958
|
else {
|
|
7583
7959
|
U(null);
|
|
7584
7960
|
let e = L.current;
|
|
7585
7961
|
e && (e.getCanvas().style.cursor = "");
|
|
7586
7962
|
}
|
|
7587
|
-
if (
|
|
7963
|
+
if (st === "square") if (ht.current) ht.current = null, on();
|
|
7588
7964
|
else {
|
|
7589
7965
|
U(null);
|
|
7590
7966
|
let e = L.current;
|
|
7591
7967
|
e && (e.getCanvas().style.cursor = "");
|
|
7592
7968
|
}
|
|
7593
|
-
if (
|
|
7969
|
+
if (st === "polyline") if (_t.current.length > 0) _t.current = [], un();
|
|
7594
7970
|
else {
|
|
7595
7971
|
U(null);
|
|
7596
7972
|
let e = L.current;
|
|
@@ -7603,55 +7979,55 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7603
7979
|
};
|
|
7604
7980
|
}, [
|
|
7605
7981
|
V,
|
|
7606
|
-
at,
|
|
7607
7982
|
ot,
|
|
7608
7983
|
st,
|
|
7984
|
+
ct,
|
|
7609
7985
|
Y,
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7986
|
+
Gt,
|
|
7987
|
+
Xt,
|
|
7988
|
+
en,
|
|
7989
|
+
on,
|
|
7990
|
+
un
|
|
7615
7991
|
]), useEffect(() => {
|
|
7616
7992
|
let e = L.current;
|
|
7617
7993
|
if (!e || !B) return;
|
|
7618
7994
|
let t = B.entityId, n = B.config, r = () => {
|
|
7619
|
-
let r =
|
|
7995
|
+
let r = Fn.current.find((e) => e.id === t);
|
|
7620
7996
|
if (!r) {
|
|
7621
|
-
|
|
7997
|
+
kt();
|
|
7622
7998
|
return;
|
|
7623
7999
|
}
|
|
7624
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7625
|
-
|
|
8000
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Je.current);
|
|
8001
|
+
Je.current && (Je.current.style.left = `${i.x}px`, Je.current.style.top = `${i.y}px`);
|
|
7626
8002
|
}, i = setTimeout(() => {
|
|
7627
8003
|
r();
|
|
7628
8004
|
}, 50);
|
|
7629
8005
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7630
8006
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7631
8007
|
};
|
|
7632
|
-
}, [B?.entityId,
|
|
7633
|
-
let e = L.current, t =
|
|
7634
|
-
if (!e || !
|
|
7635
|
-
let n =
|
|
8008
|
+
}, [B?.entityId, kt]), useEffect(() => {
|
|
8009
|
+
let e = L.current, t = He.current;
|
|
8010
|
+
if (!e || !Xe || !t) return;
|
|
8011
|
+
let n = Xe.lngLat, r = () => {
|
|
7636
8012
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7637
8013
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7638
|
-
|
|
8014
|
+
Pn();
|
|
7639
8015
|
return;
|
|
7640
8016
|
}
|
|
7641
8017
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7642
|
-
|
|
8018
|
+
$e.current && ($e.current.style.left = `${s}px`, $e.current.style.top = `${c}px`);
|
|
7643
8019
|
};
|
|
7644
8020
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7645
8021
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7646
8022
|
};
|
|
7647
|
-
}, [
|
|
7648
|
-
if (!
|
|
8023
|
+
}, [Xe?.lngLat, Pn]), useEffect(() => {
|
|
8024
|
+
if (!He.current) return;
|
|
7649
8025
|
let e = {
|
|
7650
8026
|
version: 8,
|
|
7651
8027
|
sources: {},
|
|
7652
8028
|
layers: []
|
|
7653
8029
|
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: m = !0, boxZoom: h = !0 } = x, _ = new mapboxgl.Map({
|
|
7654
|
-
container:
|
|
8030
|
+
container: He.current,
|
|
7655
8031
|
style: p || e,
|
|
7656
8032
|
center: l,
|
|
7657
8033
|
zoom: u,
|
|
@@ -7685,9 +8061,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7685
8061
|
}
|
|
7686
8062
|
z.current.clear(), T.forEach((e) => {
|
|
7687
8063
|
z.current.set(e.id, e);
|
|
7688
|
-
}),
|
|
7689
|
-
}), _.on("click",
|
|
7690
|
-
_.off("click",
|
|
8064
|
+
}), On(S), bn(), Ut(), Kt(), Qt(), nn(), cn(), tt(_), Ie?.(_);
|
|
8065
|
+
}), _.on("click", An), _.on("mousemove", jn), _.on("contextmenu", Mn), () => {
|
|
8066
|
+
_.off("click", An), _.off("mousemove", jn), _.off("contextmenu", Mn), xn(), zt(), Y(), X(), Z(), _.remove(), L.current = null;
|
|
7691
8067
|
};
|
|
7692
8068
|
}, []), useEffect(() => {
|
|
7693
8069
|
if (L.current) {
|
|
@@ -7695,53 +8071,53 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7695
8071
|
L.current.once("load", () => {
|
|
7696
8072
|
z.current.clear(), T.forEach((e) => {
|
|
7697
8073
|
z.current.set(e.id, e);
|
|
7698
|
-
}),
|
|
8074
|
+
}), bn();
|
|
7699
8075
|
});
|
|
7700
8076
|
return;
|
|
7701
8077
|
}
|
|
7702
8078
|
z.current.clear(), T.forEach((e) => {
|
|
7703
8079
|
z.current.set(e.id, e);
|
|
7704
|
-
}),
|
|
8080
|
+
}), bn();
|
|
7705
8081
|
}
|
|
7706
|
-
}, [T,
|
|
7707
|
-
!L.current || !L.current.isStyleLoaded() || (
|
|
8082
|
+
}, [T, bn]), useEffect(() => {
|
|
8083
|
+
!L.current || !L.current.isStyleLoaded() || (xn(), bn());
|
|
7708
8084
|
}, [
|
|
7709
8085
|
O,
|
|
7710
8086
|
k,
|
|
7711
8087
|
j,
|
|
7712
8088
|
M,
|
|
7713
8089
|
N,
|
|
7714
|
-
|
|
7715
|
-
|
|
8090
|
+
xn,
|
|
8091
|
+
bn
|
|
7716
8092
|
]), useEffect(() => {
|
|
7717
8093
|
if (L.current) {
|
|
7718
8094
|
if (!L.current.isStyleLoaded()) {
|
|
7719
8095
|
L.current.once("load", () => {
|
|
7720
|
-
|
|
8096
|
+
On(S);
|
|
7721
8097
|
});
|
|
7722
8098
|
return;
|
|
7723
8099
|
}
|
|
7724
|
-
|
|
7725
|
-
}
|
|
7726
|
-
}, [S,
|
|
7727
|
-
let
|
|
7728
|
-
|
|
7729
|
-
let
|
|
7730
|
-
|
|
7731
|
-
let
|
|
7732
|
-
|
|
7733
|
-
let
|
|
7734
|
-
|
|
7735
|
-
let
|
|
7736
|
-
|
|
7737
|
-
let
|
|
7738
|
-
|
|
7739
|
-
let
|
|
7740
|
-
|
|
7741
|
-
let
|
|
7742
|
-
|
|
7743
|
-
let
|
|
7744
|
-
|
|
8100
|
+
On(S);
|
|
8101
|
+
}
|
|
8102
|
+
}, [S, On]);
|
|
8103
|
+
let Wn = useRef(void 0), Gn = useRef(!0), Kn = useRef(S);
|
|
8104
|
+
Kn.current = S;
|
|
8105
|
+
let qn = useRef(On);
|
|
8106
|
+
qn.current = On;
|
|
8107
|
+
let Jn = useRef(xn);
|
|
8108
|
+
Jn.current = xn;
|
|
8109
|
+
let Yn = useRef(bn);
|
|
8110
|
+
Yn.current = bn;
|
|
8111
|
+
let Xn = useRef(Ut);
|
|
8112
|
+
Xn.current = Ut;
|
|
8113
|
+
let Zn = useRef(Kt);
|
|
8114
|
+
Zn.current = Kt;
|
|
8115
|
+
let Qn = useRef(Qt);
|
|
8116
|
+
Qn.current = Qt;
|
|
8117
|
+
let $n = useRef(nn);
|
|
8118
|
+
$n.current = nn;
|
|
8119
|
+
let er = useRef(cn);
|
|
8120
|
+
er.current = cn, useEffect(() => {
|
|
7745
8121
|
let e = L.current;
|
|
7746
8122
|
if (!e) return;
|
|
7747
8123
|
let t = p || {
|
|
@@ -7749,27 +8125,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7749
8125
|
sources: {},
|
|
7750
8126
|
layers: []
|
|
7751
8127
|
};
|
|
7752
|
-
if (
|
|
7753
|
-
|
|
8128
|
+
if (Gn.current) {
|
|
8129
|
+
Gn.current = !1, Wn.current = p;
|
|
7754
8130
|
return;
|
|
7755
8131
|
}
|
|
7756
|
-
|
|
8132
|
+
Wn.current !== p && (Wn.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7757
8133
|
if (!e.getStyle().glyphs) {
|
|
7758
8134
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7759
8135
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7760
8136
|
}
|
|
7761
|
-
|
|
8137
|
+
Ge.current.clear(), qn.current(Kn.current), Jn.current(), Yn.current(), Xn.current(), Zn.current(), Qn.current(), $n.current(), er.current();
|
|
7762
8138
|
}));
|
|
7763
8139
|
}, [p]), useEffect(() => {
|
|
7764
8140
|
let e = new Set(E.map(String));
|
|
7765
8141
|
for (let [t, n] of R.current) n.setSelected(e.has(String(t)));
|
|
7766
8142
|
}, [E]);
|
|
7767
|
-
let
|
|
8143
|
+
let tr = useRef({});
|
|
7768
8144
|
useEffect(() => {
|
|
7769
8145
|
let e = L.current;
|
|
7770
8146
|
if (!e) return;
|
|
7771
|
-
let t =
|
|
7772
|
-
!n && !r && !i && !a || (
|
|
8147
|
+
let t = tr.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;
|
|
8148
|
+
!n && !r && !i && !a || (tr.current = {
|
|
7773
8149
|
center: l,
|
|
7774
8150
|
zoom: u,
|
|
7775
8151
|
pitch: d,
|
|
@@ -7786,8 +8162,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7786
8162
|
d,
|
|
7787
8163
|
f
|
|
7788
8164
|
]);
|
|
7789
|
-
let
|
|
7790
|
-
if (
|
|
8165
|
+
let nr = (() => we === !1 ? null : we === !0 ? { enabled: !0 } : we)(), rr = (() => P === !1 ? null : P === !0 ? { enabled: !0 } : P)(), ir = (() => Te === !1 ? null : Te === !0 ? { enabled: !0 } : Te)(), $ = (() => {
|
|
8166
|
+
if (Ee === !1) return null;
|
|
7791
8167
|
let e, t, n;
|
|
7792
8168
|
if (S && S.length > 0) {
|
|
7793
8169
|
let r = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
@@ -7800,18 +8176,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7800
8176
|
} else e = `base-layer-source-${r.id}`;
|
|
7801
8177
|
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7802
8178
|
}
|
|
7803
|
-
return
|
|
8179
|
+
return Ee === !0 ? {
|
|
7804
8180
|
enabled: !0,
|
|
7805
8181
|
source: e,
|
|
7806
8182
|
sourceLayer: t,
|
|
7807
8183
|
classField: n
|
|
7808
8184
|
} : {
|
|
7809
|
-
...
|
|
7810
|
-
source:
|
|
7811
|
-
sourceLayer:
|
|
7812
|
-
classField:
|
|
8185
|
+
...Ee,
|
|
8186
|
+
source: Ee.source || e,
|
|
8187
|
+
sourceLayer: Ee.sourceLayer || t,
|
|
8188
|
+
classField: Ee.classField || n
|
|
7813
8189
|
};
|
|
7814
|
-
})(),
|
|
8190
|
+
})(), ar = (() => F ? F === !0 ? { enabled: !0 } : F : null)(), or = (() => Oe ? Oe === !0 ? { enabled: !0 } : Oe : null)(), sr = (() => Me || null)(), cr = useMemo(() => {
|
|
7815
8191
|
let e = [];
|
|
7816
8192
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7817
8193
|
let n = L.current;
|
|
@@ -7821,7 +8197,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7821
8197
|
}
|
|
7822
8198
|
} else e.push(`base-layer-${t.id}`);
|
|
7823
8199
|
return e;
|
|
7824
|
-
}, [S,
|
|
8200
|
+
}, [S, et]), lr = useMemo(() => {
|
|
7825
8201
|
if (V !== "picker") return;
|
|
7826
8202
|
let e = J.cursorImage;
|
|
7827
8203
|
if (!e) return;
|
|
@@ -7856,16 +8232,16 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7856
8232
|
break;
|
|
7857
8233
|
}
|
|
7858
8234
|
return `url(${e.url}) ${i} ${a}, crosshair`;
|
|
7859
|
-
}, [V, J.cursorImage]),
|
|
7860
|
-
...
|
|
7861
|
-
"--mapbox-picker-cursor":
|
|
7862
|
-
} :
|
|
8235
|
+
}, [V, J.cursorImage]), ur = useMemo(() => lr ? {
|
|
8236
|
+
...Ve,
|
|
8237
|
+
"--mapbox-picker-cursor": lr
|
|
8238
|
+
} : Ve, [Ve, lr]);
|
|
7863
8239
|
return /* @__PURE__ */ jsxs("div", {
|
|
7864
|
-
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${
|
|
7865
|
-
style:
|
|
8240
|
+
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${Be}`,
|
|
8241
|
+
style: ur,
|
|
7866
8242
|
children: [
|
|
7867
8243
|
/* @__PURE__ */ jsx("div", {
|
|
7868
|
-
ref:
|
|
8244
|
+
ref: He,
|
|
7869
8245
|
className: "comp-mapbox__map"
|
|
7870
8246
|
}),
|
|
7871
8247
|
V === "picker" && J.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
@@ -7879,14 +8255,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7879
8255
|
})]
|
|
7880
8256
|
}),
|
|
7881
8257
|
/* @__PURE__ */ jsxs("div", {
|
|
7882
|
-
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ||
|
|
8258
|
+
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || sr && sr.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
|
|
7883
8259
|
children: [
|
|
7884
8260
|
V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7885
8261
|
markerTemplates: v.markerTemplates || [],
|
|
7886
|
-
selectedTemplate:
|
|
7887
|
-
onTemplateSelect:
|
|
7888
|
-
drawMode:
|
|
7889
|
-
onDrawModeChange:
|
|
8262
|
+
selectedTemplate: ot,
|
|
8263
|
+
onTemplateSelect: dn,
|
|
8264
|
+
drawMode: st,
|
|
8265
|
+
onDrawModeChange: fn,
|
|
7890
8266
|
showRectangleTool: v.showRectangleTool,
|
|
7891
8267
|
showCircleTool: v.showCircleTool,
|
|
7892
8268
|
showPolygonTool: v.showPolygonTool,
|
|
@@ -7894,8 +8270,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7894
8270
|
showPolylineTool: v.showPolylineTool
|
|
7895
8271
|
}),
|
|
7896
8272
|
/* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7897
|
-
ref:
|
|
7898
|
-
map:
|
|
8273
|
+
ref: We,
|
|
8274
|
+
map: et,
|
|
7899
8275
|
showButton: !!($ && $.enabled !== !1),
|
|
7900
8276
|
highlightWidth: $?.highlightWidth,
|
|
7901
8277
|
defaultRoadTypes: $?.defaultRoadTypes,
|
|
@@ -7906,80 +8282,80 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7906
8282
|
className: $?.className,
|
|
7907
8283
|
style: $?.style
|
|
7908
8284
|
}),
|
|
7909
|
-
|
|
7910
|
-
ref:
|
|
7911
|
-
map:
|
|
7912
|
-
pointCount:
|
|
7913
|
-
showPointCountInput:
|
|
7914
|
-
visualType:
|
|
7915
|
-
onSelectFinished:
|
|
8285
|
+
sr && sr.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
8286
|
+
ref: Ue,
|
|
8287
|
+
map: et,
|
|
8288
|
+
pointCount: sr.pointCount,
|
|
8289
|
+
showPointCountInput: sr.showPointCountInput,
|
|
8290
|
+
visualType: sr.visualType,
|
|
8291
|
+
onSelectFinished: sr.onSelectFinished
|
|
7916
8292
|
})
|
|
7917
8293
|
]
|
|
7918
8294
|
}),
|
|
7919
|
-
(
|
|
8295
|
+
(nr?.enabled !== !1 || rr?.enabled !== !1 || ir?.enabled !== !1 || ar && ar.enabled !== !1 || or && or.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7920
8296
|
className: "comp-mapbox__controls",
|
|
7921
8297
|
children: [
|
|
7922
|
-
|
|
7923
|
-
map:
|
|
7924
|
-
precision:
|
|
7925
|
-
className: tr.className,
|
|
7926
|
-
style: tr.style
|
|
7927
|
-
}),
|
|
7928
|
-
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7929
|
-
map: $e,
|
|
7930
|
-
maxWidth: nr.maxWidth,
|
|
7931
|
-
unit: nr.unit,
|
|
8298
|
+
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
8299
|
+
map: et,
|
|
8300
|
+
precision: nr.precision,
|
|
7932
8301
|
className: nr.className,
|
|
7933
8302
|
style: nr.style
|
|
7934
8303
|
}),
|
|
7935
|
-
|
|
7936
|
-
map:
|
|
8304
|
+
rr && rr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
8305
|
+
map: et,
|
|
8306
|
+
maxWidth: rr.maxWidth,
|
|
8307
|
+
unit: rr.unit,
|
|
8308
|
+
className: rr.className,
|
|
8309
|
+
style: rr.style
|
|
8310
|
+
}),
|
|
8311
|
+
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
8312
|
+
map: et,
|
|
7937
8313
|
entityConfig: D,
|
|
7938
8314
|
onDrawModeChange: (e) => {
|
|
7939
|
-
|
|
8315
|
+
yt.current = e;
|
|
7940
8316
|
},
|
|
7941
|
-
className: ir.className,
|
|
7942
|
-
style: ir.style
|
|
7943
|
-
}),
|
|
7944
|
-
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7945
|
-
map: $e,
|
|
7946
|
-
value: C,
|
|
7947
|
-
onChange: Me,
|
|
7948
|
-
rasterPaintLayerIds: sr,
|
|
7949
8317
|
className: ar.className,
|
|
7950
8318
|
style: ar.style
|
|
7951
8319
|
}),
|
|
7952
|
-
|
|
7953
|
-
map:
|
|
8320
|
+
or && or.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
8321
|
+
map: et,
|
|
8322
|
+
value: C,
|
|
8323
|
+
onChange: Ne,
|
|
8324
|
+
rasterPaintLayerIds: cr,
|
|
8325
|
+
className: or.className,
|
|
8326
|
+
style: or.style
|
|
8327
|
+
}),
|
|
8328
|
+
ir && ir.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
8329
|
+
map: et,
|
|
7954
8330
|
initialCenter: l,
|
|
7955
8331
|
initialZoom: u,
|
|
7956
8332
|
initialPitch: d,
|
|
7957
8333
|
initialBearing: f,
|
|
7958
|
-
duration:
|
|
7959
|
-
className:
|
|
7960
|
-
style:
|
|
8334
|
+
duration: ir.duration,
|
|
8335
|
+
className: ir.className,
|
|
8336
|
+
style: ir.style
|
|
7961
8337
|
})
|
|
7962
8338
|
]
|
|
7963
8339
|
}),
|
|
7964
|
-
!(
|
|
7965
|
-
ref:
|
|
7966
|
-
map:
|
|
8340
|
+
!(sr && sr.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
8341
|
+
ref: Ue,
|
|
8342
|
+
map: et,
|
|
7967
8343
|
showButton: !1
|
|
7968
8344
|
}),
|
|
7969
|
-
B &&
|
|
8345
|
+
B && qe.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7970
8346
|
popupState: B,
|
|
7971
|
-
onClose: () =>
|
|
7972
|
-
portalContainer:
|
|
7973
|
-
popupRef:
|
|
8347
|
+
onClose: () => Ot(B.entityId),
|
|
8348
|
+
portalContainer: qe.current,
|
|
8349
|
+
popupRef: Je
|
|
7974
8350
|
}),
|
|
7975
|
-
|
|
7976
|
-
menuState:
|
|
7977
|
-
onClose:
|
|
7978
|
-
portalContainer:
|
|
7979
|
-
menuRef:
|
|
8351
|
+
Xe && Qe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
8352
|
+
menuState: Xe,
|
|
8353
|
+
onClose: Pn,
|
|
8354
|
+
portalContainer: Qe.current,
|
|
8355
|
+
menuRef: $e
|
|
7980
8356
|
})
|
|
7981
8357
|
]
|
|
7982
8358
|
});
|
|
7983
8359
|
});
|
|
7984
8360
|
Mapbox.displayName = "Mapbox";
|
|
7985
|
-
export { BaseCanvasRenderer, COLOR_SCHEMES, CanvasCircleRenderer, CanvasImageRenderer, CanvasRadarRenderer, CircleRenderer, ContextMenu, CoordinateDisplay, DEFAULT_NAME_CONFIG, DEFAULT_SELECT_NAME_CONFIG, EditControl, EntityPopup, Mapbox, MarkerRenderer, POPUP_DEFAULTS, PolygonRenderer, PolylineRenderer, RADAR_DEFAULTS, ROAD_TYPE_OPTIONS, RectangleRenderer, ResetViewControl, RoadHighlightControl, ScaleControl, SquareRenderer, UnitRenderer, bearing, calculatePopupPosition, confidenceToOpacity, destinationPoint, distance, mergePopupConfig, resolveNameConfig };
|
|
8361
|
+
export { AttackDirectionRenderer, BaseCanvasRenderer, COLOR_SCHEMES, CanvasCircleRenderer, CanvasImageRenderer, CanvasRadarRenderer, CircleRenderer, ContextMenu, CoordinateDisplay, DEFAULT_NAME_CONFIG, DEFAULT_SELECT_NAME_CONFIG, EditControl, EntityPopup, Mapbox, MarkerRenderer, POPUP_DEFAULTS, PolygonRenderer, PolylineRenderer, RADAR_DEFAULTS, ROAD_TYPE_OPTIONS, RectangleRenderer, ResetViewControl, RoadHighlightControl, ScaleControl, SquareRenderer, UnitRenderer, bearing, calculatePopupPosition, confidenceToOpacity, destinationPoint, distance, mergePopupConfig, resolveNameConfig };
|