bbl-mapbox-react 0.0.30 → 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 +923 -533
- package/dist/types.d.ts +36 -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,76 +6387,88 @@ 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) => {
|
|
6420
|
+
if (e.length === 0) return null;
|
|
6421
|
+
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity, a = !1;
|
|
6422
|
+
for (let o of e) {
|
|
6423
|
+
let e = R.current.get(o);
|
|
6424
|
+
if (e) {
|
|
6425
|
+
let [[o, s], [c, l]] = e.getBounds();
|
|
6426
|
+
t = Math.min(t, o), n = Math.max(n, c), r = Math.min(r, s), i = Math.max(i, l), a = !0;
|
|
6427
|
+
}
|
|
6428
|
+
}
|
|
6429
|
+
return a ? [(t + n) / 2, (r + i) / 2] : null;
|
|
6430
|
+
}, []), Nt = useCallback((e, t, n) => {
|
|
6045
6431
|
let r = L.current;
|
|
6046
6432
|
if (!r || e.length === 0) return;
|
|
6047
|
-
let i =
|
|
6433
|
+
let i = Mt(e);
|
|
6434
|
+
if (!i) return;
|
|
6435
|
+
let a = [];
|
|
6048
6436
|
for (let t of e) {
|
|
6049
6437
|
let e = R.current.get(t);
|
|
6050
|
-
e &&
|
|
6438
|
+
e && a.push(e.getBounds());
|
|
6051
6439
|
}
|
|
6052
|
-
|
|
6053
|
-
let
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
if (i.length === 1 || d) {
|
|
6440
|
+
let o = Infinity, s = -Infinity, c = Infinity, l = -Infinity;
|
|
6441
|
+
for (let [[e, t], [n, r]] of a) o = Math.min(o, e), s = Math.max(s, n), c = Math.min(c, t), l = Math.max(l, r);
|
|
6442
|
+
let u = o === s && c === l;
|
|
6443
|
+
if (a.length === 1 || u) {
|
|
6057
6444
|
let e = {
|
|
6058
|
-
center:
|
|
6445
|
+
center: i,
|
|
6059
6446
|
zoom: t ?? r.getZoom()
|
|
6060
6447
|
};
|
|
6061
6448
|
n?.duration !== void 0 && (e.duration = n.duration), n?.pitch !== void 0 && (e.pitch = n.pitch), n?.bearing !== void 0 && (e.bearing = n.bearing), n?.essential !== void 0 && (e.essential = n.essential), r.flyTo(e);
|
|
6062
6449
|
return;
|
|
6063
6450
|
}
|
|
6064
|
-
let
|
|
6451
|
+
let d = [[o, c], [s, l]], f = {
|
|
6065
6452
|
padding: n?.padding ?? 50,
|
|
6066
6453
|
duration: n?.duration ?? 1e3,
|
|
6067
6454
|
bearing: n?.bearing ?? r.getBearing(),
|
|
6068
6455
|
pitch: n?.pitch ?? r.getPitch()
|
|
6069
6456
|
};
|
|
6070
|
-
t !== void 0 && (
|
|
6071
|
-
}, []),
|
|
6457
|
+
t !== void 0 && (f.maxZoom = t), n?.essential !== void 0 && (f.essential = n.essential), r.fitBounds(d, f);
|
|
6458
|
+
}, [Mt]), Pt = useRef(null), Ft = useRef("display"), [It, Lt] = useState({}), J = useMemo(() => ({
|
|
6072
6459
|
...y,
|
|
6073
|
-
...
|
|
6074
|
-
}), [y,
|
|
6460
|
+
...It
|
|
6461
|
+
}), [y, It]), Rt = useCallback((e) => {
|
|
6075
6462
|
let t = L.current;
|
|
6076
6463
|
if (!t || !t.getContainer()) return;
|
|
6077
6464
|
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = J;
|
|
6078
6465
|
if (!n) {
|
|
6079
|
-
|
|
6466
|
+
at.current &&= (at.current.remove(), null);
|
|
6080
6467
|
return;
|
|
6081
6468
|
}
|
|
6082
|
-
if (
|
|
6083
|
-
|
|
6084
|
-
let t =
|
|
6469
|
+
if (at.current) {
|
|
6470
|
+
at.current.setLngLat(e);
|
|
6471
|
+
let t = at.current.getElement(), n = t.querySelector(".marker-label");
|
|
6085
6472
|
if (i) {
|
|
6086
6473
|
let e = resolveNameConfig(a, O);
|
|
6087
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`;
|
|
@@ -6098,38 +6485,38 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6098
6485
|
let e = resolveNameConfig(a, O), t = document.createElement("div");
|
|
6099
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);
|
|
6100
6487
|
}
|
|
6101
|
-
|
|
6488
|
+
at.current = new mapboxgl.Marker({
|
|
6102
6489
|
element: n,
|
|
6103
6490
|
anchor: "bottom"
|
|
6104
6491
|
}).setLngLat(e).addTo(t);
|
|
6105
6492
|
}
|
|
6106
|
-
}, [J, O]),
|
|
6107
|
-
|
|
6108
|
-
}, []),
|
|
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) => {
|
|
6109
6496
|
let t = L.current;
|
|
6110
|
-
if (
|
|
6497
|
+
if (He.current) if (vt.current &&= (vt.current.remove(), null), e && t) {
|
|
6111
6498
|
t.getCanvas().style.cursor = "none";
|
|
6112
6499
|
let n = document.createElement("div");
|
|
6113
6500
|
n.className = "mapbox-custom-cursor";
|
|
6114
6501
|
let r = e.size || e.width || 32;
|
|
6115
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 ";
|
|
6116
6503
|
let i = document.createElement("img");
|
|
6117
|
-
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n),
|
|
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;
|
|
6118
6505
|
let a = (e) => {
|
|
6119
|
-
|
|
6506
|
+
vt.current && (vt.current.style.left = `${e.clientX}px`, vt.current.style.top = `${e.clientY}px`);
|
|
6120
6507
|
};
|
|
6121
6508
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
6122
6509
|
document.removeEventListener("mousemove", a);
|
|
6123
6510
|
};
|
|
6124
6511
|
} else t && (t.getCanvas().style.cursor = "");
|
|
6125
6512
|
}, []), Y = useCallback(() => {
|
|
6126
|
-
if (
|
|
6127
|
-
let e =
|
|
6128
|
-
e && e(),
|
|
6513
|
+
if (vt.current) {
|
|
6514
|
+
let e = vt.current._cleanup;
|
|
6515
|
+
e && e(), vt.current.remove(), vt.current = null;
|
|
6129
6516
|
}
|
|
6130
6517
|
let e = L.current;
|
|
6131
6518
|
e && (e.getCanvas().style.cursor = "");
|
|
6132
|
-
}, []),
|
|
6519
|
+
}, []), Ht = useCallback((e, t, n) => {
|
|
6133
6520
|
if (!e.getSource(t)) {
|
|
6134
6521
|
if (!e.getStyle().glyphs) {
|
|
6135
6522
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -6165,7 +6552,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6165
6552
|
}
|
|
6166
6553
|
});
|
|
6167
6554
|
}
|
|
6168
|
-
}, []),
|
|
6555
|
+
}, []), Ut = useCallback(() => {
|
|
6169
6556
|
let e = L.current;
|
|
6170
6557
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6171
6558
|
type: "geojson",
|
|
@@ -6190,8 +6577,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6190
6577
|
"line-width": 2,
|
|
6191
6578
|
"line-dasharray": [4, 4]
|
|
6192
6579
|
}
|
|
6193
|
-
}),
|
|
6194
|
-
}, [
|
|
6580
|
+
}), Ht(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6581
|
+
}, [Ht]), Wt = useCallback((e, t) => {
|
|
6195
6582
|
let n = L.current;
|
|
6196
6583
|
if (!n) return;
|
|
6197
6584
|
let r = n.getSource("rect-preview-source");
|
|
@@ -6211,11 +6598,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6211
6598
|
},
|
|
6212
6599
|
properties: {}
|
|
6213
6600
|
});
|
|
6214
|
-
let l =
|
|
6601
|
+
let l = ut.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6215
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));
|
|
6216
6603
|
let m = n.getSource("rect-preview-measure-source");
|
|
6217
6604
|
if (m) {
|
|
6218
|
-
let e =
|
|
6605
|
+
let e = Un.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6219
6606
|
if (e?.showArea) {
|
|
6220
6607
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6221
6608
|
t.push({
|
|
@@ -6252,7 +6639,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6252
6639
|
features: t
|
|
6253
6640
|
});
|
|
6254
6641
|
}
|
|
6255
|
-
}, []),
|
|
6642
|
+
}, []), Gt = useCallback(() => {
|
|
6256
6643
|
let e = L.current;
|
|
6257
6644
|
if (!e) return;
|
|
6258
6645
|
let t = e.getSource("rect-preview-source");
|
|
@@ -6266,8 +6653,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6266
6653
|
features: []
|
|
6267
6654
|
});
|
|
6268
6655
|
}, []), X = useCallback(() => {
|
|
6269
|
-
|
|
6270
|
-
}, [
|
|
6656
|
+
lt(null), Gt();
|
|
6657
|
+
}, [Gt]), Kt = useCallback(() => {
|
|
6271
6658
|
let e = L.current;
|
|
6272
6659
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6273
6660
|
type: "geojson",
|
|
@@ -6292,7 +6679,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6292
6679
|
"line-width": 2,
|
|
6293
6680
|
"line-dasharray": [4, 4]
|
|
6294
6681
|
}
|
|
6295
|
-
}),
|
|
6682
|
+
}), Ht(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
6296
6683
|
type: "geojson",
|
|
6297
6684
|
data: {
|
|
6298
6685
|
type: "FeatureCollection",
|
|
@@ -6309,22 +6696,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6309
6696
|
"line-dasharray": [4, 4]
|
|
6310
6697
|
}
|
|
6311
6698
|
}))));
|
|
6312
|
-
}, [
|
|
6699
|
+
}, [Ht]), qt = useCallback((e, t, n = 64) => {
|
|
6313
6700
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
6314
6701
|
for (let e = 0; e <= n; e++) {
|
|
6315
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;
|
|
6316
6703
|
a.push([d, u]);
|
|
6317
6704
|
}
|
|
6318
6705
|
return a;
|
|
6319
|
-
}, []),
|
|
6706
|
+
}, []), Jt = useCallback((e, t) => {
|
|
6320
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);
|
|
6321
6708
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6322
|
-
}, []),
|
|
6709
|
+
}, []), Yt = useCallback((e, t) => {
|
|
6323
6710
|
let n = L.current;
|
|
6324
6711
|
if (!n) return;
|
|
6325
6712
|
let r = n.getSource("circle-preview-source");
|
|
6326
6713
|
if (!r) return;
|
|
6327
|
-
let i =
|
|
6714
|
+
let i = Jt(e, t), a = qt(e, i);
|
|
6328
6715
|
r.setData({
|
|
6329
6716
|
type: "Feature",
|
|
6330
6717
|
geometry: {
|
|
@@ -6335,7 +6722,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6335
6722
|
});
|
|
6336
6723
|
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6337
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));
|
|
6338
|
-
let d =
|
|
6725
|
+
let d = Un.current, f = [], p = [];
|
|
6339
6726
|
if (d?.showArea) {
|
|
6340
6727
|
let t = Math.PI * i * i;
|
|
6341
6728
|
f.push({
|
|
@@ -6375,7 +6762,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6375
6762
|
type: "FeatureCollection",
|
|
6376
6763
|
features: p
|
|
6377
6764
|
});
|
|
6378
|
-
}, [
|
|
6765
|
+
}, [Jt, qt]), Xt = useCallback(() => {
|
|
6379
6766
|
let e = L.current;
|
|
6380
6767
|
if (!e) return;
|
|
6381
6768
|
let t = e.getSource("circle-preview-source");
|
|
@@ -6393,9 +6780,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6393
6780
|
type: "FeatureCollection",
|
|
6394
6781
|
features: []
|
|
6395
6782
|
});
|
|
6396
|
-
}, []),
|
|
6397
|
-
|
|
6398
|
-
}, [
|
|
6783
|
+
}, []), Zt = useCallback(() => {
|
|
6784
|
+
ft.current = null, Xt();
|
|
6785
|
+
}, [Xt]), Qt = useCallback(() => {
|
|
6399
6786
|
let e = L.current;
|
|
6400
6787
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6401
6788
|
type: "geojson",
|
|
@@ -6436,8 +6823,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6436
6823
|
"circle-stroke-color": "#ffffff",
|
|
6437
6824
|
"circle-stroke-width": 2
|
|
6438
6825
|
}
|
|
6439
|
-
}),
|
|
6440
|
-
}, [
|
|
6826
|
+
}), Ht(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6827
|
+
}, [Ht]), $t = useCallback((e, t) => {
|
|
6441
6828
|
let n = L.current;
|
|
6442
6829
|
if (!n) return;
|
|
6443
6830
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
@@ -6479,7 +6866,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6479
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);
|
|
6480
6867
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6481
6868
|
if (d) {
|
|
6482
|
-
let e =
|
|
6869
|
+
let e = Un.current, t = [];
|
|
6483
6870
|
if (e?.showArea && a.length >= 3) {
|
|
6484
6871
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6485
6872
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6521,7 +6908,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6521
6908
|
features: t
|
|
6522
6909
|
});
|
|
6523
6910
|
}
|
|
6524
|
-
}, []),
|
|
6911
|
+
}, []), en = useCallback(() => {
|
|
6525
6912
|
let e = L.current;
|
|
6526
6913
|
if (!e) return;
|
|
6527
6914
|
let t = e.getSource("polygon-preview-source");
|
|
@@ -6539,9 +6926,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6539
6926
|
type: "FeatureCollection",
|
|
6540
6927
|
features: []
|
|
6541
6928
|
});
|
|
6542
|
-
}, []),
|
|
6543
|
-
|
|
6544
|
-
}, [
|
|
6929
|
+
}, []), tn = useCallback(() => {
|
|
6930
|
+
pt.current = [], en();
|
|
6931
|
+
}, [en]), nn = useCallback(() => {
|
|
6545
6932
|
let e = L.current;
|
|
6546
6933
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6547
6934
|
type: "geojson",
|
|
@@ -6566,8 +6953,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6566
6953
|
"line-width": 2,
|
|
6567
6954
|
"line-dasharray": [4, 4]
|
|
6568
6955
|
}
|
|
6569
|
-
}),
|
|
6570
|
-
}, [
|
|
6956
|
+
}), Ht(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6957
|
+
}, [Ht]), rn = useCallback((e, t) => {
|
|
6571
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);
|
|
6572
6959
|
return [
|
|
6573
6960
|
[n - s, r + o],
|
|
@@ -6576,12 +6963,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6576
6963
|
[n - s, r - o],
|
|
6577
6964
|
[n - s, r + o]
|
|
6578
6965
|
];
|
|
6579
|
-
}, []),
|
|
6966
|
+
}, []), an = useCallback((e, t) => {
|
|
6580
6967
|
let n = L.current;
|
|
6581
6968
|
if (!n) return;
|
|
6582
6969
|
let r = n.getSource("square-preview-source");
|
|
6583
6970
|
if (!r) return;
|
|
6584
|
-
let i =
|
|
6971
|
+
let i = Jt(e, t) * 2, a = rn(e, i);
|
|
6585
6972
|
r.setData({
|
|
6586
6973
|
type: "Feature",
|
|
6587
6974
|
geometry: {
|
|
@@ -6590,11 +6977,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6590
6977
|
},
|
|
6591
6978
|
properties: {}
|
|
6592
6979
|
});
|
|
6593
|
-
let o =
|
|
6980
|
+
let o = mt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6594
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));
|
|
6595
6982
|
let d = n.getSource("square-preview-measure-source");
|
|
6596
6983
|
if (d) {
|
|
6597
|
-
let t =
|
|
6984
|
+
let t = Un.current, n = [];
|
|
6598
6985
|
if (t?.showArea && n.push({
|
|
6599
6986
|
type: "Feature",
|
|
6600
6987
|
geometry: {
|
|
@@ -6618,7 +7005,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6618
7005
|
features: n
|
|
6619
7006
|
});
|
|
6620
7007
|
}
|
|
6621
|
-
}, [
|
|
7008
|
+
}, [Jt, rn]), on = useCallback(() => {
|
|
6622
7009
|
let e = L.current;
|
|
6623
7010
|
if (!e) return;
|
|
6624
7011
|
let t = e.getSource("square-preview-source");
|
|
@@ -6631,9 +7018,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6631
7018
|
type: "FeatureCollection",
|
|
6632
7019
|
features: []
|
|
6633
7020
|
});
|
|
6634
|
-
}, []),
|
|
6635
|
-
|
|
6636
|
-
}, [
|
|
7021
|
+
}, []), sn = useCallback(() => {
|
|
7022
|
+
ht.current = null, on();
|
|
7023
|
+
}, [on]), cn = useCallback(() => {
|
|
6637
7024
|
let e = L.current;
|
|
6638
7025
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6639
7026
|
type: "geojson",
|
|
@@ -6666,8 +7053,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6666
7053
|
"circle-stroke-color": "#ffffff",
|
|
6667
7054
|
"circle-stroke-width": 2
|
|
6668
7055
|
}
|
|
6669
|
-
}),
|
|
6670
|
-
}, [
|
|
7056
|
+
}), Ht(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
7057
|
+
}, [Ht]), ln = useCallback((e, t) => {
|
|
6671
7058
|
let n = L.current;
|
|
6672
7059
|
if (!n) return;
|
|
6673
7060
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
@@ -6694,11 +7081,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6694
7081
|
properties: {}
|
|
6695
7082
|
}))
|
|
6696
7083
|
});
|
|
6697
|
-
let o =
|
|
7084
|
+
let o = gt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
6698
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);
|
|
6699
7086
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6700
7087
|
if (l) {
|
|
6701
|
-
let e =
|
|
7088
|
+
let e = Un.current, t = [];
|
|
6702
7089
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6703
7090
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6704
7091
|
t.push({
|
|
@@ -6715,7 +7102,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6715
7102
|
features: t
|
|
6716
7103
|
});
|
|
6717
7104
|
}
|
|
6718
|
-
}, []),
|
|
7105
|
+
}, []), un = useCallback(() => {
|
|
6719
7106
|
let e = L.current;
|
|
6720
7107
|
if (!e) return;
|
|
6721
7108
|
let t = e.getSource("polyline-preview-source");
|
|
@@ -6734,156 +7121,158 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6734
7121
|
features: []
|
|
6735
7122
|
});
|
|
6736
7123
|
}, []), Z = useCallback(() => {
|
|
6737
|
-
|
|
6738
|
-
}, [
|
|
6739
|
-
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);
|
|
6740
7127
|
}, [
|
|
6741
|
-
|
|
7128
|
+
Vt,
|
|
6742
7129
|
X,
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
7130
|
+
Zt,
|
|
7131
|
+
tn,
|
|
7132
|
+
sn,
|
|
6746
7133
|
Z
|
|
6747
|
-
]),
|
|
7134
|
+
]), fn = useCallback((e) => {
|
|
6748
7135
|
if (U(e), e === "rectangle") {
|
|
6749
|
-
H(null), Y(),
|
|
7136
|
+
H(null), Y(), Zt(), tn(), sn(), Z();
|
|
6750
7137
|
let e = L.current;
|
|
6751
7138
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6752
7139
|
} else if (e === "circle") {
|
|
6753
|
-
H(null), Y(), X(),
|
|
7140
|
+
H(null), Y(), X(), tn(), sn(), Z();
|
|
6754
7141
|
let e = L.current;
|
|
6755
7142
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6756
7143
|
} else if (e === "polygon") {
|
|
6757
|
-
H(null), Y(), X(),
|
|
7144
|
+
H(null), Y(), X(), Zt(), sn(), Z();
|
|
6758
7145
|
let e = L.current;
|
|
6759
7146
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6760
7147
|
} else if (e === "square") {
|
|
6761
|
-
H(null), Y(), X(),
|
|
7148
|
+
H(null), Y(), X(), Zt(), tn(), Z();
|
|
6762
7149
|
let e = L.current;
|
|
6763
7150
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6764
7151
|
} else if (e === "polyline") {
|
|
6765
|
-
H(null), Y(), X(),
|
|
7152
|
+
H(null), Y(), X(), Zt(), tn(), sn();
|
|
6766
7153
|
let e = L.current;
|
|
6767
7154
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6768
|
-
} else e === "marker" ? (X(),
|
|
7155
|
+
} else e === "marker" ? (X(), Zt(), tn(), sn(), Z()) : (H(null), Y(), X(), Zt(), tn(), sn(), Z());
|
|
6769
7156
|
}, [
|
|
6770
7157
|
Y,
|
|
6771
7158
|
X,
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
7159
|
+
Zt,
|
|
7160
|
+
tn,
|
|
7161
|
+
sn,
|
|
6775
7162
|
Z
|
|
6776
|
-
]),
|
|
7163
|
+
]), pn = useCallback((e) => {
|
|
6777
7164
|
if (e !== "picker") {
|
|
6778
7165
|
let e = J.value && isFinite(J.value.lng) && isFinite(J.value.lat), t = J.showMarker !== !1;
|
|
6779
|
-
(!e || !t) &&
|
|
7166
|
+
(!e || !t) && zt(), it(null);
|
|
6780
7167
|
}
|
|
6781
|
-
e !== "edit" && (H(null), U(null), X(), Z(), Y()),
|
|
7168
|
+
e !== "edit" && (H(null), U(null), X(), Z(), Y()), nt(e);
|
|
6782
7169
|
}, [
|
|
6783
|
-
|
|
7170
|
+
zt,
|
|
6784
7171
|
Y,
|
|
6785
7172
|
X,
|
|
6786
7173
|
Z
|
|
6787
|
-
]),
|
|
6788
|
-
|
|
6789
|
-
}, [
|
|
6790
|
-
|
|
6791
|
-
})), [
|
|
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]);
|
|
6792
7179
|
useEffect(() => {
|
|
6793
|
-
if (
|
|
7180
|
+
if (!et) return;
|
|
6794
7181
|
let e = J.value;
|
|
6795
7182
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6796
7183
|
let t = [e.lng, e.lat];
|
|
6797
|
-
|
|
7184
|
+
it(e), Rt(t);
|
|
6798
7185
|
}
|
|
6799
7186
|
}, [
|
|
6800
7187
|
J.value,
|
|
6801
|
-
|
|
6802
|
-
|
|
7188
|
+
Rt,
|
|
7189
|
+
et
|
|
6803
7190
|
]);
|
|
6804
|
-
let
|
|
6805
|
-
if (
|
|
6806
|
-
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({
|
|
6807
7194
|
id: "custom",
|
|
6808
7195
|
name: e.markerStyle.name || "Marker",
|
|
6809
7196
|
icon: e.markerStyle.src,
|
|
6810
7197
|
width: e.markerStyle.width
|
|
6811
|
-
}) : 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));
|
|
6812
7199
|
else if (e.mode === "rectangle") {
|
|
6813
|
-
|
|
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();
|
|
6814
7201
|
let t = L.current;
|
|
6815
7202
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6816
7203
|
} else if (e.mode === "circle") {
|
|
6817
|
-
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();
|
|
6818
7205
|
let t = L.current;
|
|
6819
7206
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6820
7207
|
} else if (e.mode === "polygon") {
|
|
6821
|
-
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();
|
|
6822
7209
|
let t = L.current;
|
|
6823
7210
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6824
7211
|
} else if (e.mode === "square") {
|
|
6825
|
-
|
|
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();
|
|
6826
7213
|
let t = L.current;
|
|
6827
7214
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6828
7215
|
} else if (e.mode === "polyline") {
|
|
6829
|
-
|
|
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();
|
|
6830
7217
|
let t = L.current;
|
|
6831
7218
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6832
7219
|
}
|
|
6833
|
-
} 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;
|
|
6834
7221
|
}, [
|
|
6835
|
-
Lt,
|
|
6836
7222
|
zt,
|
|
7223
|
+
Vt,
|
|
6837
7224
|
Y
|
|
6838
7225
|
]);
|
|
6839
7226
|
useImperativeHandle(c, () => ({
|
|
6840
|
-
startAnimation:
|
|
6841
|
-
stopAnimation:
|
|
6842
|
-
toggleAnimation:
|
|
7227
|
+
startAnimation: Ct,
|
|
7228
|
+
stopAnimation: wt,
|
|
7229
|
+
toggleAnimation: Tt,
|
|
6843
7230
|
getMap: () => L.current,
|
|
6844
|
-
openPopup: (e) =>
|
|
6845
|
-
closePopup:
|
|
6846
|
-
closeAllPopups:
|
|
6847
|
-
isPopupOpen:
|
|
6848
|
-
toggleUnitTrajectory:
|
|
6849
|
-
flyTo:
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
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,
|
|
6856
7244
|
getRenderer: (e) => R.current.get(e),
|
|
6857
7245
|
setEditingEntities: (e) => {
|
|
6858
|
-
for (let t of
|
|
7246
|
+
for (let t of St.current) e.map(String).includes(String(t)) || R.current.get(t)?.setEditing?.(!1);
|
|
6859
7247
|
for (let t of e) R.current.get(t)?.setEditing?.(!0);
|
|
6860
|
-
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null),
|
|
7248
|
+
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null), xt(e);
|
|
6861
7249
|
},
|
|
6862
|
-
getEditingEntities: () =>
|
|
6863
|
-
startPicking:
|
|
7250
|
+
getEditingEntities: () => St.current,
|
|
7251
|
+
startPicking: _n,
|
|
6864
7252
|
startRoutePlanning: (e) => {
|
|
6865
|
-
|
|
7253
|
+
Ue.current?.startPlanning(e);
|
|
6866
7254
|
},
|
|
6867
|
-
getRoadHighlightControl: () =>
|
|
7255
|
+
getRoadHighlightControl: () => We.current
|
|
6868
7256
|
}), [
|
|
6869
|
-
St,
|
|
6870
7257
|
Ct,
|
|
6871
7258
|
wt,
|
|
6872
|
-
|
|
7259
|
+
Tt,
|
|
6873
7260
|
Dt,
|
|
6874
7261
|
Ot,
|
|
6875
7262
|
kt,
|
|
6876
|
-
Tt,
|
|
6877
7263
|
At,
|
|
7264
|
+
Et,
|
|
6878
7265
|
jt,
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
pn,
|
|
7266
|
+
Mt,
|
|
7267
|
+
Nt,
|
|
6882
7268
|
mn,
|
|
6883
|
-
|
|
6884
|
-
hn
|
|
7269
|
+
pn,
|
|
7270
|
+
hn,
|
|
7271
|
+
gn,
|
|
7272
|
+
yn,
|
|
7273
|
+
_n
|
|
6885
7274
|
]);
|
|
6886
|
-
let
|
|
7275
|
+
let bn = useCallback(() => {
|
|
6887
7276
|
let e = L.current;
|
|
6888
7277
|
if (!e) return;
|
|
6889
7278
|
let t = new Set(T.map((e) => e.id)), n = new Set(R.current.keys());
|
|
@@ -6908,13 +7297,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6908
7297
|
let t = new CircleRenderer(e, n, O, k, j, M);
|
|
6909
7298
|
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6910
7299
|
}
|
|
6911
|
-
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);
|
|
6912
7301
|
else {
|
|
6913
7302
|
let t = null;
|
|
6914
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, j, M) : new CircleRenderer(e, n, O, k, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, j, N) : n.type === "polyline"
|
|
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));
|
|
6915
7304
|
}
|
|
6916
7305
|
}
|
|
6917
|
-
for (let e of
|
|
7306
|
+
for (let e of St.current) {
|
|
6918
7307
|
let t = R.current.get(e);
|
|
6919
7308
|
t && t.setEditing?.(!0);
|
|
6920
7309
|
}
|
|
@@ -6927,10 +7316,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6927
7316
|
j,
|
|
6928
7317
|
M,
|
|
6929
7318
|
N
|
|
6930
|
-
]),
|
|
7319
|
+
]), xn = useCallback(() => {
|
|
6931
7320
|
for (let e of R.current.values()) e.destroy();
|
|
6932
7321
|
R.current.clear();
|
|
6933
|
-
}, []),
|
|
7322
|
+
}, []), Sn = useCallback((e) => {
|
|
6934
7323
|
let t = e.getStyle();
|
|
6935
7324
|
if (!t?.layers) return;
|
|
6936
7325
|
let n = [
|
|
@@ -6942,13 +7331,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6942
7331
|
"radar-",
|
|
6943
7332
|
"image-",
|
|
6944
7333
|
"unit-",
|
|
6945
|
-
"marker-"
|
|
7334
|
+
"marker-",
|
|
7335
|
+
"attack-direction-"
|
|
6946
7336
|
];
|
|
6947
7337
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6948
|
-
}, []),
|
|
7338
|
+
}, []), Cn = useCallback((e) => {
|
|
6949
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;
|
|
6950
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;
|
|
6951
|
-
}, [C]),
|
|
7341
|
+
}, [C]), wn = useCallback((e, t) => {
|
|
6952
7342
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6953
7343
|
type: "raster",
|
|
6954
7344
|
tiles: [t.url],
|
|
@@ -6958,19 +7348,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6958
7348
|
scheme: t.scheme ?? "xyz"
|
|
6959
7349
|
};
|
|
6960
7350
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6961
|
-
let a =
|
|
7351
|
+
let a = Sn(e);
|
|
6962
7352
|
e.addLayer({
|
|
6963
7353
|
id: r,
|
|
6964
7354
|
type: "raster",
|
|
6965
7355
|
source: n,
|
|
6966
|
-
paint:
|
|
7356
|
+
paint: Cn(t),
|
|
6967
7357
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6968
7358
|
}, a);
|
|
6969
|
-
}, [
|
|
7359
|
+
}, [Sn, Cn]), Tn = useCallback(async (e, t) => {
|
|
6970
7360
|
try {
|
|
6971
7361
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6972
|
-
if (!
|
|
6973
|
-
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);
|
|
6974
7364
|
if (a) {
|
|
6975
7365
|
let t = {
|
|
6976
7366
|
type: "vector",
|
|
@@ -6991,21 +7381,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6991
7381
|
id: i,
|
|
6992
7382
|
type: "raster",
|
|
6993
7383
|
source: r,
|
|
6994
|
-
paint:
|
|
7384
|
+
paint: Cn(t),
|
|
6995
7385
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6996
7386
|
}, o);
|
|
6997
7387
|
} catch (e) {
|
|
6998
7388
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
6999
7389
|
}
|
|
7000
|
-
}, [
|
|
7390
|
+
}, [Sn, Cn]), En = useCallback(async (e, t) => {
|
|
7001
7391
|
try {
|
|
7002
7392
|
let n = await (await fetch(t.url)).json();
|
|
7003
|
-
if (!
|
|
7393
|
+
if (!Ge.current.has(t.id)) return;
|
|
7004
7394
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
7005
7395
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
7006
7396
|
e.getSource(n) || e.addSource(n, i);
|
|
7007
7397
|
}
|
|
7008
|
-
let r =
|
|
7398
|
+
let r = Sn(e);
|
|
7009
7399
|
if (n.layers) for (let i of n.layers) {
|
|
7010
7400
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
7011
7401
|
if (e.getLayer(n)) continue;
|
|
@@ -7016,7 +7406,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7016
7406
|
};
|
|
7017
7407
|
i.type === "raster" && (a.paint = {
|
|
7018
7408
|
...a.paint,
|
|
7019
|
-
...
|
|
7409
|
+
...Cn(t)
|
|
7020
7410
|
}), t.visible === !1 && (a.layout = {
|
|
7021
7411
|
...a.layout,
|
|
7022
7412
|
visibility: "none"
|
|
@@ -7029,50 +7419,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7029
7419
|
} catch (e) {
|
|
7030
7420
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
7031
7421
|
}
|
|
7032
|
-
}, [
|
|
7422
|
+
}, [Sn, Cn]), Dn = useCallback((e, t) => {
|
|
7033
7423
|
let n = e.getStyle();
|
|
7034
7424
|
if (!n) return;
|
|
7035
7425
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
7036
7426
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
7037
7427
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7038
7428
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7039
|
-
}, []),
|
|
7429
|
+
}, []), On = useCallback((e) => {
|
|
7040
7430
|
let t = L.current;
|
|
7041
7431
|
if (!t) return;
|
|
7042
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
7043
|
-
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));
|
|
7044
7434
|
for (let n of e) if (r.has(n.id)) {
|
|
7045
7435
|
let e = `base-layer-${n.id}`;
|
|
7046
7436
|
if (t.getLayer(e)) {
|
|
7047
|
-
let r =
|
|
7437
|
+
let r = Cn(n);
|
|
7048
7438
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7049
7439
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7050
7440
|
}
|
|
7051
7441
|
} else switch (r.add(n.id), n.type) {
|
|
7052
7442
|
case "raster":
|
|
7053
|
-
|
|
7443
|
+
wn(t, n);
|
|
7054
7444
|
break;
|
|
7055
7445
|
case "tilejson":
|
|
7056
|
-
|
|
7446
|
+
Tn(t, n);
|
|
7057
7447
|
break;
|
|
7058
7448
|
case "style":
|
|
7059
|
-
|
|
7449
|
+
En(t, n);
|
|
7060
7450
|
break;
|
|
7061
7451
|
default: {
|
|
7062
7452
|
let e = n;
|
|
7063
|
-
e.url &&
|
|
7453
|
+
e.url && wn(t, {
|
|
7064
7454
|
...e,
|
|
7065
7455
|
type: "raster"
|
|
7066
7456
|
});
|
|
7067
7457
|
}
|
|
7068
7458
|
}
|
|
7069
7459
|
}, [
|
|
7070
|
-
Sn,
|
|
7071
|
-
Cn,
|
|
7072
7460
|
wn,
|
|
7073
7461
|
Tn,
|
|
7074
|
-
|
|
7075
|
-
|
|
7462
|
+
En,
|
|
7463
|
+
Dn,
|
|
7464
|
+
Cn
|
|
7465
|
+
]), kn = useCallback((e) => {
|
|
7076
7466
|
let t = e;
|
|
7077
7467
|
for (; t;) {
|
|
7078
7468
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7080,129 +7470,129 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7080
7470
|
t = t.parentElement;
|
|
7081
7471
|
}
|
|
7082
7472
|
return null;
|
|
7083
|
-
}, []),
|
|
7473
|
+
}, []), An = useCallback((e) => {
|
|
7084
7474
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7085
7475
|
x: e.point.x,
|
|
7086
7476
|
y: e.point.y
|
|
7087
|
-
}, r =
|
|
7477
|
+
}, r = Rn.current;
|
|
7088
7478
|
if (r === "picker") {
|
|
7089
7479
|
let e = {
|
|
7090
7480
|
lng: t[0],
|
|
7091
7481
|
lat: t[1]
|
|
7092
7482
|
};
|
|
7093
|
-
|
|
7483
|
+
it(e), Rt(t), zn.current?.(e), Pt.current && (Pt.current(e), Pt.current = null, Lt({}), zt(), it(null), pn(Ft.current));
|
|
7094
7484
|
return;
|
|
7095
7485
|
}
|
|
7096
|
-
if (
|
|
7486
|
+
if (yt.current) return;
|
|
7097
7487
|
if (r === "edit") {
|
|
7098
|
-
let e =
|
|
7488
|
+
let e = Vn.current;
|
|
7099
7489
|
if (e === "rectangle") {
|
|
7100
|
-
let e =
|
|
7101
|
-
if (!e)
|
|
7490
|
+
let e = Hn.current;
|
|
7491
|
+
if (!e) lt(t);
|
|
7102
7492
|
else {
|
|
7103
|
-
let n =
|
|
7493
|
+
let n = ut.current, r = applyEntityConfig({
|
|
7104
7494
|
...n,
|
|
7105
|
-
id: n?.id ??
|
|
7495
|
+
id: n?.id ?? Bt(),
|
|
7106
7496
|
type: "rectangle",
|
|
7107
7497
|
bounds: [e, t]
|
|
7108
7498
|
}, D);
|
|
7109
|
-
|
|
7499
|
+
Gt();
|
|
7110
7500
|
let i = L.current;
|
|
7111
7501
|
if (i && !R.current.has(r.id)) {
|
|
7112
7502
|
let e = new RectangleRenderer(i, r, O, k, j, N);
|
|
7113
7503
|
R.current.set(r.id, e);
|
|
7114
7504
|
}
|
|
7115
|
-
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 = ""));
|
|
7116
7506
|
}
|
|
7117
7507
|
return;
|
|
7118
7508
|
}
|
|
7119
7509
|
if (e === "circle") {
|
|
7120
|
-
let e =
|
|
7121
|
-
if (!e)
|
|
7510
|
+
let e = ft.current;
|
|
7511
|
+
if (!e) ft.current = { center: t };
|
|
7122
7512
|
else {
|
|
7123
|
-
let n =
|
|
7513
|
+
let n = Jt(e.center, t), r = G.current, i = applyEntityConfig({
|
|
7124
7514
|
...r,
|
|
7125
|
-
id: r?.id ??
|
|
7515
|
+
id: r?.id ?? Bt(),
|
|
7126
7516
|
type: "circle",
|
|
7127
7517
|
center: e.center,
|
|
7128
7518
|
radius: n
|
|
7129
7519
|
}, D);
|
|
7130
|
-
|
|
7520
|
+
Xt();
|
|
7131
7521
|
let a = L.current;
|
|
7132
7522
|
if (a && !R.current.has(i.id)) {
|
|
7133
7523
|
let e = new CircleRenderer(a, i, O, k, j, M);
|
|
7134
7524
|
R.current.set(i.id, e);
|
|
7135
7525
|
}
|
|
7136
|
-
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 = ""));
|
|
7137
7527
|
}
|
|
7138
7528
|
return;
|
|
7139
7529
|
}
|
|
7140
7530
|
if (e === "polygon") {
|
|
7141
|
-
let e =
|
|
7531
|
+
let e = pt.current;
|
|
7142
7532
|
if (e.length >= 3) {
|
|
7143
7533
|
let n = e[0];
|
|
7144
|
-
if (
|
|
7534
|
+
if (Jt(n, t) < 20) {
|
|
7145
7535
|
let t = K.current, n = applyEntityConfig({
|
|
7146
7536
|
...t,
|
|
7147
|
-
id: t?.id ??
|
|
7537
|
+
id: t?.id ?? Bt(),
|
|
7148
7538
|
type: "polygon",
|
|
7149
7539
|
coordinates: [...e]
|
|
7150
7540
|
}, D);
|
|
7151
|
-
|
|
7541
|
+
en();
|
|
7152
7542
|
let r = L.current;
|
|
7153
7543
|
if (r && !R.current.has(n.id)) {
|
|
7154
7544
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7155
7545
|
R.current.set(n.id, e);
|
|
7156
7546
|
}
|
|
7157
|
-
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 = ""));
|
|
7158
7548
|
return;
|
|
7159
7549
|
}
|
|
7160
7550
|
}
|
|
7161
|
-
|
|
7551
|
+
pt.current = [...e, t];
|
|
7162
7552
|
return;
|
|
7163
7553
|
}
|
|
7164
7554
|
if (e === "square") {
|
|
7165
|
-
let e =
|
|
7166
|
-
if (!e)
|
|
7555
|
+
let e = ht.current;
|
|
7556
|
+
if (!e) ht.current = { center: t };
|
|
7167
7557
|
else {
|
|
7168
|
-
let n =
|
|
7558
|
+
let n = Jt(e.center, t) * 2, r = mt.current, i = applyEntityConfig({
|
|
7169
7559
|
...r,
|
|
7170
|
-
id: r?.id ??
|
|
7560
|
+
id: r?.id ?? Bt(),
|
|
7171
7561
|
type: "square",
|
|
7172
7562
|
center: e.center,
|
|
7173
7563
|
length: n
|
|
7174
7564
|
}, D);
|
|
7175
|
-
|
|
7565
|
+
on();
|
|
7176
7566
|
let a = L.current;
|
|
7177
7567
|
if (a && !R.current.has(i.id)) {
|
|
7178
7568
|
let e = new SquareRenderer(a, i, O, k, j, N);
|
|
7179
7569
|
R.current.set(i.id, e);
|
|
7180
7570
|
}
|
|
7181
|
-
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 = ""));
|
|
7182
7572
|
}
|
|
7183
7573
|
return;
|
|
7184
7574
|
}
|
|
7185
7575
|
if (e === "polyline") {
|
|
7186
|
-
|
|
7576
|
+
_t.current = [..._t.current, t];
|
|
7187
7577
|
return;
|
|
7188
7578
|
}
|
|
7189
|
-
let n =
|
|
7579
|
+
let n = dt.current;
|
|
7190
7580
|
if (n && n.src && n.width) {
|
|
7191
7581
|
let e = {
|
|
7192
7582
|
...n,
|
|
7193
|
-
id: n.id ??
|
|
7583
|
+
id: n.id ?? Bt(),
|
|
7194
7584
|
type: "marker",
|
|
7195
7585
|
center: t,
|
|
7196
7586
|
src: n.src,
|
|
7197
7587
|
width: n.width
|
|
7198
7588
|
};
|
|
7199
|
-
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;
|
|
7200
7590
|
return;
|
|
7201
7591
|
}
|
|
7202
|
-
let r =
|
|
7592
|
+
let r = Bn.current;
|
|
7203
7593
|
if (r) {
|
|
7204
7594
|
let e = {
|
|
7205
|
-
id:
|
|
7595
|
+
id: Bt(),
|
|
7206
7596
|
type: "marker",
|
|
7207
7597
|
name: r.name,
|
|
7208
7598
|
center: t,
|
|
@@ -7213,7 +7603,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7213
7603
|
return;
|
|
7214
7604
|
}
|
|
7215
7605
|
}
|
|
7216
|
-
if (
|
|
7606
|
+
if (St.current.length > 0) {
|
|
7217
7607
|
let e = L.current?.getZoom() ?? 12;
|
|
7218
7608
|
if (q.current) {
|
|
7219
7609
|
let { entityId: e, activeHandle: n } = q.current, r = R.current.get(e);
|
|
@@ -7224,7 +7614,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7224
7614
|
q.current = null;
|
|
7225
7615
|
return;
|
|
7226
7616
|
}
|
|
7227
|
-
for (let n of
|
|
7617
|
+
for (let n of St.current) {
|
|
7228
7618
|
let r = R.current.get(n);
|
|
7229
7619
|
if (!r?.getEditHandleAt) continue;
|
|
7230
7620
|
let i = r.getEditHandleAt(t, e);
|
|
@@ -7247,12 +7637,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7247
7637
|
}
|
|
7248
7638
|
}
|
|
7249
7639
|
}
|
|
7250
|
-
let i =
|
|
7640
|
+
let i = Fn.current, a = In.current, o = Ln.current, s = kn(e.originalEvent.target);
|
|
7251
7641
|
if (s) {
|
|
7252
7642
|
let e = i.find((e) => String(e.id) === s);
|
|
7253
7643
|
if (e) {
|
|
7254
7644
|
if (a?.(e), e.popup) {
|
|
7255
|
-
let t = e.popup.content ??
|
|
7645
|
+
let t = e.popup.content ?? Fe?.(e);
|
|
7256
7646
|
t && mergePopupConfig(e.popup, I, t).trigger === "click" && o(s, "click", n);
|
|
7257
7647
|
}
|
|
7258
7648
|
return;
|
|
@@ -7264,7 +7654,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7264
7654
|
let e = i.find((e) => e.id === t);
|
|
7265
7655
|
if (e) {
|
|
7266
7656
|
if (a?.(e), e.popup) {
|
|
7267
|
-
let r = e.popup.content ??
|
|
7657
|
+
let r = e.popup.content ?? Fe?.(e);
|
|
7268
7658
|
r && mergePopupConfig(e.popup, I, r).trigger === "click" && o(t, "click", n);
|
|
7269
7659
|
}
|
|
7270
7660
|
return;
|
|
@@ -7275,7 +7665,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7275
7665
|
let t = i.find((t) => t.id === e);
|
|
7276
7666
|
if (t) {
|
|
7277
7667
|
if (a?.(t), t.popup) {
|
|
7278
|
-
let r = t.popup.content ??
|
|
7668
|
+
let r = t.popup.content ?? Fe?.(t);
|
|
7279
7669
|
r && mergePopupConfig(t.popup, I, r).trigger === "click" && o(e, "click", n);
|
|
7280
7670
|
}
|
|
7281
7671
|
return;
|
|
@@ -7283,67 +7673,67 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7283
7673
|
}
|
|
7284
7674
|
}, [
|
|
7285
7675
|
I,
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
]),
|
|
7676
|
+
Fe,
|
|
7677
|
+
kn
|
|
7678
|
+
]), jn = useCallback((e) => {
|
|
7289
7679
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7290
7680
|
if (q.current) {
|
|
7291
7681
|
let { entityId: e, activeHandle: n } = q.current;
|
|
7292
7682
|
R.current.get(e)?.updateEditPreview?.(n, t);
|
|
7293
7683
|
return;
|
|
7294
7684
|
}
|
|
7295
|
-
let n =
|
|
7296
|
-
n === "rectangle" && r &&
|
|
7297
|
-
let i =
|
|
7298
|
-
n === "circle" && i &&
|
|
7299
|
-
let a =
|
|
7300
|
-
n === "polygon" && a.length > 0 &&
|
|
7301
|
-
let o =
|
|
7302
|
-
n === "square" && o &&
|
|
7303
|
-
let s =
|
|
7304
|
-
n === "polyline" && s.length > 0 &&
|
|
7305
|
-
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;
|
|
7306
7696
|
for (let [e, n] of R.current) if (n.isPointInEntity(t)) {
|
|
7307
7697
|
let t = c.find((t) => t.id === e);
|
|
7308
7698
|
if (!t?.popup) continue;
|
|
7309
|
-
let n = t.popup.content ??
|
|
7699
|
+
let n = t.popup.content ?? Fe?.(t);
|
|
7310
7700
|
if (!n) continue;
|
|
7311
7701
|
let r = mergePopupConfig(t.popup, I, n);
|
|
7312
7702
|
if (r.trigger === "hover") {
|
|
7313
|
-
|
|
7703
|
+
Ye.current && clearTimeout(Ye.current), Ye.current = window.setTimeout(() => {
|
|
7314
7704
|
l(e, "hover");
|
|
7315
7705
|
}, r.hoverDelay);
|
|
7316
7706
|
return;
|
|
7317
7707
|
}
|
|
7318
7708
|
}
|
|
7319
|
-
if (
|
|
7709
|
+
if (Ye.current &&= (clearTimeout(Ye.current), null), B?.openedBy === "hover") {
|
|
7320
7710
|
let e = R.current.get(B.entityId);
|
|
7321
|
-
e && !e.isPointInEntity(t) &&
|
|
7711
|
+
e && !e.isPointInEntity(t) && Ot(B.entityId);
|
|
7322
7712
|
}
|
|
7323
7713
|
}, [
|
|
7324
7714
|
I,
|
|
7325
|
-
|
|
7715
|
+
Fe,
|
|
7326
7716
|
B,
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
]),
|
|
7334
|
-
if (e.preventDefault(),
|
|
7335
|
-
|
|
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);
|
|
7336
7726
|
return;
|
|
7337
7727
|
}
|
|
7338
|
-
if (
|
|
7339
|
-
if (
|
|
7728
|
+
if (yt.current) return;
|
|
7729
|
+
if (St.current.length > 0) {
|
|
7340
7730
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7341
7731
|
if (q.current) {
|
|
7342
7732
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7343
7733
|
return;
|
|
7344
7734
|
}
|
|
7345
7735
|
let n = L.current?.getZoom() ?? 12;
|
|
7346
|
-
for (let e of
|
|
7736
|
+
for (let e of St.current) {
|
|
7347
7737
|
let r = R.current.get(e);
|
|
7348
7738
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7349
7739
|
let i = r.getEditHandleAt(t, n);
|
|
@@ -7354,14 +7744,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7354
7744
|
}
|
|
7355
7745
|
}
|
|
7356
7746
|
}
|
|
7357
|
-
if (
|
|
7358
|
-
if (
|
|
7747
|
+
if (Rn.current !== "edit") return;
|
|
7748
|
+
if (Bn.current) {
|
|
7359
7749
|
H(null), U(null), Y();
|
|
7360
7750
|
return;
|
|
7361
7751
|
}
|
|
7362
|
-
let t =
|
|
7752
|
+
let t = Vn.current;
|
|
7363
7753
|
if (t === "rectangle") {
|
|
7364
|
-
if (
|
|
7754
|
+
if (Hn.current) lt(null), Gt();
|
|
7365
7755
|
else {
|
|
7366
7756
|
U(null);
|
|
7367
7757
|
let e = L.current;
|
|
@@ -7370,7 +7760,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7370
7760
|
return;
|
|
7371
7761
|
}
|
|
7372
7762
|
if (t === "circle") {
|
|
7373
|
-
if (
|
|
7763
|
+
if (ft.current) ft.current = null, Xt();
|
|
7374
7764
|
else {
|
|
7375
7765
|
U(null);
|
|
7376
7766
|
let e = L.current;
|
|
@@ -7379,22 +7769,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7379
7769
|
return;
|
|
7380
7770
|
}
|
|
7381
7771
|
if (t === "polygon") {
|
|
7382
|
-
let e =
|
|
7772
|
+
let e = pt.current;
|
|
7383
7773
|
if (e.length >= 3) {
|
|
7384
7774
|
let t = K.current, n = applyEntityConfig({
|
|
7385
7775
|
...t,
|
|
7386
|
-
id: t?.id ??
|
|
7776
|
+
id: t?.id ?? Bt(),
|
|
7387
7777
|
type: "polygon",
|
|
7388
7778
|
coordinates: [...e]
|
|
7389
7779
|
}, D);
|
|
7390
|
-
|
|
7780
|
+
en();
|
|
7391
7781
|
let r = L.current;
|
|
7392
7782
|
if (r && !R.current.has(n.id)) {
|
|
7393
7783
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7394
7784
|
R.current.set(n.id, e);
|
|
7395
7785
|
}
|
|
7396
|
-
Q.current.onPolygonAdd?.(n),
|
|
7397
|
-
} 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();
|
|
7398
7788
|
else {
|
|
7399
7789
|
U(null);
|
|
7400
7790
|
let e = L.current;
|
|
@@ -7403,7 +7793,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7403
7793
|
return;
|
|
7404
7794
|
}
|
|
7405
7795
|
if (t === "square") {
|
|
7406
|
-
if (
|
|
7796
|
+
if (ht.current) ht.current = null, on();
|
|
7407
7797
|
else {
|
|
7408
7798
|
U(null);
|
|
7409
7799
|
let e = L.current;
|
|
@@ -7412,22 +7802,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7412
7802
|
return;
|
|
7413
7803
|
}
|
|
7414
7804
|
if (t === "polyline") {
|
|
7415
|
-
let e =
|
|
7805
|
+
let e = _t.current;
|
|
7416
7806
|
if (e.length >= 2) {
|
|
7417
|
-
let t =
|
|
7807
|
+
let t = gt.current, n = applyEntityConfig({
|
|
7418
7808
|
...t,
|
|
7419
|
-
id: t?.id ??
|
|
7809
|
+
id: t?.id ?? Bt(),
|
|
7420
7810
|
type: "polyline",
|
|
7421
7811
|
coordinates: [...e]
|
|
7422
7812
|
}, D);
|
|
7423
|
-
|
|
7813
|
+
un();
|
|
7424
7814
|
let r = L.current;
|
|
7425
7815
|
if (r && !R.current.has(n.id)) {
|
|
7426
7816
|
let e = new PolylineRenderer(r, n, O, k, N);
|
|
7427
7817
|
R.current.set(n.id, e);
|
|
7428
7818
|
}
|
|
7429
|
-
Q.current.onPolylineAdd?.(n),
|
|
7430
|
-
} 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();
|
|
7431
7821
|
else {
|
|
7432
7822
|
U(null);
|
|
7433
7823
|
let e = L.current;
|
|
@@ -7438,11 +7828,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7438
7828
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7439
7829
|
x: e.point.x,
|
|
7440
7830
|
y: e.point.y
|
|
7441
|
-
}, i =
|
|
7831
|
+
}, i = Fn.current, a = kn(e.originalEvent.target);
|
|
7442
7832
|
if (a) {
|
|
7443
7833
|
let e = i.find((e) => String(e.id) === a);
|
|
7444
7834
|
if (e) {
|
|
7445
|
-
|
|
7835
|
+
Nn(e, r, n);
|
|
7446
7836
|
return;
|
|
7447
7837
|
}
|
|
7448
7838
|
}
|
|
@@ -7451,7 +7841,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7451
7841
|
if (o && L.current?.getLayer(o) && L.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7452
7842
|
let e = i.find((e) => e.id === t);
|
|
7453
7843
|
if (e) {
|
|
7454
|
-
|
|
7844
|
+
Nn(e, r, n);
|
|
7455
7845
|
return;
|
|
7456
7846
|
}
|
|
7457
7847
|
}
|
|
@@ -7459,24 +7849,24 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7459
7849
|
for (let [e, t] of R.current) if (t.isPointInEntity(n)) {
|
|
7460
7850
|
let t = i.find((t) => t.id === e);
|
|
7461
7851
|
if (t) {
|
|
7462
|
-
|
|
7852
|
+
Nn(t, r, n);
|
|
7463
7853
|
return;
|
|
7464
7854
|
}
|
|
7465
7855
|
}
|
|
7466
7856
|
}, [
|
|
7467
|
-
|
|
7857
|
+
kn,
|
|
7468
7858
|
Y,
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
]),
|
|
7475
|
-
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 ? {
|
|
7476
7866
|
x: t.x + r.left,
|
|
7477
7867
|
y: t.y + r.top
|
|
7478
7868
|
} : t;
|
|
7479
|
-
|
|
7869
|
+
Ze({
|
|
7480
7870
|
position: i,
|
|
7481
7871
|
lngLat: n,
|
|
7482
7872
|
items: [{
|
|
@@ -7496,8 +7886,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7496
7886
|
}
|
|
7497
7887
|
}]
|
|
7498
7888
|
});
|
|
7499
|
-
}, []),
|
|
7500
|
-
|
|
7889
|
+
}, []), Pn = useCallback(() => {
|
|
7890
|
+
Ze(null);
|
|
7501
7891
|
}, []);
|
|
7502
7892
|
useEffect(() => {
|
|
7503
7893
|
let e = document.createElement("div");
|
|
@@ -7509,7 +7899,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7509
7899
|
pointer-events: none;
|
|
7510
7900
|
height: 100%;
|
|
7511
7901
|
z-index: ${I?.zIndex ?? 1e3};
|
|
7512
|
-
`, document.body.appendChild(e),
|
|
7902
|
+
`, document.body.appendChild(e), qe.current = e, () => {
|
|
7513
7903
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7514
7904
|
};
|
|
7515
7905
|
}, [I?.zIndex]), useEffect(() => {
|
|
@@ -7522,61 +7912,61 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7522
7912
|
pointer-events: none;
|
|
7523
7913
|
height: 100%;
|
|
7524
7914
|
z-index: ${(I?.zIndex ?? 1e3) + 100};
|
|
7525
|
-
`, document.body.appendChild(e),
|
|
7915
|
+
`, document.body.appendChild(e), Qe.current = e, () => {
|
|
7526
7916
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7527
7917
|
};
|
|
7528
7918
|
}, [I?.zIndex]);
|
|
7529
|
-
let
|
|
7530
|
-
|
|
7531
|
-
let
|
|
7532
|
-
|
|
7533
|
-
let
|
|
7534
|
-
|
|
7535
|
-
let
|
|
7536
|
-
|
|
7537
|
-
let
|
|
7538
|
-
|
|
7539
|
-
let
|
|
7540
|
-
|
|
7541
|
-
let
|
|
7542
|
-
|
|
7543
|
-
let
|
|
7544
|
-
|
|
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;
|
|
7929
|
+
let Bn = useRef(ot);
|
|
7930
|
+
Bn.current = ot;
|
|
7931
|
+
let Vn = useRef(st);
|
|
7932
|
+
Vn.current = st;
|
|
7933
|
+
let Hn = useRef(ct);
|
|
7934
|
+
Hn.current = ct;
|
|
7545
7935
|
let Q = useRef(v);
|
|
7546
7936
|
Q.current = v;
|
|
7547
|
-
let
|
|
7548
|
-
|
|
7937
|
+
let Un = useRef(D);
|
|
7938
|
+
Un.current = D, useEffect(() => {
|
|
7549
7939
|
let e = (e) => {
|
|
7550
7940
|
if (e.key === "Escape" && q.current) {
|
|
7551
7941
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7552
7942
|
return;
|
|
7553
7943
|
}
|
|
7554
7944
|
if (e.key === "Escape" && V === "edit") {
|
|
7555
|
-
if (
|
|
7945
|
+
if (ot && (H(null), U(null), Y()), st === "rectangle") if (ct) lt(null), Gt();
|
|
7556
7946
|
else {
|
|
7557
7947
|
U(null);
|
|
7558
7948
|
let e = L.current;
|
|
7559
7949
|
e && (e.getCanvas().style.cursor = "");
|
|
7560
7950
|
}
|
|
7561
|
-
if (
|
|
7951
|
+
if (st === "circle") if (ft.current) ft.current = null, Xt();
|
|
7562
7952
|
else {
|
|
7563
7953
|
U(null);
|
|
7564
7954
|
let e = L.current;
|
|
7565
7955
|
e && (e.getCanvas().style.cursor = "");
|
|
7566
7956
|
}
|
|
7567
|
-
if (
|
|
7957
|
+
if (st === "polygon") if (pt.current.length > 0) pt.current = [], en();
|
|
7568
7958
|
else {
|
|
7569
7959
|
U(null);
|
|
7570
7960
|
let e = L.current;
|
|
7571
7961
|
e && (e.getCanvas().style.cursor = "");
|
|
7572
7962
|
}
|
|
7573
|
-
if (
|
|
7963
|
+
if (st === "square") if (ht.current) ht.current = null, on();
|
|
7574
7964
|
else {
|
|
7575
7965
|
U(null);
|
|
7576
7966
|
let e = L.current;
|
|
7577
7967
|
e && (e.getCanvas().style.cursor = "");
|
|
7578
7968
|
}
|
|
7579
|
-
if (
|
|
7969
|
+
if (st === "polyline") if (_t.current.length > 0) _t.current = [], un();
|
|
7580
7970
|
else {
|
|
7581
7971
|
U(null);
|
|
7582
7972
|
let e = L.current;
|
|
@@ -7589,55 +7979,55 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7589
7979
|
};
|
|
7590
7980
|
}, [
|
|
7591
7981
|
V,
|
|
7592
|
-
at,
|
|
7593
7982
|
ot,
|
|
7594
7983
|
st,
|
|
7984
|
+
ct,
|
|
7595
7985
|
Y,
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7986
|
+
Gt,
|
|
7987
|
+
Xt,
|
|
7988
|
+
en,
|
|
7989
|
+
on,
|
|
7990
|
+
un
|
|
7601
7991
|
]), useEffect(() => {
|
|
7602
7992
|
let e = L.current;
|
|
7603
7993
|
if (!e || !B) return;
|
|
7604
7994
|
let t = B.entityId, n = B.config, r = () => {
|
|
7605
|
-
let r =
|
|
7995
|
+
let r = Fn.current.find((e) => e.id === t);
|
|
7606
7996
|
if (!r) {
|
|
7607
|
-
|
|
7997
|
+
kt();
|
|
7608
7998
|
return;
|
|
7609
7999
|
}
|
|
7610
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7611
|
-
|
|
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`);
|
|
7612
8002
|
}, i = setTimeout(() => {
|
|
7613
8003
|
r();
|
|
7614
8004
|
}, 50);
|
|
7615
8005
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7616
8006
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7617
8007
|
};
|
|
7618
|
-
}, [B?.entityId,
|
|
7619
|
-
let e = L.current, t =
|
|
7620
|
-
if (!e || !
|
|
7621
|
-
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 = () => {
|
|
7622
8012
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7623
8013
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7624
|
-
|
|
8014
|
+
Pn();
|
|
7625
8015
|
return;
|
|
7626
8016
|
}
|
|
7627
8017
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7628
|
-
|
|
8018
|
+
$e.current && ($e.current.style.left = `${s}px`, $e.current.style.top = `${c}px`);
|
|
7629
8019
|
};
|
|
7630
8020
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7631
8021
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7632
8022
|
};
|
|
7633
|
-
}, [
|
|
7634
|
-
if (!
|
|
8023
|
+
}, [Xe?.lngLat, Pn]), useEffect(() => {
|
|
8024
|
+
if (!He.current) return;
|
|
7635
8025
|
let e = {
|
|
7636
8026
|
version: 8,
|
|
7637
8027
|
sources: {},
|
|
7638
8028
|
layers: []
|
|
7639
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({
|
|
7640
|
-
container:
|
|
8030
|
+
container: He.current,
|
|
7641
8031
|
style: p || e,
|
|
7642
8032
|
center: l,
|
|
7643
8033
|
zoom: u,
|
|
@@ -7671,9 +8061,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7671
8061
|
}
|
|
7672
8062
|
z.current.clear(), T.forEach((e) => {
|
|
7673
8063
|
z.current.set(e.id, e);
|
|
7674
|
-
}),
|
|
7675
|
-
}), _.on("click",
|
|
7676
|
-
_.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;
|
|
7677
8067
|
};
|
|
7678
8068
|
}, []), useEffect(() => {
|
|
7679
8069
|
if (L.current) {
|
|
@@ -7681,53 +8071,53 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7681
8071
|
L.current.once("load", () => {
|
|
7682
8072
|
z.current.clear(), T.forEach((e) => {
|
|
7683
8073
|
z.current.set(e.id, e);
|
|
7684
|
-
}),
|
|
8074
|
+
}), bn();
|
|
7685
8075
|
});
|
|
7686
8076
|
return;
|
|
7687
8077
|
}
|
|
7688
8078
|
z.current.clear(), T.forEach((e) => {
|
|
7689
8079
|
z.current.set(e.id, e);
|
|
7690
|
-
}),
|
|
8080
|
+
}), bn();
|
|
7691
8081
|
}
|
|
7692
|
-
}, [T,
|
|
7693
|
-
!L.current || !L.current.isStyleLoaded() || (
|
|
8082
|
+
}, [T, bn]), useEffect(() => {
|
|
8083
|
+
!L.current || !L.current.isStyleLoaded() || (xn(), bn());
|
|
7694
8084
|
}, [
|
|
7695
8085
|
O,
|
|
7696
8086
|
k,
|
|
7697
8087
|
j,
|
|
7698
8088
|
M,
|
|
7699
8089
|
N,
|
|
7700
|
-
|
|
7701
|
-
|
|
8090
|
+
xn,
|
|
8091
|
+
bn
|
|
7702
8092
|
]), useEffect(() => {
|
|
7703
8093
|
if (L.current) {
|
|
7704
8094
|
if (!L.current.isStyleLoaded()) {
|
|
7705
8095
|
L.current.once("load", () => {
|
|
7706
|
-
|
|
8096
|
+
On(S);
|
|
7707
8097
|
});
|
|
7708
8098
|
return;
|
|
7709
8099
|
}
|
|
7710
|
-
|
|
7711
|
-
}
|
|
7712
|
-
}, [S,
|
|
7713
|
-
let
|
|
7714
|
-
|
|
7715
|
-
let
|
|
7716
|
-
|
|
7717
|
-
let
|
|
7718
|
-
|
|
7719
|
-
let
|
|
7720
|
-
|
|
7721
|
-
let
|
|
7722
|
-
|
|
7723
|
-
let
|
|
7724
|
-
|
|
7725
|
-
let
|
|
7726
|
-
|
|
7727
|
-
let
|
|
7728
|
-
|
|
7729
|
-
let
|
|
7730
|
-
|
|
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(() => {
|
|
7731
8121
|
let e = L.current;
|
|
7732
8122
|
if (!e) return;
|
|
7733
8123
|
let t = p || {
|
|
@@ -7735,27 +8125,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7735
8125
|
sources: {},
|
|
7736
8126
|
layers: []
|
|
7737
8127
|
};
|
|
7738
|
-
if (
|
|
7739
|
-
|
|
8128
|
+
if (Gn.current) {
|
|
8129
|
+
Gn.current = !1, Wn.current = p;
|
|
7740
8130
|
return;
|
|
7741
8131
|
}
|
|
7742
|
-
|
|
8132
|
+
Wn.current !== p && (Wn.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7743
8133
|
if (!e.getStyle().glyphs) {
|
|
7744
8134
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7745
8135
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7746
8136
|
}
|
|
7747
|
-
|
|
8137
|
+
Ge.current.clear(), qn.current(Kn.current), Jn.current(), Yn.current(), Xn.current(), Zn.current(), Qn.current(), $n.current(), er.current();
|
|
7748
8138
|
}));
|
|
7749
8139
|
}, [p]), useEffect(() => {
|
|
7750
8140
|
let e = new Set(E.map(String));
|
|
7751
8141
|
for (let [t, n] of R.current) n.setSelected(e.has(String(t)));
|
|
7752
8142
|
}, [E]);
|
|
7753
|
-
let
|
|
8143
|
+
let tr = useRef({});
|
|
7754
8144
|
useEffect(() => {
|
|
7755
8145
|
let e = L.current;
|
|
7756
8146
|
if (!e) return;
|
|
7757
|
-
let t =
|
|
7758
|
-
!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 = {
|
|
7759
8149
|
center: l,
|
|
7760
8150
|
zoom: u,
|
|
7761
8151
|
pitch: d,
|
|
@@ -7772,8 +8162,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7772
8162
|
d,
|
|
7773
8163
|
f
|
|
7774
8164
|
]);
|
|
7775
|
-
let
|
|
7776
|
-
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;
|
|
7777
8167
|
let e, t, n;
|
|
7778
8168
|
if (S && S.length > 0) {
|
|
7779
8169
|
let r = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
@@ -7786,18 +8176,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7786
8176
|
} else e = `base-layer-source-${r.id}`;
|
|
7787
8177
|
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7788
8178
|
}
|
|
7789
|
-
return
|
|
8179
|
+
return Ee === !0 ? {
|
|
7790
8180
|
enabled: !0,
|
|
7791
8181
|
source: e,
|
|
7792
8182
|
sourceLayer: t,
|
|
7793
8183
|
classField: n
|
|
7794
8184
|
} : {
|
|
7795
|
-
...
|
|
7796
|
-
source:
|
|
7797
|
-
sourceLayer:
|
|
7798
|
-
classField:
|
|
8185
|
+
...Ee,
|
|
8186
|
+
source: Ee.source || e,
|
|
8187
|
+
sourceLayer: Ee.sourceLayer || t,
|
|
8188
|
+
classField: Ee.classField || n
|
|
7799
8189
|
};
|
|
7800
|
-
})(),
|
|
8190
|
+
})(), ar = (() => F ? F === !0 ? { enabled: !0 } : F : null)(), or = (() => Oe ? Oe === !0 ? { enabled: !0 } : Oe : null)(), sr = (() => Me || null)(), cr = useMemo(() => {
|
|
7801
8191
|
let e = [];
|
|
7802
8192
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7803
8193
|
let n = L.current;
|
|
@@ -7807,7 +8197,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7807
8197
|
}
|
|
7808
8198
|
} else e.push(`base-layer-${t.id}`);
|
|
7809
8199
|
return e;
|
|
7810
|
-
}, [S,
|
|
8200
|
+
}, [S, et]), lr = useMemo(() => {
|
|
7811
8201
|
if (V !== "picker") return;
|
|
7812
8202
|
let e = J.cursorImage;
|
|
7813
8203
|
if (!e) return;
|
|
@@ -7842,16 +8232,16 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7842
8232
|
break;
|
|
7843
8233
|
}
|
|
7844
8234
|
return `url(${e.url}) ${i} ${a}, crosshair`;
|
|
7845
|
-
}, [V, J.cursorImage]),
|
|
7846
|
-
...
|
|
7847
|
-
"--mapbox-picker-cursor":
|
|
7848
|
-
} :
|
|
8235
|
+
}, [V, J.cursorImage]), ur = useMemo(() => lr ? {
|
|
8236
|
+
...Ve,
|
|
8237
|
+
"--mapbox-picker-cursor": lr
|
|
8238
|
+
} : Ve, [Ve, lr]);
|
|
7849
8239
|
return /* @__PURE__ */ jsxs("div", {
|
|
7850
|
-
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${
|
|
7851
|
-
style:
|
|
8240
|
+
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${Be}`,
|
|
8241
|
+
style: ur,
|
|
7852
8242
|
children: [
|
|
7853
8243
|
/* @__PURE__ */ jsx("div", {
|
|
7854
|
-
ref:
|
|
8244
|
+
ref: He,
|
|
7855
8245
|
className: "comp-mapbox__map"
|
|
7856
8246
|
}),
|
|
7857
8247
|
V === "picker" && J.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
@@ -7865,14 +8255,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7865
8255
|
})]
|
|
7866
8256
|
}),
|
|
7867
8257
|
/* @__PURE__ */ jsxs("div", {
|
|
7868
|
-
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ||
|
|
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"}`,
|
|
7869
8259
|
children: [
|
|
7870
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, {
|
|
7871
8261
|
markerTemplates: v.markerTemplates || [],
|
|
7872
|
-
selectedTemplate:
|
|
7873
|
-
onTemplateSelect:
|
|
7874
|
-
drawMode:
|
|
7875
|
-
onDrawModeChange:
|
|
8262
|
+
selectedTemplate: ot,
|
|
8263
|
+
onTemplateSelect: dn,
|
|
8264
|
+
drawMode: st,
|
|
8265
|
+
onDrawModeChange: fn,
|
|
7876
8266
|
showRectangleTool: v.showRectangleTool,
|
|
7877
8267
|
showCircleTool: v.showCircleTool,
|
|
7878
8268
|
showPolygonTool: v.showPolygonTool,
|
|
@@ -7880,8 +8270,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7880
8270
|
showPolylineTool: v.showPolylineTool
|
|
7881
8271
|
}),
|
|
7882
8272
|
/* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7883
|
-
ref:
|
|
7884
|
-
map:
|
|
8273
|
+
ref: We,
|
|
8274
|
+
map: et,
|
|
7885
8275
|
showButton: !!($ && $.enabled !== !1),
|
|
7886
8276
|
highlightWidth: $?.highlightWidth,
|
|
7887
8277
|
defaultRoadTypes: $?.defaultRoadTypes,
|
|
@@ -7892,80 +8282,80 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7892
8282
|
className: $?.className,
|
|
7893
8283
|
style: $?.style
|
|
7894
8284
|
}),
|
|
7895
|
-
|
|
7896
|
-
ref:
|
|
7897
|
-
map:
|
|
7898
|
-
pointCount:
|
|
7899
|
-
showPointCountInput:
|
|
7900
|
-
visualType:
|
|
7901
|
-
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
|
|
7902
8292
|
})
|
|
7903
8293
|
]
|
|
7904
8294
|
}),
|
|
7905
|
-
(
|
|
8295
|
+
(nr?.enabled !== !1 || rr?.enabled !== !1 || ir?.enabled !== !1 || ar && ar.enabled !== !1 || or && or.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7906
8296
|
className: "comp-mapbox__controls",
|
|
7907
8297
|
children: [
|
|
7908
|
-
|
|
7909
|
-
map:
|
|
7910
|
-
precision:
|
|
7911
|
-
className:
|
|
7912
|
-
style:
|
|
8298
|
+
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
8299
|
+
map: et,
|
|
8300
|
+
precision: nr.precision,
|
|
8301
|
+
className: nr.className,
|
|
8302
|
+
style: nr.style
|
|
7913
8303
|
}),
|
|
7914
|
-
|
|
7915
|
-
map:
|
|
7916
|
-
maxWidth:
|
|
7917
|
-
unit:
|
|
7918
|
-
className:
|
|
7919
|
-
style:
|
|
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
|
|
7920
8310
|
}),
|
|
7921
|
-
|
|
7922
|
-
map:
|
|
8311
|
+
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
8312
|
+
map: et,
|
|
7923
8313
|
entityConfig: D,
|
|
7924
8314
|
onDrawModeChange: (e) => {
|
|
7925
|
-
|
|
8315
|
+
yt.current = e;
|
|
7926
8316
|
},
|
|
7927
|
-
className:
|
|
7928
|
-
style:
|
|
8317
|
+
className: ar.className,
|
|
8318
|
+
style: ar.style
|
|
7929
8319
|
}),
|
|
7930
|
-
|
|
7931
|
-
map:
|
|
8320
|
+
or && or.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
8321
|
+
map: et,
|
|
7932
8322
|
value: C,
|
|
7933
|
-
onChange:
|
|
7934
|
-
rasterPaintLayerIds:
|
|
7935
|
-
className:
|
|
7936
|
-
style:
|
|
8323
|
+
onChange: Ne,
|
|
8324
|
+
rasterPaintLayerIds: cr,
|
|
8325
|
+
className: or.className,
|
|
8326
|
+
style: or.style
|
|
7937
8327
|
}),
|
|
7938
|
-
|
|
7939
|
-
map:
|
|
8328
|
+
ir && ir.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
8329
|
+
map: et,
|
|
7940
8330
|
initialCenter: l,
|
|
7941
8331
|
initialZoom: u,
|
|
7942
8332
|
initialPitch: d,
|
|
7943
8333
|
initialBearing: f,
|
|
7944
|
-
duration:
|
|
7945
|
-
className:
|
|
7946
|
-
style:
|
|
8334
|
+
duration: ir.duration,
|
|
8335
|
+
className: ir.className,
|
|
8336
|
+
style: ir.style
|
|
7947
8337
|
})
|
|
7948
8338
|
]
|
|
7949
8339
|
}),
|
|
7950
|
-
!(
|
|
7951
|
-
ref:
|
|
7952
|
-
map:
|
|
8340
|
+
!(sr && sr.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
8341
|
+
ref: Ue,
|
|
8342
|
+
map: et,
|
|
7953
8343
|
showButton: !1
|
|
7954
8344
|
}),
|
|
7955
|
-
B &&
|
|
8345
|
+
B && qe.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7956
8346
|
popupState: B,
|
|
7957
|
-
onClose: () =>
|
|
7958
|
-
portalContainer:
|
|
7959
|
-
popupRef:
|
|
8347
|
+
onClose: () => Ot(B.entityId),
|
|
8348
|
+
portalContainer: qe.current,
|
|
8349
|
+
popupRef: Je
|
|
7960
8350
|
}),
|
|
7961
|
-
|
|
7962
|
-
menuState:
|
|
7963
|
-
onClose:
|
|
7964
|
-
portalContainer:
|
|
7965
|
-
menuRef:
|
|
8351
|
+
Xe && Qe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
8352
|
+
menuState: Xe,
|
|
8353
|
+
onClose: Pn,
|
|
8354
|
+
portalContainer: Qe.current,
|
|
8355
|
+
menuRef: $e
|
|
7966
8356
|
})
|
|
7967
8357
|
]
|
|
7968
8358
|
});
|
|
7969
8359
|
});
|
|
7970
8360
|
Mapbox.displayName = "Mapbox";
|
|
7971
|
-
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 };
|