bbl-mapbox-react 0.0.31 → 0.0.33
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/Mapbox.d.ts +2 -0
- 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 +928 -551
- package/dist/types.d.ts +30 -1
- package/dist/utils/measure.d.ts +3 -0
- 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,12 +4802,43 @@ 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
|
-
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"
|
|
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";
|
|
4811
|
+
function computeEntityArea(e) {
|
|
4812
|
+
if (e.type === "circle") return formatArea(Math.PI * e.radius * e.radius);
|
|
4813
|
+
if (e.type === "square") return formatArea(e.length * e.length);
|
|
4814
|
+
if (e.type === "rectangle") {
|
|
4815
|
+
let [[t, n], [r, i]] = e.bounds, a = [Math.min(t, r), Math.max(n, i)], o = [Math.max(t, r), Math.max(n, i)], s = [Math.max(t, r), Math.min(n, i)], c = distance(a, o), l = distance(o, s);
|
|
4816
|
+
return formatArea(c * l);
|
|
4817
|
+
}
|
|
4818
|
+
if (e.type === "polygon") {
|
|
4819
|
+
let t = [...e.coordinates, e.coordinates[0]];
|
|
4820
|
+
return formatArea(polygonArea(t));
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
function computeEntityLengthOrRadius(e) {
|
|
4824
|
+
if (e.type === "circle") return formatLength(e.radius);
|
|
4825
|
+
if (e.type === "square") return formatLength(e.length);
|
|
4826
|
+
if (e.type === "rectangle") {
|
|
4827
|
+
let [[t, n], [r, i]] = e.bounds, a = [Math.min(t, r), Math.max(n, i)], o = [Math.max(t, r), Math.max(n, i)], s = [Math.max(t, r), Math.min(n, i)], c = distance(a, o), l = distance(o, s);
|
|
4828
|
+
return formatLength(2 * (c + l));
|
|
4829
|
+
}
|
|
4830
|
+
if (e.type === "polygon") {
|
|
4831
|
+
let t = 0, n = e.coordinates;
|
|
4832
|
+
for (let e = 0; e < n.length; e++) t += distance(n[e], n[(e + 1) % n.length]);
|
|
4833
|
+
return formatLength(t);
|
|
4834
|
+
}
|
|
4835
|
+
if (e.type === "polyline") {
|
|
4836
|
+
let t = 0;
|
|
4837
|
+
for (let n = 0; n < e.coordinates.length - 1; n++) t += distance(e.coordinates[n], e.coordinates[n + 1]);
|
|
4838
|
+
return formatLength(t);
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
var SHAPE_LABELS = {
|
|
4446
4842
|
square: "正方形",
|
|
4447
4843
|
rectangle: "矩形",
|
|
4448
4844
|
circle: "圆形",
|
|
@@ -4497,36 +4893,6 @@ function createSquareCoords(e, t) {
|
|
|
4497
4893
|
[n - s, r + o]
|
|
4498
4894
|
];
|
|
4499
4895
|
}
|
|
4500
|
-
function computeEntityArea(e) {
|
|
4501
|
-
if (e.type === "circle") return formatArea(Math.PI * e.radius * e.radius);
|
|
4502
|
-
if (e.type === "square") return formatArea(e.length * e.length);
|
|
4503
|
-
if (e.type === "rectangle") {
|
|
4504
|
-
let [[t, n], [r, i]] = e.bounds, a = [Math.min(t, r), Math.max(n, i)], o = [Math.max(t, r), Math.max(n, i)], s = [Math.max(t, r), Math.min(n, i)], c = distance(a, o), l = distance(o, s);
|
|
4505
|
-
return formatArea(c * l);
|
|
4506
|
-
}
|
|
4507
|
-
if (e.type === "polygon") {
|
|
4508
|
-
let t = [...e.coordinates, e.coordinates[0]];
|
|
4509
|
-
return formatArea(polygonArea(t));
|
|
4510
|
-
}
|
|
4511
|
-
}
|
|
4512
|
-
function computeEntityLengthOrRadius(e) {
|
|
4513
|
-
if (e.type === "circle") return formatLength(e.radius);
|
|
4514
|
-
if (e.type === "square") return formatLength(e.length);
|
|
4515
|
-
if (e.type === "rectangle") {
|
|
4516
|
-
let [[t, n], [r, i]] = e.bounds, a = [Math.min(t, r), Math.max(n, i)], o = [Math.max(t, r), Math.max(n, i)], s = [Math.max(t, r), Math.min(n, i)], c = distance(a, o), l = distance(o, s);
|
|
4517
|
-
return formatLength(2 * (c + l));
|
|
4518
|
-
}
|
|
4519
|
-
if (e.type === "polygon") {
|
|
4520
|
-
let t = 0, n = e.coordinates;
|
|
4521
|
-
for (let e = 0; e < n.length; e++) t += distance(n[e], n[(e + 1) % n.length]);
|
|
4522
|
-
return formatLength(t);
|
|
4523
|
-
}
|
|
4524
|
-
if (e.type === "polyline") {
|
|
4525
|
-
let t = 0;
|
|
4526
|
-
for (let n = 0; n < e.coordinates.length - 1; n++) t += distance(e.coordinates[n], e.coordinates[n + 1]);
|
|
4527
|
-
return formatLength(t);
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
4896
|
var PREVIEW_PREFIX = "measure-";
|
|
4531
4897
|
function addPreviewSource(e, t) {
|
|
4532
4898
|
e.getSource(t) || e.addSource(t, {
|
|
@@ -4693,23 +5059,23 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4693
5059
|
showRadius: r.showRadius ?? !0
|
|
4694
5060
|
} : _, [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
5061
|
N.current = b;
|
|
4696
|
-
let
|
|
4697
|
-
|
|
5062
|
+
let we = useRef(f);
|
|
5063
|
+
we.current = f;
|
|
4698
5064
|
let P = useCallback(() => `measure-${++w.current}`, []);
|
|
4699
5065
|
useEffect(() => {
|
|
4700
5066
|
s?.(f !== null);
|
|
4701
5067
|
}, [f, s]);
|
|
4702
|
-
let
|
|
4703
|
-
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e),
|
|
5068
|
+
let Te = useRef(!1), Ee = useCallback(() => {
|
|
5069
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), Te.current = !0);
|
|
4704
5070
|
}, [e]);
|
|
4705
5071
|
useEffect(() => {
|
|
4706
5072
|
if (!e) return;
|
|
4707
5073
|
let t = () => {
|
|
4708
|
-
initAllPreviewLayers(e),
|
|
5074
|
+
initAllPreviewLayers(e), Te.current = !0;
|
|
4709
5075
|
};
|
|
4710
5076
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
4711
5077
|
let n = () => {
|
|
4712
|
-
|
|
5078
|
+
Te.current = !1;
|
|
4713
5079
|
};
|
|
4714
5080
|
return e.on("style.load", n), () => {
|
|
4715
5081
|
if (e) try {
|
|
@@ -4735,12 +5101,12 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4735
5101
|
};
|
|
4736
5102
|
S((t) => [...t, e]);
|
|
4737
5103
|
}
|
|
4738
|
-
}, [e]),
|
|
5104
|
+
}, [e]), De = useCallback((e) => {
|
|
4739
5105
|
let t = C.current.get(e);
|
|
4740
5106
|
t && (t.destroy(), C.current.delete(e)), S((t) => t.filter((t) => t.entity.id !== e));
|
|
4741
|
-
}, []),
|
|
5107
|
+
}, []), Oe = useCallback(() => {
|
|
4742
5108
|
C.current.forEach((e) => e.destroy()), C.current.clear(), S([]);
|
|
4743
|
-
}, []),
|
|
5109
|
+
}, []), ke = useCallback((t) => {
|
|
4744
5110
|
if (!e) return;
|
|
4745
5111
|
let n = C.current.get(t);
|
|
4746
5112
|
if (!n) return;
|
|
@@ -4750,7 +5116,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4750
5116
|
maxZoom: 18,
|
|
4751
5117
|
duration: 1e3
|
|
4752
5118
|
});
|
|
4753
|
-
}, [e]),
|
|
5119
|
+
}, [e]), Ae = useCallback((e, t) => {
|
|
4754
5120
|
let n = {
|
|
4755
5121
|
...N.current,
|
|
4756
5122
|
[e]: t
|
|
@@ -4764,7 +5130,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4764
5130
|
entity: i
|
|
4765
5131
|
};
|
|
4766
5132
|
}));
|
|
4767
|
-
}, [y, i]),
|
|
5133
|
+
}, [y, i]), je = useCallback((t, n) => {
|
|
4768
5134
|
if (!e) return;
|
|
4769
5135
|
let [r, i] = t, [a, o] = n, s = [
|
|
4770
5136
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -4814,7 +5180,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4814
5180
|
features: t
|
|
4815
5181
|
});
|
|
4816
5182
|
}
|
|
4817
|
-
}, [e]),
|
|
5183
|
+
}, [e]), Me = useCallback((t, n) => {
|
|
4818
5184
|
if (!e) return;
|
|
4819
5185
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
4820
5186
|
a && a.setData({
|
|
@@ -4861,7 +5227,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4861
5227
|
type: "FeatureCollection",
|
|
4862
5228
|
features: c
|
|
4863
5229
|
});
|
|
4864
|
-
}, [e]),
|
|
5230
|
+
}, [e]), Ne = useCallback((t, n) => {
|
|
4865
5231
|
if (!e) return;
|
|
4866
5232
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
4867
5233
|
a && a.setData({
|
|
@@ -4975,7 +5341,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
4975
5341
|
features: t
|
|
4976
5342
|
});
|
|
4977
5343
|
}
|
|
4978
|
-
}, [e]),
|
|
5344
|
+
}, [e]), Pe = useCallback((t, n) => {
|
|
4979
5345
|
if (!e) return;
|
|
4980
5346
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
4981
5347
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -5023,9 +5389,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5023
5389
|
}, [e]);
|
|
5024
5390
|
useEffect(() => {
|
|
5025
5391
|
if (!e || !f) return;
|
|
5026
|
-
|
|
5392
|
+
Ee(), e.getCanvas().style.cursor = "crosshair";
|
|
5027
5393
|
let t = (t) => {
|
|
5028
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
5394
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = we.current;
|
|
5029
5395
|
if (r === "rectangle") {
|
|
5030
5396
|
let t = D.current;
|
|
5031
5397
|
if (!t) D.current = n;
|
|
@@ -5075,20 +5441,20 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5075
5441
|
j.current = [...t, n];
|
|
5076
5442
|
} else r === "polyline" && (M.current = [...M.current, n]);
|
|
5077
5443
|
}, 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)
|
|
5444
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = we.current;
|
|
5445
|
+
if (n === "rectangle" && D.current) je(D.current, t);
|
|
5446
|
+
else if (n === "circle" && O.current) Me(O.current.center, t);
|
|
5447
|
+
else if (n === "square" && k.current) Ne(k.current.center, t);
|
|
5082
5448
|
else if (n === "polygon") {
|
|
5083
5449
|
let e = j.current;
|
|
5084
5450
|
e.length > 0 && I(e, t);
|
|
5085
5451
|
} else if (n === "polyline") {
|
|
5086
5452
|
let e = M.current;
|
|
5087
|
-
e.length > 0 &&
|
|
5453
|
+
e.length > 0 && Pe(e, t);
|
|
5088
5454
|
}
|
|
5089
5455
|
}, r = (t) => {
|
|
5090
5456
|
t.preventDefault();
|
|
5091
|
-
let n =
|
|
5457
|
+
let n = we.current;
|
|
5092
5458
|
if (n === "polygon") {
|
|
5093
5459
|
let t = j.current;
|
|
5094
5460
|
if (t.length >= 3) {
|
|
@@ -5114,7 +5480,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5114
5480
|
t.key === "Escape" && (D.current = null, O.current = null, k.current = null, j.current = [], M.current = [], clearAllPreviewSources(e), p(null));
|
|
5115
5481
|
}, a = (t) => {
|
|
5116
5482
|
t.preventDefault();
|
|
5117
|
-
let n =
|
|
5483
|
+
let n = we.current;
|
|
5118
5484
|
if (n === "polygon") {
|
|
5119
5485
|
let t = j.current;
|
|
5120
5486
|
if (t.length >= 3) {
|
|
@@ -5147,16 +5513,16 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5147
5513
|
f,
|
|
5148
5514
|
P,
|
|
5149
5515
|
F,
|
|
5150
|
-
|
|
5151
|
-
Ae,
|
|
5516
|
+
Ee,
|
|
5152
5517
|
je,
|
|
5153
5518
|
Me,
|
|
5519
|
+
Ne,
|
|
5154
5520
|
I,
|
|
5155
|
-
|
|
5521
|
+
Pe
|
|
5156
5522
|
]), useEffect(() => () => {
|
|
5157
5523
|
C.current.forEach((e) => e.destroy()), C.current.clear();
|
|
5158
5524
|
}, []);
|
|
5159
|
-
let
|
|
5525
|
+
let Fe = useCallback((t) => {
|
|
5160
5526
|
p((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null, j.current = [], M.current = [], e && clearAllPreviewSources(e);
|
|
5161
5527
|
}, [e]);
|
|
5162
5528
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -5193,17 +5559,17 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5193
5559
|
children: [
|
|
5194
5560
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5195
5561
|
checked: b.showArea,
|
|
5196
|
-
onChange: (e) =>
|
|
5562
|
+
onChange: (e) => Ae("showArea", e),
|
|
5197
5563
|
children: "面积"
|
|
5198
5564
|
}),
|
|
5199
5565
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5200
5566
|
checked: b.showLength,
|
|
5201
|
-
onChange: (e) =>
|
|
5567
|
+
onChange: (e) => Ae("showLength", e),
|
|
5202
5568
|
children: "长度"
|
|
5203
5569
|
}),
|
|
5204
5570
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
5205
5571
|
checked: b.showRadius,
|
|
5206
|
-
onChange: (e) =>
|
|
5572
|
+
onChange: (e) => Ae("showRadius", e),
|
|
5207
5573
|
children: "半径"
|
|
5208
5574
|
})
|
|
5209
5575
|
]
|
|
@@ -5216,7 +5582,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5216
5582
|
className: "mapbox-measure-control__tools",
|
|
5217
5583
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
5218
5584
|
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5219
|
-
onClick: () =>
|
|
5585
|
+
onClick: () => Fe(e.mode),
|
|
5220
5586
|
title: e.label,
|
|
5221
5587
|
children: /* @__PURE__ */ jsx("img", {
|
|
5222
5588
|
src: e.icon,
|
|
@@ -5224,7 +5590,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5224
5590
|
})
|
|
5225
5591
|
}, e.mode)), x.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
5226
5592
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
5227
|
-
onClick:
|
|
5593
|
+
onClick: Oe,
|
|
5228
5594
|
title: "清除全部",
|
|
5229
5595
|
children: /* @__PURE__ */ jsx("img", {
|
|
5230
5596
|
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 +5610,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5244
5610
|
/* @__PURE__ */ jsx("th", {})
|
|
5245
5611
|
] }) }), /* @__PURE__ */ jsx("tbody", { children: x.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
5246
5612
|
className: "mapbox-measure-control__table-row",
|
|
5247
|
-
onClick: () =>
|
|
5613
|
+
onClick: () => ke(e.entity.id),
|
|
5248
5614
|
children: [
|
|
5249
5615
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
5250
5616
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -5253,7 +5619,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDr
|
|
|
5253
5619
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
5254
5620
|
className: "mapbox-measure-control__delete-btn",
|
|
5255
5621
|
onClick: (t) => {
|
|
5256
|
-
t.stopPropagation(),
|
|
5622
|
+
t.stopPropagation(), De(e.entity.id);
|
|
5257
5623
|
},
|
|
5258
5624
|
title: "删除",
|
|
5259
5625
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -5348,7 +5714,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5348
5714
|
x,
|
|
5349
5715
|
p,
|
|
5350
5716
|
C
|
|
5351
|
-
]),
|
|
5717
|
+
]), ye = useCallback(() => {
|
|
5352
5718
|
b ? s?.({ ...DEFAULT_CONFIG }) : (g({ ...DEFAULT_CONFIG }), C({ ...DEFAULT_CONFIG }));
|
|
5353
5719
|
}, [
|
|
5354
5720
|
b,
|
|
@@ -5403,7 +5769,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
|
|
|
5403
5769
|
]
|
|
5404
5770
|
}, e)), /* @__PURE__ */ jsx("button", {
|
|
5405
5771
|
className: "mapbox-raster-paint-control__reset",
|
|
5406
|
-
onClick:
|
|
5772
|
+
onClick: ye,
|
|
5407
5773
|
children: "重置"
|
|
5408
5774
|
})]
|
|
5409
5775
|
})]
|
|
@@ -5432,13 +5798,13 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5432
5798
|
i === "polyline" ? s(null) : (r(null), s("polyline"));
|
|
5433
5799
|
}, w = () => {
|
|
5434
5800
|
(i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), g(!p);
|
|
5435
|
-
},
|
|
5801
|
+
}, ye = (e) => e.size ? {
|
|
5436
5802
|
width: e.size,
|
|
5437
5803
|
height: e.size
|
|
5438
5804
|
} : {
|
|
5439
5805
|
width: e.width || 32,
|
|
5440
5806
|
height: e.height || 32
|
|
5441
|
-
}, T = p || t, E = i === "rectangle", D = i === "circle", O = i === "polygon",
|
|
5807
|
+
}, T = p || t, E = i === "rectangle", D = i === "circle", O = i === "polygon", be = i === "square", xe = i === "polyline";
|
|
5442
5808
|
return /* @__PURE__ */ jsxs("div", {
|
|
5443
5809
|
ref: _,
|
|
5444
5810
|
className: "mapbox-edit-control",
|
|
@@ -5460,7 +5826,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5460
5826
|
}), /* @__PURE__ */ jsx("span", { children: t ? t.name : "Marker" })]
|
|
5461
5827
|
}),
|
|
5462
5828
|
d && /* @__PURE__ */ jsxs("button", {
|
|
5463
|
-
className: `mapbox-control-btn ${
|
|
5829
|
+
className: `mapbox-control-btn ${be ? "mapbox-control-btn--active" : ""}`,
|
|
5464
5830
|
onClick: S,
|
|
5465
5831
|
title: "绘制正方形",
|
|
5466
5832
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -5500,7 +5866,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5500
5866
|
}), /* @__PURE__ */ jsx("span", { children: "多边形" })]
|
|
5501
5867
|
}),
|
|
5502
5868
|
f && /* @__PURE__ */ jsxs("button", {
|
|
5503
|
-
className: `mapbox-control-btn ${
|
|
5869
|
+
className: `mapbox-control-btn ${xe ? "mapbox-control-btn--active" : ""}`,
|
|
5504
5870
|
onClick: C,
|
|
5505
5871
|
title: "绘制折线",
|
|
5506
5872
|
children: [/* @__PURE__ */ jsx("img", {
|
|
@@ -5518,7 +5884,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5518
5884
|
}), /* @__PURE__ */ jsx("div", {
|
|
5519
5885
|
className: "mapbox-edit-control__template-list",
|
|
5520
5886
|
children: e.map((e) => {
|
|
5521
|
-
let n =
|
|
5887
|
+
let n = ye(e), r = t?.id === e.id;
|
|
5522
5888
|
return /* @__PURE__ */ jsxs("div", {
|
|
5523
5889
|
className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
|
|
5524
5890
|
onClick: () => v(e),
|
|
@@ -5590,7 +5956,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
5590
5956
|
};
|
|
5591
5957
|
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
5958
|
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),
|
|
5959
|
+
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
5960
|
useEffect(() => {
|
|
5595
5961
|
E.current = p;
|
|
5596
5962
|
}, [p]), useEffect(() => {
|
|
@@ -5606,12 +5972,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5606
5972
|
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
5607
5973
|
};
|
|
5608
5974
|
}, [x]);
|
|
5609
|
-
let
|
|
5975
|
+
let be = useCallback(() => {
|
|
5610
5976
|
for (let e of T.current) e.remove();
|
|
5611
5977
|
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]),
|
|
5978
|
+
}, [e]), xe = useCallback(() => {
|
|
5613
5979
|
if (!e) return;
|
|
5614
|
-
let t =
|
|
5980
|
+
let t = ye.current, n = {
|
|
5615
5981
|
type: "FeatureCollection",
|
|
5616
5982
|
features: [{
|
|
5617
5983
|
type: "Feature",
|
|
@@ -5667,18 +6033,18 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5667
6033
|
let { visualType: n } = D.current;
|
|
5668
6034
|
if (n === "marker") {
|
|
5669
6035
|
let n = document.createElement("div");
|
|
5670
|
-
n.className = "route-planning-temp-marker", n.textContent = String(
|
|
6036
|
+
n.className = "route-planning-temp-marker", n.textContent = String(ye.current.length);
|
|
5671
6037
|
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5672
6038
|
T.current.push(r);
|
|
5673
|
-
} else
|
|
5674
|
-
}, [e,
|
|
5675
|
-
if (
|
|
6039
|
+
} else xe();
|
|
6040
|
+
}, [e, xe]), Se = useCallback(() => {
|
|
6041
|
+
if (be(), ye.current = [], D.current = null, v(0), g("idle"), e) try {
|
|
5676
6042
|
e.getCanvas().style.cursor = O.current;
|
|
5677
6043
|
} catch {}
|
|
5678
|
-
}, [
|
|
5679
|
-
let e = D.current, t = [...
|
|
6044
|
+
}, [be, e]), A = useCallback(async () => {
|
|
6045
|
+
let e = D.current, t = [...ye.current];
|
|
5680
6046
|
if (!e || t.length < 2) {
|
|
5681
|
-
|
|
6047
|
+
Se();
|
|
5682
6048
|
return;
|
|
5683
6049
|
}
|
|
5684
6050
|
g("planning");
|
|
@@ -5687,48 +6053,48 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5687
6053
|
} catch (e) {
|
|
5688
6054
|
console.error("Route planning onSelectFinished failed:", e);
|
|
5689
6055
|
} finally {
|
|
5690
|
-
|
|
6056
|
+
Se();
|
|
5691
6057
|
}
|
|
5692
|
-
}, [
|
|
6058
|
+
}, [Se]), Ce = useCallback((e) => {
|
|
5693
6059
|
if (E.current !== "selecting" || !D.current) return;
|
|
5694
6060
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5695
|
-
|
|
5696
|
-
let n =
|
|
6061
|
+
ye.current.push(t);
|
|
6062
|
+
let n = ye.current.length;
|
|
5697
6063
|
v(n), k(t), n >= D.current.pointCount && A();
|
|
5698
6064
|
}, [k, A]), j = useCallback((e) => {
|
|
5699
|
-
E.current === "selecting" && (e.preventDefault(),
|
|
5700
|
-
}, [
|
|
6065
|
+
E.current === "selecting" && (e.preventDefault(), Se());
|
|
6066
|
+
}, [Se]);
|
|
5701
6067
|
useEffect(() => {
|
|
5702
|
-
if (e && p === "selecting") return e.on("click",
|
|
6068
|
+
if (e && p === "selecting") return e.on("click", Ce), e.on("contextmenu", j), () => {
|
|
5703
6069
|
if (e) try {
|
|
5704
|
-
e.off("click",
|
|
6070
|
+
e.off("click", Ce), e.off("contextmenu", j);
|
|
5705
6071
|
} catch {}
|
|
5706
6072
|
};
|
|
5707
6073
|
}, [
|
|
5708
6074
|
e,
|
|
5709
6075
|
p,
|
|
5710
|
-
|
|
6076
|
+
Ce,
|
|
5711
6077
|
j
|
|
5712
6078
|
]);
|
|
5713
6079
|
let M = useCallback((t) => {
|
|
5714
6080
|
if (!e) return;
|
|
5715
|
-
E.current !== "idle" &&
|
|
6081
|
+
E.current !== "idle" && Se();
|
|
5716
6082
|
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5717
6083
|
D.current = {
|
|
5718
6084
|
pointCount: n,
|
|
5719
6085
|
visualType: r,
|
|
5720
6086
|
onSelectFinished: t.onSelectFinished
|
|
5721
|
-
},
|
|
6087
|
+
}, ye.current = [], v(0), b(n), S(!1), O.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", g("selecting");
|
|
5722
6088
|
}, [
|
|
5723
6089
|
e,
|
|
5724
6090
|
i,
|
|
5725
6091
|
l,
|
|
5726
|
-
|
|
6092
|
+
Se
|
|
5727
6093
|
]);
|
|
5728
6094
|
useImperativeHandle(f, () => ({ startPlanning: M }), [M]);
|
|
5729
6095
|
let N = () => {
|
|
5730
|
-
p === "idle" ? S((e) => !e) : p === "selecting" &&
|
|
5731
|
-
},
|
|
6096
|
+
p === "idle" ? S((e) => !e) : p === "selecting" && Se();
|
|
6097
|
+
}, we = () => {
|
|
5732
6098
|
u && M({
|
|
5733
6099
|
pointCount: Math.max(2, y),
|
|
5734
6100
|
visualType: l,
|
|
@@ -5737,7 +6103,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5737
6103
|
}, P = (e) => {
|
|
5738
6104
|
let t = parseInt(e.target.value, 10);
|
|
5739
6105
|
!isNaN(t) && t >= 2 ? b(t) : e.target.value === "" && b(2);
|
|
5740
|
-
},
|
|
6106
|
+
}, Te = () => {
|
|
5741
6107
|
if (p === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5742
6108
|
if (p === "selecting") {
|
|
5743
6109
|
let e = D.current?.pointCount ?? y;
|
|
@@ -5748,12 +6114,12 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5748
6114
|
] });
|
|
5749
6115
|
}
|
|
5750
6116
|
return "路径规划";
|
|
5751
|
-
},
|
|
6117
|
+
}, Ee = p === "selecting", F = p === "planning";
|
|
5752
6118
|
return !d && p === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5753
6119
|
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5754
6120
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
5755
6121
|
ref: C,
|
|
5756
|
-
className: `mapbox-control-btn mapbox-route-planning-control__btn${
|
|
6122
|
+
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
6123
|
onClick: N,
|
|
5758
6124
|
disabled: F,
|
|
5759
6125
|
title: p === "idle" ? "路径规划" : p === "selecting" ? "取消选点" : "规划中...",
|
|
@@ -5761,7 +6127,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5761
6127
|
src: route_planning_default,
|
|
5762
6128
|
alt: "route",
|
|
5763
6129
|
className: "mapbox-route-planning-control__btn-icon"
|
|
5764
|
-
}),
|
|
6130
|
+
}), Te()]
|
|
5765
6131
|
}), x && p === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5766
6132
|
ref: w,
|
|
5767
6133
|
className: "mapbox-route-planning-control__panel",
|
|
@@ -5796,7 +6162,7 @@ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointC
|
|
|
5796
6162
|
}),
|
|
5797
6163
|
/* @__PURE__ */ jsx("button", {
|
|
5798
6164
|
className: "mapbox-route-planning-control__panel-start",
|
|
5799
|
-
onClick:
|
|
6165
|
+
onClick: we,
|
|
5800
6166
|
disabled: !u,
|
|
5801
6167
|
children: "开始规划"
|
|
5802
6168
|
})
|
|
@@ -5832,7 +6198,17 @@ function calculatePopupPosition(e, t, n, r, i) {
|
|
|
5832
6198
|
let [[t, n], [r, i]] = e.bounds;
|
|
5833
6199
|
o = [(t + r) / 2, (n + i) / 2];
|
|
5834
6200
|
}
|
|
5835
|
-
else
|
|
6201
|
+
else if (e.type === "attack-direction") {
|
|
6202
|
+
let t = e.coordinates;
|
|
6203
|
+
o = e.center ?? [(t[0][0] + t[1][0] + t[2][0]) / 3, (t[0][1] + t[1][1] + t[2][1]) / 3];
|
|
6204
|
+
} else o = e.center;
|
|
6205
|
+
if (!o) return {
|
|
6206
|
+
position: {
|
|
6207
|
+
x: 0,
|
|
6208
|
+
y: 0
|
|
6209
|
+
},
|
|
6210
|
+
actualPosition: t.position
|
|
6211
|
+
};
|
|
5836
6212
|
let s = n.project(o);
|
|
5837
6213
|
a = {
|
|
5838
6214
|
x: s.x,
|
|
@@ -5953,13 +6329,13 @@ function adjustPopupForBounds(e, t) {
|
|
|
5953
6329
|
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
6330
|
}
|
|
5955
6331
|
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
|
-
|
|
6332
|
+
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([]);
|
|
6333
|
+
St.current = bt;
|
|
5958
6334
|
let q = useRef(null);
|
|
5959
6335
|
useEffect(() => {
|
|
5960
|
-
|
|
6336
|
+
nt(_);
|
|
5961
6337
|
}, [_]);
|
|
5962
|
-
let
|
|
6338
|
+
let Ct = useCallback((e) => {
|
|
5963
6339
|
let t = R.current.get(e), n = z.current.get(e);
|
|
5964
6340
|
if (t && n) {
|
|
5965
6341
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
@@ -5976,7 +6352,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5976
6352
|
z.current.set(e, r), t.startAnimation();
|
|
5977
6353
|
}
|
|
5978
6354
|
}
|
|
5979
|
-
}, []),
|
|
6355
|
+
}, []), wt = useCallback((e) => {
|
|
5980
6356
|
let t = R.current.get(e), n = z.current.get(e);
|
|
5981
6357
|
if (t && n) {
|
|
5982
6358
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
@@ -5993,10 +6369,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5993
6369
|
z.current.set(e, r), t.stopAnimation();
|
|
5994
6370
|
}
|
|
5995
6371
|
}
|
|
5996
|
-
}, []),
|
|
6372
|
+
}, []), Tt = useCallback((e) => {
|
|
5997
6373
|
let t = z.current.get(e);
|
|
5998
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
5999
|
-
}, [
|
|
6374
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? wt(e) : Ct(e));
|
|
6375
|
+
}, [Ct, wt]), Et = useCallback((e) => {
|
|
6000
6376
|
if (e === void 0) {
|
|
6001
6377
|
let e = !1;
|
|
6002
6378
|
for (let [, t] of R.current) if (t instanceof UnitRenderer) {
|
|
@@ -6012,36 +6388,36 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6012
6388
|
let t = new Set(e.map(String));
|
|
6013
6389
|
for (let [e, n] of R.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
6014
6390
|
}
|
|
6015
|
-
}, []),
|
|
6391
|
+
}, []), Dt = useCallback((e, t, n) => {
|
|
6016
6392
|
let r = T.find((t) => String(t.id) === String(e));
|
|
6017
6393
|
if (!r?.popup || !L.current) return;
|
|
6018
|
-
let i = r.popup.content ??
|
|
6394
|
+
let i = r.popup.content ?? Fe?.(r);
|
|
6019
6395
|
if (!i) return;
|
|
6020
6396
|
let a = mergePopupConfig(r.popup, I, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, L.current, n);
|
|
6021
|
-
|
|
6397
|
+
Ke({
|
|
6022
6398
|
entityId: e,
|
|
6023
6399
|
position: o,
|
|
6024
6400
|
config: a,
|
|
6025
6401
|
openedBy: t,
|
|
6026
6402
|
actualPosition: s
|
|
6027
|
-
}),
|
|
6403
|
+
}), Re?.(e);
|
|
6028
6404
|
}, [
|
|
6029
6405
|
T,
|
|
6030
6406
|
I,
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
]),
|
|
6034
|
-
B?.entityId === e && (
|
|
6035
|
-
}, [B,
|
|
6036
|
-
|
|
6037
|
-
}, [
|
|
6407
|
+
Fe,
|
|
6408
|
+
Re
|
|
6409
|
+
]), Ot = useCallback((e) => {
|
|
6410
|
+
B?.entityId === e && (Ke(null), ze?.(e));
|
|
6411
|
+
}, [B, ze]), kt = useCallback(() => {
|
|
6412
|
+
Ke((e) => (e && ze?.(e.entityId), null));
|
|
6413
|
+
}, [ze]), At = useCallback((e) => B?.entityId === e, [B]), jt = useCallback((e, t, n) => {
|
|
6038
6414
|
let r = L.current;
|
|
6039
6415
|
r && r.flyTo({
|
|
6040
6416
|
center: e,
|
|
6041
6417
|
zoom: t ?? r.getZoom(),
|
|
6042
6418
|
...n
|
|
6043
6419
|
});
|
|
6044
|
-
}, []),
|
|
6420
|
+
}, []), Mt = useCallback((e) => {
|
|
6045
6421
|
if (e.length === 0) return null;
|
|
6046
6422
|
let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity, a = !1;
|
|
6047
6423
|
for (let o of e) {
|
|
@@ -6052,10 +6428,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6052
6428
|
}
|
|
6053
6429
|
}
|
|
6054
6430
|
return a ? [(t + n) / 2, (r + i) / 2] : null;
|
|
6055
|
-
}, []),
|
|
6431
|
+
}, []), Nt = useCallback((e, t, n) => {
|
|
6056
6432
|
let r = L.current;
|
|
6057
6433
|
if (!r || e.length === 0) return;
|
|
6058
|
-
let i =
|
|
6434
|
+
let i = Mt(e);
|
|
6059
6435
|
if (!i) return;
|
|
6060
6436
|
let a = [];
|
|
6061
6437
|
for (let t of e) {
|
|
@@ -6080,20 +6456,20 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6080
6456
|
pitch: n?.pitch ?? r.getPitch()
|
|
6081
6457
|
};
|
|
6082
6458
|
t !== void 0 && (f.maxZoom = t), n?.essential !== void 0 && (f.essential = n.essential), r.fitBounds(d, f);
|
|
6083
|
-
}, [
|
|
6459
|
+
}, [Mt]), Pt = useRef(null), Ft = useRef("display"), [It, Lt] = useState({}), J = useMemo(() => ({
|
|
6084
6460
|
...y,
|
|
6085
|
-
...
|
|
6086
|
-
}), [y,
|
|
6461
|
+
...It
|
|
6462
|
+
}), [y, It]), Rt = useCallback((e) => {
|
|
6087
6463
|
let t = L.current;
|
|
6088
6464
|
if (!t || !t.getContainer()) return;
|
|
6089
6465
|
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = J;
|
|
6090
6466
|
if (!n) {
|
|
6091
|
-
|
|
6467
|
+
at.current &&= (at.current.remove(), null);
|
|
6092
6468
|
return;
|
|
6093
6469
|
}
|
|
6094
|
-
if (
|
|
6095
|
-
|
|
6096
|
-
let t =
|
|
6470
|
+
if (at.current) {
|
|
6471
|
+
at.current.setLngLat(e);
|
|
6472
|
+
let t = at.current.getElement(), n = t.querySelector(".marker-label");
|
|
6097
6473
|
if (i) {
|
|
6098
6474
|
let e = resolveNameConfig(a, O);
|
|
6099
6475
|
if (n) n.textContent = i, n.style.color = e.fillColor, n.style.opacity = String(e.fillOpacity), n.style.webkitTextStrokeColor = e.strokeColor, n.style.webkitTextStrokeWidth = `${e.strokeWidth}px`;
|
|
@@ -6110,38 +6486,38 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6110
6486
|
let e = resolveNameConfig(a, O), t = document.createElement("div");
|
|
6111
6487
|
t.className = "marker-label", t.textContent = i, t.style.color = e.fillColor, t.style.opacity = String(e.fillOpacity), t.style.webkitTextStrokeColor = e.strokeColor, t.style.webkitTextStrokeWidth = `${e.strokeWidth}px`, n.appendChild(t);
|
|
6112
6488
|
}
|
|
6113
|
-
|
|
6489
|
+
at.current = new mapboxgl.Marker({
|
|
6114
6490
|
element: n,
|
|
6115
6491
|
anchor: "bottom"
|
|
6116
6492
|
}).setLngLat(e).addTo(t);
|
|
6117
6493
|
}
|
|
6118
|
-
}, [J, O]),
|
|
6119
|
-
|
|
6120
|
-
}, []),
|
|
6494
|
+
}, [J, O]), zt = useCallback(() => {
|
|
6495
|
+
at.current &&= (at.current.remove(), null);
|
|
6496
|
+
}, []), Bt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Vt = useCallback((e) => {
|
|
6121
6497
|
let t = L.current;
|
|
6122
|
-
if (
|
|
6498
|
+
if (He.current) if (vt.current &&= (vt.current.remove(), null), e && t) {
|
|
6123
6499
|
t.getCanvas().style.cursor = "none";
|
|
6124
6500
|
let n = document.createElement("div");
|
|
6125
6501
|
n.className = "mapbox-custom-cursor";
|
|
6126
6502
|
let r = e.size || e.width || 32;
|
|
6127
6503
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
6128
6504
|
let i = document.createElement("img");
|
|
6129
|
-
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n),
|
|
6505
|
+
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n), vt.current = n;
|
|
6130
6506
|
let a = (e) => {
|
|
6131
|
-
|
|
6507
|
+
vt.current && (vt.current.style.left = `${e.clientX}px`, vt.current.style.top = `${e.clientY}px`);
|
|
6132
6508
|
};
|
|
6133
6509
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
6134
6510
|
document.removeEventListener("mousemove", a);
|
|
6135
6511
|
};
|
|
6136
6512
|
} else t && (t.getCanvas().style.cursor = "");
|
|
6137
6513
|
}, []), Y = useCallback(() => {
|
|
6138
|
-
if (
|
|
6139
|
-
let e =
|
|
6140
|
-
e && e(),
|
|
6514
|
+
if (vt.current) {
|
|
6515
|
+
let e = vt.current._cleanup;
|
|
6516
|
+
e && e(), vt.current.remove(), vt.current = null;
|
|
6141
6517
|
}
|
|
6142
6518
|
let e = L.current;
|
|
6143
6519
|
e && (e.getCanvas().style.cursor = "");
|
|
6144
|
-
}, []),
|
|
6520
|
+
}, []), Ht = useCallback((e, t, n) => {
|
|
6145
6521
|
if (!e.getSource(t)) {
|
|
6146
6522
|
if (!e.getStyle().glyphs) {
|
|
6147
6523
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -6177,7 +6553,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6177
6553
|
}
|
|
6178
6554
|
});
|
|
6179
6555
|
}
|
|
6180
|
-
}, []),
|
|
6556
|
+
}, []), Ut = useCallback(() => {
|
|
6181
6557
|
let e = L.current;
|
|
6182
6558
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
6183
6559
|
type: "geojson",
|
|
@@ -6202,8 +6578,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6202
6578
|
"line-width": 2,
|
|
6203
6579
|
"line-dasharray": [4, 4]
|
|
6204
6580
|
}
|
|
6205
|
-
}),
|
|
6206
|
-
}, [
|
|
6581
|
+
}), Ht(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6582
|
+
}, [Ht]), Wt = useCallback((e, t) => {
|
|
6207
6583
|
let n = L.current;
|
|
6208
6584
|
if (!n) return;
|
|
6209
6585
|
let r = n.getSource("rect-preview-source");
|
|
@@ -6223,11 +6599,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6223
6599
|
},
|
|
6224
6600
|
properties: {}
|
|
6225
6601
|
});
|
|
6226
|
-
let l =
|
|
6602
|
+
let l = ut.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
6227
6603
|
n.getLayer("rect-preview-line") && (n.setPaintProperty("rect-preview-line", "line-color", u), n.setPaintProperty("rect-preview-line", "line-width", d)), n.getLayer("rect-preview-fill") && (n.setPaintProperty("rect-preview-fill", "fill-color", f), n.setPaintProperty("rect-preview-fill", "fill-opacity", p));
|
|
6228
6604
|
let m = n.getSource("rect-preview-measure-source");
|
|
6229
6605
|
if (m) {
|
|
6230
|
-
let e =
|
|
6606
|
+
let e = Un.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
6231
6607
|
if (e?.showArea) {
|
|
6232
6608
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
6233
6609
|
t.push({
|
|
@@ -6264,7 +6640,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6264
6640
|
features: t
|
|
6265
6641
|
});
|
|
6266
6642
|
}
|
|
6267
|
-
}, []),
|
|
6643
|
+
}, []), Gt = useCallback(() => {
|
|
6268
6644
|
let e = L.current;
|
|
6269
6645
|
if (!e) return;
|
|
6270
6646
|
let t = e.getSource("rect-preview-source");
|
|
@@ -6278,8 +6654,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6278
6654
|
features: []
|
|
6279
6655
|
});
|
|
6280
6656
|
}, []), X = useCallback(() => {
|
|
6281
|
-
|
|
6282
|
-
}, [
|
|
6657
|
+
lt(null), Gt();
|
|
6658
|
+
}, [Gt]), Kt = useCallback(() => {
|
|
6283
6659
|
let e = L.current;
|
|
6284
6660
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
6285
6661
|
type: "geojson",
|
|
@@ -6304,7 +6680,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6304
6680
|
"line-width": 2,
|
|
6305
6681
|
"line-dasharray": [4, 4]
|
|
6306
6682
|
}
|
|
6307
|
-
}),
|
|
6683
|
+
}), Ht(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
6308
6684
|
type: "geojson",
|
|
6309
6685
|
data: {
|
|
6310
6686
|
type: "FeatureCollection",
|
|
@@ -6321,22 +6697,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6321
6697
|
"line-dasharray": [4, 4]
|
|
6322
6698
|
}
|
|
6323
6699
|
}))));
|
|
6324
|
-
}, [
|
|
6700
|
+
}, [Ht]), qt = useCallback((e, t, n = 64) => {
|
|
6325
6701
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
6326
6702
|
for (let e = 0; e <= n; e++) {
|
|
6327
6703
|
let t = e / n * 2 * Math.PI, c = o * Math.cos(t), l = o * Math.sin(t) / Math.cos(s), u = i + c * 180 / Math.PI, d = r + l * 180 / Math.PI;
|
|
6328
6704
|
a.push([d, u]);
|
|
6329
6705
|
}
|
|
6330
6706
|
return a;
|
|
6331
|
-
}, []),
|
|
6707
|
+
}, []), Jt = useCallback((e, t) => {
|
|
6332
6708
|
let [n, r] = e, [i, a] = t, o = (a - r) * Math.PI / 180, s = (i - n) * Math.PI / 180, c = Math.sin(o / 2) * Math.sin(o / 2) + Math.cos(r * Math.PI / 180) * Math.cos(a * Math.PI / 180) * Math.sin(s / 2) * Math.sin(s / 2);
|
|
6333
6709
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
6334
|
-
}, []),
|
|
6710
|
+
}, []), Yt = useCallback((e, t) => {
|
|
6335
6711
|
let n = L.current;
|
|
6336
6712
|
if (!n) return;
|
|
6337
6713
|
let r = n.getSource("circle-preview-source");
|
|
6338
6714
|
if (!r) return;
|
|
6339
|
-
let i =
|
|
6715
|
+
let i = Jt(e, t), a = qt(e, i);
|
|
6340
6716
|
r.setData({
|
|
6341
6717
|
type: "Feature",
|
|
6342
6718
|
geometry: {
|
|
@@ -6347,7 +6723,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6347
6723
|
});
|
|
6348
6724
|
let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6349
6725
|
n.getLayer("circle-preview-line") && (n.setPaintProperty("circle-preview-line", "line-color", s), n.setPaintProperty("circle-preview-line", "line-width", c)), n.getLayer("circle-preview-fill") && (n.setPaintProperty("circle-preview-fill", "fill-color", l), n.setPaintProperty("circle-preview-fill", "fill-opacity", u));
|
|
6350
|
-
let d =
|
|
6726
|
+
let d = Un.current, f = [], p = [];
|
|
6351
6727
|
if (d?.showArea) {
|
|
6352
6728
|
let t = Math.PI * i * i;
|
|
6353
6729
|
f.push({
|
|
@@ -6387,7 +6763,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6387
6763
|
type: "FeatureCollection",
|
|
6388
6764
|
features: p
|
|
6389
6765
|
});
|
|
6390
|
-
}, [
|
|
6766
|
+
}, [Jt, qt]), Xt = useCallback(() => {
|
|
6391
6767
|
let e = L.current;
|
|
6392
6768
|
if (!e) return;
|
|
6393
6769
|
let t = e.getSource("circle-preview-source");
|
|
@@ -6405,9 +6781,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6405
6781
|
type: "FeatureCollection",
|
|
6406
6782
|
features: []
|
|
6407
6783
|
});
|
|
6408
|
-
}, []),
|
|
6409
|
-
|
|
6410
|
-
}, [
|
|
6784
|
+
}, []), Zt = useCallback(() => {
|
|
6785
|
+
ft.current = null, Xt();
|
|
6786
|
+
}, [Xt]), Qt = useCallback(() => {
|
|
6411
6787
|
let e = L.current;
|
|
6412
6788
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
6413
6789
|
type: "geojson",
|
|
@@ -6448,8 +6824,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6448
6824
|
"circle-stroke-color": "#ffffff",
|
|
6449
6825
|
"circle-stroke-width": 2
|
|
6450
6826
|
}
|
|
6451
|
-
}),
|
|
6452
|
-
}, [
|
|
6827
|
+
}), Ht(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6828
|
+
}, [Ht]), $t = useCallback((e, t) => {
|
|
6453
6829
|
let n = L.current;
|
|
6454
6830
|
if (!n) return;
|
|
6455
6831
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
@@ -6491,7 +6867,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6491
6867
|
n.getLayer("polygon-preview-line") && (n.setPaintProperty("polygon-preview-line", "line-color", s), n.setPaintProperty("polygon-preview-line", "line-width", c)), n.getLayer("polygon-preview-fill") && (n.setPaintProperty("polygon-preview-fill", "fill-color", l), n.setPaintProperty("polygon-preview-fill", "fill-opacity", u)), n.getLayer("polygon-vertices") && n.setPaintProperty("polygon-vertices", "circle-color", s);
|
|
6492
6868
|
let d = n.getSource("polygon-preview-measure-source");
|
|
6493
6869
|
if (d) {
|
|
6494
|
-
let e =
|
|
6870
|
+
let e = Un.current, t = [];
|
|
6495
6871
|
if (e?.showArea && a.length >= 3) {
|
|
6496
6872
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
6497
6873
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -6533,7 +6909,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6533
6909
|
features: t
|
|
6534
6910
|
});
|
|
6535
6911
|
}
|
|
6536
|
-
}, []),
|
|
6912
|
+
}, []), en = useCallback(() => {
|
|
6537
6913
|
let e = L.current;
|
|
6538
6914
|
if (!e) return;
|
|
6539
6915
|
let t = e.getSource("polygon-preview-source");
|
|
@@ -6551,9 +6927,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6551
6927
|
type: "FeatureCollection",
|
|
6552
6928
|
features: []
|
|
6553
6929
|
});
|
|
6554
|
-
}, []),
|
|
6555
|
-
|
|
6556
|
-
}, [
|
|
6930
|
+
}, []), tn = useCallback(() => {
|
|
6931
|
+
pt.current = [], en();
|
|
6932
|
+
}, [en]), nn = useCallback(() => {
|
|
6557
6933
|
let e = L.current;
|
|
6558
6934
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
6559
6935
|
type: "geojson",
|
|
@@ -6578,8 +6954,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6578
6954
|
"line-width": 2,
|
|
6579
6955
|
"line-dasharray": [4, 4]
|
|
6580
6956
|
}
|
|
6581
|
-
}),
|
|
6582
|
-
}, [
|
|
6957
|
+
}), Ht(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6958
|
+
}, [Ht]), rn = useCallback((e, t) => {
|
|
6583
6959
|
let [n, r] = e, i = t / 2 / 6371e3, a = r * Math.PI / 180, o = i * 180 / Math.PI, s = i * 180 / Math.PI / Math.cos(a);
|
|
6584
6960
|
return [
|
|
6585
6961
|
[n - s, r + o],
|
|
@@ -6588,12 +6964,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6588
6964
|
[n - s, r - o],
|
|
6589
6965
|
[n - s, r + o]
|
|
6590
6966
|
];
|
|
6591
|
-
}, []),
|
|
6967
|
+
}, []), an = useCallback((e, t) => {
|
|
6592
6968
|
let n = L.current;
|
|
6593
6969
|
if (!n) return;
|
|
6594
6970
|
let r = n.getSource("square-preview-source");
|
|
6595
6971
|
if (!r) return;
|
|
6596
|
-
let i =
|
|
6972
|
+
let i = Jt(e, t) * 2, a = rn(e, i);
|
|
6597
6973
|
r.setData({
|
|
6598
6974
|
type: "Feature",
|
|
6599
6975
|
geometry: {
|
|
@@ -6602,11 +6978,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6602
6978
|
},
|
|
6603
6979
|
properties: {}
|
|
6604
6980
|
});
|
|
6605
|
-
let o =
|
|
6981
|
+
let o = mt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
6606
6982
|
n.getLayer("square-preview-line") && (n.setPaintProperty("square-preview-line", "line-color", s), n.setPaintProperty("square-preview-line", "line-width", c)), n.getLayer("square-preview-fill") && (n.setPaintProperty("square-preview-fill", "fill-color", l), n.setPaintProperty("square-preview-fill", "fill-opacity", u));
|
|
6607
6983
|
let d = n.getSource("square-preview-measure-source");
|
|
6608
6984
|
if (d) {
|
|
6609
|
-
let t =
|
|
6985
|
+
let t = Un.current, n = [];
|
|
6610
6986
|
if (t?.showArea && n.push({
|
|
6611
6987
|
type: "Feature",
|
|
6612
6988
|
geometry: {
|
|
@@ -6630,7 +7006,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6630
7006
|
features: n
|
|
6631
7007
|
});
|
|
6632
7008
|
}
|
|
6633
|
-
}, [
|
|
7009
|
+
}, [Jt, rn]), on = useCallback(() => {
|
|
6634
7010
|
let e = L.current;
|
|
6635
7011
|
if (!e) return;
|
|
6636
7012
|
let t = e.getSource("square-preview-source");
|
|
@@ -6643,9 +7019,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6643
7019
|
type: "FeatureCollection",
|
|
6644
7020
|
features: []
|
|
6645
7021
|
});
|
|
6646
|
-
}, []),
|
|
6647
|
-
|
|
6648
|
-
}, [
|
|
7022
|
+
}, []), sn = useCallback(() => {
|
|
7023
|
+
ht.current = null, on();
|
|
7024
|
+
}, [on]), cn = useCallback(() => {
|
|
6649
7025
|
let e = L.current;
|
|
6650
7026
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
6651
7027
|
type: "geojson",
|
|
@@ -6678,8 +7054,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6678
7054
|
"circle-stroke-color": "#ffffff",
|
|
6679
7055
|
"circle-stroke-width": 2
|
|
6680
7056
|
}
|
|
6681
|
-
}),
|
|
6682
|
-
}, [
|
|
7057
|
+
}), Ht(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
7058
|
+
}, [Ht]), ln = useCallback((e, t) => {
|
|
6683
7059
|
let n = L.current;
|
|
6684
7060
|
if (!n) return;
|
|
6685
7061
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
@@ -6706,11 +7082,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6706
7082
|
properties: {}
|
|
6707
7083
|
}))
|
|
6708
7084
|
});
|
|
6709
|
-
let o =
|
|
7085
|
+
let o = gt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
6710
7086
|
n.getLayer("polyline-preview-line") && (n.setPaintProperty("polyline-preview-line", "line-color", s), n.setPaintProperty("polyline-preview-line", "line-width", c)), n.getLayer("polyline-vertices") && n.setPaintProperty("polyline-vertices", "circle-color", s);
|
|
6711
7087
|
let l = n.getSource("polyline-preview-measure-source");
|
|
6712
7088
|
if (l) {
|
|
6713
|
-
let e =
|
|
7089
|
+
let e = Un.current, t = [];
|
|
6714
7090
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
6715
7091
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
6716
7092
|
t.push({
|
|
@@ -6727,7 +7103,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6727
7103
|
features: t
|
|
6728
7104
|
});
|
|
6729
7105
|
}
|
|
6730
|
-
}, []),
|
|
7106
|
+
}, []), un = useCallback(() => {
|
|
6731
7107
|
let e = L.current;
|
|
6732
7108
|
if (!e) return;
|
|
6733
7109
|
let t = e.getSource("polyline-preview-source");
|
|
@@ -6746,158 +7122,158 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6746
7122
|
features: []
|
|
6747
7123
|
});
|
|
6748
7124
|
}, []), Z = useCallback(() => {
|
|
6749
|
-
|
|
6750
|
-
}, [
|
|
6751
|
-
H(e),
|
|
7125
|
+
_t.current = [], un();
|
|
7126
|
+
}, [un]), dn = useCallback((e) => {
|
|
7127
|
+
H(e), Vt(e), e ? (U("marker"), X(), Zt(), tn(), sn(), Z()) : U(null);
|
|
6752
7128
|
}, [
|
|
6753
|
-
|
|
7129
|
+
Vt,
|
|
6754
7130
|
X,
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
7131
|
+
Zt,
|
|
7132
|
+
tn,
|
|
7133
|
+
sn,
|
|
6758
7134
|
Z
|
|
6759
|
-
]),
|
|
7135
|
+
]), fn = useCallback((e) => {
|
|
6760
7136
|
if (U(e), e === "rectangle") {
|
|
6761
|
-
H(null), Y(),
|
|
7137
|
+
H(null), Y(), Zt(), tn(), sn(), Z();
|
|
6762
7138
|
let e = L.current;
|
|
6763
7139
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6764
7140
|
} else if (e === "circle") {
|
|
6765
|
-
H(null), Y(), X(),
|
|
7141
|
+
H(null), Y(), X(), tn(), sn(), Z();
|
|
6766
7142
|
let e = L.current;
|
|
6767
7143
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6768
7144
|
} else if (e === "polygon") {
|
|
6769
|
-
H(null), Y(), X(),
|
|
7145
|
+
H(null), Y(), X(), Zt(), sn(), Z();
|
|
6770
7146
|
let e = L.current;
|
|
6771
7147
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6772
7148
|
} else if (e === "square") {
|
|
6773
|
-
H(null), Y(), X(),
|
|
7149
|
+
H(null), Y(), X(), Zt(), tn(), Z();
|
|
6774
7150
|
let e = L.current;
|
|
6775
7151
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6776
7152
|
} else if (e === "polyline") {
|
|
6777
|
-
H(null), Y(), X(),
|
|
7153
|
+
H(null), Y(), X(), Zt(), tn(), sn();
|
|
6778
7154
|
let e = L.current;
|
|
6779
7155
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
6780
|
-
} else e === "marker" ? (X(),
|
|
7156
|
+
} else e === "marker" ? (X(), Zt(), tn(), sn(), Z()) : (H(null), Y(), X(), Zt(), tn(), sn(), Z());
|
|
6781
7157
|
}, [
|
|
6782
7158
|
Y,
|
|
6783
7159
|
X,
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
7160
|
+
Zt,
|
|
7161
|
+
tn,
|
|
7162
|
+
sn,
|
|
6787
7163
|
Z
|
|
6788
|
-
]),
|
|
7164
|
+
]), pn = useCallback((e) => {
|
|
6789
7165
|
if (e !== "picker") {
|
|
6790
7166
|
let e = J.value && isFinite(J.value.lng) && isFinite(J.value.lat), t = J.showMarker !== !1;
|
|
6791
|
-
(!e || !t) &&
|
|
7167
|
+
(!e || !t) && zt(), it(null);
|
|
6792
7168
|
}
|
|
6793
|
-
e !== "edit" && (H(null), U(null), X(), Z(), Y()),
|
|
7169
|
+
e !== "edit" && (H(null), U(null), X(), Z(), Y()), nt(e);
|
|
6794
7170
|
}, [
|
|
6795
|
-
|
|
7171
|
+
zt,
|
|
6796
7172
|
Y,
|
|
6797
7173
|
X,
|
|
6798
7174
|
Z
|
|
6799
|
-
]),
|
|
6800
|
-
|
|
6801
|
-
}, [
|
|
6802
|
-
|
|
6803
|
-
})), [
|
|
7175
|
+
]), mn = useCallback(() => V, [V]), hn = useCallback(() => rt, [rt]), gn = useCallback(() => {
|
|
7176
|
+
zt(), it(null);
|
|
7177
|
+
}, [zt]), _n = useCallback((e = {}) => (Pt.current &&= (Pt.current(null), null), new Promise((t) => {
|
|
7178
|
+
Pt.current = t, Ft.current = Rn.current, Lt(e), pn("picker");
|
|
7179
|
+
})), [pn]);
|
|
6804
7180
|
useEffect(() => {
|
|
6805
|
-
if (
|
|
7181
|
+
if (!et) return;
|
|
6806
7182
|
let e = J.value;
|
|
6807
7183
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
6808
7184
|
let t = [e.lng, e.lat];
|
|
6809
|
-
|
|
7185
|
+
it(e), Rt(t);
|
|
6810
7186
|
}
|
|
6811
7187
|
}, [
|
|
6812
7188
|
J.value,
|
|
6813
|
-
|
|
6814
|
-
|
|
7189
|
+
Rt,
|
|
7190
|
+
et
|
|
6815
7191
|
]);
|
|
6816
|
-
let
|
|
6817
|
-
if (
|
|
6818
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
7192
|
+
let vn = (e) => "mode" in e, yn = useCallback((e, t = !0) => {
|
|
7193
|
+
if (nt("edit"), t && (zt(), it(null)), W.current = !0, vn(e)) {
|
|
7194
|
+
if (e.mode === "marker") e.markerStyle ? (dt.current = e.markerStyle, ut.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? Vt({
|
|
6819
7195
|
id: "custom",
|
|
6820
7196
|
name: e.markerStyle.name || "Marker",
|
|
6821
7197
|
icon: e.markerStyle.src,
|
|
6822
7198
|
width: e.markerStyle.width
|
|
6823
|
-
}) : Y()) : e.template && (
|
|
7199
|
+
}) : Y()) : e.template && (dt.current = null, ut.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null, H(e.template), U("marker"), Vt(e.template));
|
|
6824
7200
|
else if (e.mode === "rectangle") {
|
|
6825
|
-
|
|
7201
|
+
ut.current = e.rectangleStyle || null, dt.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null, H(null), U("rectangle"), Y();
|
|
6826
7202
|
let t = L.current;
|
|
6827
7203
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6828
7204
|
} else if (e.mode === "circle") {
|
|
6829
|
-
G.current = e.circleStyle || null,
|
|
7205
|
+
G.current = e.circleStyle || null, ut.current = null, dt.current = null, K.current = null, mt.current = null, gt.current = null, H(null), U("circle"), Y();
|
|
6830
7206
|
let t = L.current;
|
|
6831
7207
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6832
7208
|
} else if (e.mode === "polygon") {
|
|
6833
|
-
K.current = e.polygonStyle || null,
|
|
7209
|
+
K.current = e.polygonStyle || null, ut.current = null, dt.current = null, G.current = null, mt.current = null, gt.current = null, H(null), U("polygon"), Y();
|
|
6834
7210
|
let t = L.current;
|
|
6835
7211
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6836
7212
|
} else if (e.mode === "square") {
|
|
6837
|
-
|
|
7213
|
+
mt.current = e.squareStyle || null, ut.current = null, dt.current = null, G.current = null, K.current = null, gt.current = null, H(null), U("square"), Y();
|
|
6838
7214
|
let t = L.current;
|
|
6839
7215
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6840
7216
|
} else if (e.mode === "polyline") {
|
|
6841
|
-
|
|
7217
|
+
gt.current = e.polylineStyle || null, ut.current = null, dt.current = null, G.current = null, K.current = null, mt.current = null, H(null), U("polyline"), Y();
|
|
6842
7218
|
let t = L.current;
|
|
6843
7219
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
6844
7220
|
}
|
|
6845
|
-
} else H(e), U("marker"),
|
|
7221
|
+
} else H(e), U("marker"), Vt(e), ut.current = null, dt.current = null, G.current = null, K.current = null, mt.current = null, gt.current = null;
|
|
6846
7222
|
}, [
|
|
6847
|
-
|
|
6848
|
-
|
|
7223
|
+
zt,
|
|
7224
|
+
Vt,
|
|
6849
7225
|
Y
|
|
6850
7226
|
]);
|
|
6851
7227
|
useImperativeHandle(c, () => ({
|
|
6852
|
-
startAnimation:
|
|
6853
|
-
stopAnimation:
|
|
6854
|
-
toggleAnimation:
|
|
7228
|
+
startAnimation: Ct,
|
|
7229
|
+
stopAnimation: wt,
|
|
7230
|
+
toggleAnimation: Tt,
|
|
6855
7231
|
getMap: () => L.current,
|
|
6856
|
-
openPopup: (e) =>
|
|
6857
|
-
closePopup:
|
|
6858
|
-
closeAllPopups:
|
|
6859
|
-
isPopupOpen:
|
|
6860
|
-
toggleUnitTrajectory:
|
|
6861
|
-
flyTo:
|
|
6862
|
-
getCenterByIds:
|
|
6863
|
-
flyToEntities:
|
|
6864
|
-
getMode:
|
|
6865
|
-
setMode:
|
|
6866
|
-
getPickedLocation:
|
|
6867
|
-
clearPickedLocation:
|
|
6868
|
-
startDrawing:
|
|
7232
|
+
openPopup: (e) => Dt(e, "programmatic"),
|
|
7233
|
+
closePopup: Ot,
|
|
7234
|
+
closeAllPopups: kt,
|
|
7235
|
+
isPopupOpen: At,
|
|
7236
|
+
toggleUnitTrajectory: Et,
|
|
7237
|
+
flyTo: jt,
|
|
7238
|
+
getCenterByIds: Mt,
|
|
7239
|
+
flyToEntities: Nt,
|
|
7240
|
+
getMode: mn,
|
|
7241
|
+
setMode: pn,
|
|
7242
|
+
getPickedLocation: hn,
|
|
7243
|
+
clearPickedLocation: gn,
|
|
7244
|
+
startDrawing: yn,
|
|
6869
7245
|
getRenderer: (e) => R.current.get(e),
|
|
6870
7246
|
setEditingEntities: (e) => {
|
|
6871
|
-
for (let t of
|
|
7247
|
+
for (let t of St.current) e.map(String).includes(String(t)) || R.current.get(t)?.setEditing?.(!1);
|
|
6872
7248
|
for (let t of e) R.current.get(t)?.setEditing?.(!0);
|
|
6873
|
-
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null),
|
|
7249
|
+
q.current &&= (R.current.get(q.current.entityId)?.cancelEditPreview?.(), null), xt(e);
|
|
6874
7250
|
},
|
|
6875
|
-
getEditingEntities: () =>
|
|
6876
|
-
startPicking:
|
|
7251
|
+
getEditingEntities: () => St.current,
|
|
7252
|
+
startPicking: _n,
|
|
6877
7253
|
startRoutePlanning: (e) => {
|
|
6878
|
-
|
|
7254
|
+
Ue.current?.startPlanning(e);
|
|
6879
7255
|
},
|
|
6880
|
-
getRoadHighlightControl: () =>
|
|
7256
|
+
getRoadHighlightControl: () => We.current
|
|
6881
7257
|
}), [
|
|
6882
|
-
St,
|
|
6883
7258
|
Ct,
|
|
6884
7259
|
wt,
|
|
6885
|
-
|
|
7260
|
+
Tt,
|
|
6886
7261
|
Dt,
|
|
6887
7262
|
Ot,
|
|
6888
7263
|
kt,
|
|
6889
|
-
Tt,
|
|
6890
7264
|
At,
|
|
7265
|
+
Et,
|
|
6891
7266
|
jt,
|
|
6892
7267
|
Mt,
|
|
6893
|
-
|
|
6894
|
-
fn,
|
|
7268
|
+
Nt,
|
|
6895
7269
|
mn,
|
|
7270
|
+
pn,
|
|
6896
7271
|
hn,
|
|
6897
|
-
|
|
6898
|
-
|
|
7272
|
+
gn,
|
|
7273
|
+
yn,
|
|
7274
|
+
_n
|
|
6899
7275
|
]);
|
|
6900
|
-
let
|
|
7276
|
+
let bn = useCallback(() => {
|
|
6901
7277
|
let e = L.current;
|
|
6902
7278
|
if (!e) return;
|
|
6903
7279
|
let t = new Set(T.map((e) => e.id)), n = new Set(R.current.keys());
|
|
@@ -6922,13 +7298,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6922
7298
|
let t = new CircleRenderer(e, n, O, k, j, M);
|
|
6923
7299
|
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
6924
7300
|
}
|
|
6925
|
-
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
7301
|
+
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer || n.type === "attack-direction" && i instanceof AttackDirectionRenderer) && i.update(n);
|
|
6926
7302
|
else {
|
|
6927
7303
|
let t = null;
|
|
6928
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, j, M) : new CircleRenderer(e, n, O, k, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, j, N) : n.type === "polyline"
|
|
7304
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, j, M) : new CircleRenderer(e, n, O, k, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, j, N) : n.type === "polyline" ? t = new PolylineRenderer(e, n, O, k, N) : n.type === "attack-direction" && (t = new AttackDirectionRenderer(e, n, O, k)), t && (R.current.set(n.id, t), t.setSelected(r.has(String(n.id))), St.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
6929
7305
|
}
|
|
6930
7306
|
}
|
|
6931
|
-
for (let e of
|
|
7307
|
+
for (let e of St.current) {
|
|
6932
7308
|
let t = R.current.get(e);
|
|
6933
7309
|
t && t.setEditing?.(!0);
|
|
6934
7310
|
}
|
|
@@ -6941,10 +7317,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6941
7317
|
j,
|
|
6942
7318
|
M,
|
|
6943
7319
|
N
|
|
6944
|
-
]),
|
|
7320
|
+
]), xn = useCallback(() => {
|
|
6945
7321
|
for (let e of R.current.values()) e.destroy();
|
|
6946
7322
|
R.current.clear();
|
|
6947
|
-
}, []),
|
|
7323
|
+
}, []), Sn = useCallback((e) => {
|
|
6948
7324
|
let t = e.getStyle();
|
|
6949
7325
|
if (!t?.layers) return;
|
|
6950
7326
|
let n = [
|
|
@@ -6956,13 +7332,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6956
7332
|
"radar-",
|
|
6957
7333
|
"image-",
|
|
6958
7334
|
"unit-",
|
|
6959
|
-
"marker-"
|
|
7335
|
+
"marker-",
|
|
7336
|
+
"attack-direction-"
|
|
6960
7337
|
];
|
|
6961
7338
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
6962
|
-
}, []),
|
|
7339
|
+
}, []), Cn = useCallback((e) => {
|
|
6963
7340
|
let t = C, n = { "raster-opacity": e.opacity ?? 1 }, r = e.brightness ?? t?.brightness, i = e.saturation ?? t?.saturation, a = e.contrast ?? t?.contrast, o = e.hueRotate ?? t?.hueRotate;
|
|
6964
7341
|
return r !== void 0 && (n["raster-brightness-min"] = 0, n["raster-brightness-max"] = r), i !== void 0 && (n["raster-saturation"] = i), a !== void 0 && (n["raster-contrast"] = a), o !== void 0 && (n["raster-hue-rotate"] = o), n;
|
|
6965
|
-
}, [C]),
|
|
7342
|
+
}, [C]), wn = useCallback((e, t) => {
|
|
6966
7343
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
6967
7344
|
type: "raster",
|
|
6968
7345
|
tiles: [t.url],
|
|
@@ -6972,19 +7349,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6972
7349
|
scheme: t.scheme ?? "xyz"
|
|
6973
7350
|
};
|
|
6974
7351
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
6975
|
-
let a =
|
|
7352
|
+
let a = Sn(e);
|
|
6976
7353
|
e.addLayer({
|
|
6977
7354
|
id: r,
|
|
6978
7355
|
type: "raster",
|
|
6979
7356
|
source: n,
|
|
6980
|
-
paint:
|
|
7357
|
+
paint: Cn(t),
|
|
6981
7358
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
6982
7359
|
}, a);
|
|
6983
|
-
}, [
|
|
7360
|
+
}, [Sn, Cn]), Tn = useCallback(async (e, t) => {
|
|
6984
7361
|
try {
|
|
6985
7362
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
6986
|
-
if (!
|
|
6987
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
7363
|
+
if (!Ge.current.has(t.id)) return;
|
|
7364
|
+
let a = n.format === "pbf" || n.vector_layers, o = Sn(e);
|
|
6988
7365
|
if (a) {
|
|
6989
7366
|
let t = {
|
|
6990
7367
|
type: "vector",
|
|
@@ -7005,21 +7382,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7005
7382
|
id: i,
|
|
7006
7383
|
type: "raster",
|
|
7007
7384
|
source: r,
|
|
7008
|
-
paint:
|
|
7385
|
+
paint: Cn(t),
|
|
7009
7386
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
7010
7387
|
}, o);
|
|
7011
7388
|
} catch (e) {
|
|
7012
7389
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
7013
7390
|
}
|
|
7014
|
-
}, [
|
|
7391
|
+
}, [Sn, Cn]), En = useCallback(async (e, t) => {
|
|
7015
7392
|
try {
|
|
7016
7393
|
let n = await (await fetch(t.url)).json();
|
|
7017
|
-
if (!
|
|
7394
|
+
if (!Ge.current.has(t.id)) return;
|
|
7018
7395
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
7019
7396
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
7020
7397
|
e.getSource(n) || e.addSource(n, i);
|
|
7021
7398
|
}
|
|
7022
|
-
let r =
|
|
7399
|
+
let r = Sn(e);
|
|
7023
7400
|
if (n.layers) for (let i of n.layers) {
|
|
7024
7401
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
7025
7402
|
if (e.getLayer(n)) continue;
|
|
@@ -7030,7 +7407,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7030
7407
|
};
|
|
7031
7408
|
i.type === "raster" && (a.paint = {
|
|
7032
7409
|
...a.paint,
|
|
7033
|
-
...
|
|
7410
|
+
...Cn(t)
|
|
7034
7411
|
}), t.visible === !1 && (a.layout = {
|
|
7035
7412
|
...a.layout,
|
|
7036
7413
|
visibility: "none"
|
|
@@ -7043,50 +7420,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7043
7420
|
} catch (e) {
|
|
7044
7421
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
7045
7422
|
}
|
|
7046
|
-
}, [
|
|
7423
|
+
}, [Sn, Cn]), Dn = useCallback((e, t) => {
|
|
7047
7424
|
let n = e.getStyle();
|
|
7048
7425
|
if (!n) return;
|
|
7049
7426
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
7050
7427
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
7051
7428
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
7052
7429
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
7053
|
-
}, []),
|
|
7430
|
+
}, []), On = useCallback((e) => {
|
|
7054
7431
|
let t = L.current;
|
|
7055
7432
|
if (!t) return;
|
|
7056
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
7057
|
-
for (let e of r) n.has(e) || (
|
|
7433
|
+
let n = new Set(e.map((e) => e.id)), r = Ge.current;
|
|
7434
|
+
for (let e of r) n.has(e) || (Dn(t, e), r.delete(e));
|
|
7058
7435
|
for (let n of e) if (r.has(n.id)) {
|
|
7059
7436
|
let e = `base-layer-${n.id}`;
|
|
7060
7437
|
if (t.getLayer(e)) {
|
|
7061
|
-
let r =
|
|
7438
|
+
let r = Cn(n);
|
|
7062
7439
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
7063
7440
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
7064
7441
|
}
|
|
7065
7442
|
} else switch (r.add(n.id), n.type) {
|
|
7066
7443
|
case "raster":
|
|
7067
|
-
|
|
7444
|
+
wn(t, n);
|
|
7068
7445
|
break;
|
|
7069
7446
|
case "tilejson":
|
|
7070
|
-
|
|
7447
|
+
Tn(t, n);
|
|
7071
7448
|
break;
|
|
7072
7449
|
case "style":
|
|
7073
|
-
|
|
7450
|
+
En(t, n);
|
|
7074
7451
|
break;
|
|
7075
7452
|
default: {
|
|
7076
7453
|
let e = n;
|
|
7077
|
-
e.url &&
|
|
7454
|
+
e.url && wn(t, {
|
|
7078
7455
|
...e,
|
|
7079
7456
|
type: "raster"
|
|
7080
7457
|
});
|
|
7081
7458
|
}
|
|
7082
7459
|
}
|
|
7083
7460
|
}, [
|
|
7084
|
-
Cn,
|
|
7085
7461
|
wn,
|
|
7086
7462
|
Tn,
|
|
7087
7463
|
En,
|
|
7088
|
-
|
|
7089
|
-
|
|
7464
|
+
Dn,
|
|
7465
|
+
Cn
|
|
7466
|
+
]), kn = useCallback((e) => {
|
|
7090
7467
|
let t = e;
|
|
7091
7468
|
for (; t;) {
|
|
7092
7469
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -7094,129 +7471,129 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7094
7471
|
t = t.parentElement;
|
|
7095
7472
|
}
|
|
7096
7473
|
return null;
|
|
7097
|
-
}, []),
|
|
7474
|
+
}, []), An = useCallback((e) => {
|
|
7098
7475
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
7099
7476
|
x: e.point.x,
|
|
7100
7477
|
y: e.point.y
|
|
7101
|
-
}, r =
|
|
7478
|
+
}, r = Rn.current;
|
|
7102
7479
|
if (r === "picker") {
|
|
7103
7480
|
let e = {
|
|
7104
7481
|
lng: t[0],
|
|
7105
7482
|
lat: t[1]
|
|
7106
7483
|
};
|
|
7107
|
-
|
|
7484
|
+
it(e), Rt(t), zn.current?.(e), Pt.current && (Pt.current(e), Pt.current = null, Lt({}), zt(), it(null), pn(Ft.current));
|
|
7108
7485
|
return;
|
|
7109
7486
|
}
|
|
7110
|
-
if (
|
|
7487
|
+
if (yt.current) return;
|
|
7111
7488
|
if (r === "edit") {
|
|
7112
|
-
let e =
|
|
7489
|
+
let e = Vn.current;
|
|
7113
7490
|
if (e === "rectangle") {
|
|
7114
|
-
let e =
|
|
7115
|
-
if (!e)
|
|
7491
|
+
let e = Hn.current;
|
|
7492
|
+
if (!e) lt(t);
|
|
7116
7493
|
else {
|
|
7117
|
-
let n =
|
|
7494
|
+
let n = ut.current, r = applyEntityConfig({
|
|
7118
7495
|
...n,
|
|
7119
|
-
id: n?.id ??
|
|
7496
|
+
id: n?.id ?? Bt(),
|
|
7120
7497
|
type: "rectangle",
|
|
7121
7498
|
bounds: [e, t]
|
|
7122
7499
|
}, D);
|
|
7123
|
-
|
|
7500
|
+
Gt();
|
|
7124
7501
|
let i = L.current;
|
|
7125
7502
|
if (i && !R.current.has(r.id)) {
|
|
7126
7503
|
let e = new RectangleRenderer(i, r, O, k, j, N);
|
|
7127
7504
|
R.current.set(r.id, e);
|
|
7128
7505
|
}
|
|
7129
|
-
Q.current.onRectangleAdd?.(r),
|
|
7506
|
+
Q.current.onRectangleAdd?.(r), lt(null), ut.current = null, W.current && (W.current = !1, U(null), i && (i.getCanvas().style.cursor = ""));
|
|
7130
7507
|
}
|
|
7131
7508
|
return;
|
|
7132
7509
|
}
|
|
7133
7510
|
if (e === "circle") {
|
|
7134
|
-
let e =
|
|
7135
|
-
if (!e)
|
|
7511
|
+
let e = ft.current;
|
|
7512
|
+
if (!e) ft.current = { center: t };
|
|
7136
7513
|
else {
|
|
7137
|
-
let n =
|
|
7514
|
+
let n = Jt(e.center, t), r = G.current, i = applyEntityConfig({
|
|
7138
7515
|
...r,
|
|
7139
|
-
id: r?.id ??
|
|
7516
|
+
id: r?.id ?? Bt(),
|
|
7140
7517
|
type: "circle",
|
|
7141
7518
|
center: e.center,
|
|
7142
7519
|
radius: n
|
|
7143
7520
|
}, D);
|
|
7144
|
-
|
|
7521
|
+
Xt();
|
|
7145
7522
|
let a = L.current;
|
|
7146
7523
|
if (a && !R.current.has(i.id)) {
|
|
7147
7524
|
let e = new CircleRenderer(a, i, O, k, j, M);
|
|
7148
7525
|
R.current.set(i.id, e);
|
|
7149
7526
|
}
|
|
7150
|
-
Q.current.onCircleAdd?.(i),
|
|
7527
|
+
Q.current.onCircleAdd?.(i), ft.current = null, G.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7151
7528
|
}
|
|
7152
7529
|
return;
|
|
7153
7530
|
}
|
|
7154
7531
|
if (e === "polygon") {
|
|
7155
|
-
let e =
|
|
7532
|
+
let e = pt.current;
|
|
7156
7533
|
if (e.length >= 3) {
|
|
7157
7534
|
let n = e[0];
|
|
7158
|
-
if (
|
|
7535
|
+
if (Jt(n, t) < 20) {
|
|
7159
7536
|
let t = K.current, n = applyEntityConfig({
|
|
7160
7537
|
...t,
|
|
7161
|
-
id: t?.id ??
|
|
7538
|
+
id: t?.id ?? Bt(),
|
|
7162
7539
|
type: "polygon",
|
|
7163
7540
|
coordinates: [...e]
|
|
7164
7541
|
}, D);
|
|
7165
|
-
|
|
7542
|
+
en();
|
|
7166
7543
|
let r = L.current;
|
|
7167
7544
|
if (r && !R.current.has(n.id)) {
|
|
7168
7545
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7169
7546
|
R.current.set(n.id, e);
|
|
7170
7547
|
}
|
|
7171
|
-
Q.current.onPolygonAdd?.(n),
|
|
7548
|
+
Q.current.onPolygonAdd?.(n), pt.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7172
7549
|
return;
|
|
7173
7550
|
}
|
|
7174
7551
|
}
|
|
7175
|
-
|
|
7552
|
+
pt.current = [...e, t];
|
|
7176
7553
|
return;
|
|
7177
7554
|
}
|
|
7178
7555
|
if (e === "square") {
|
|
7179
|
-
let e =
|
|
7180
|
-
if (!e)
|
|
7556
|
+
let e = ht.current;
|
|
7557
|
+
if (!e) ht.current = { center: t };
|
|
7181
7558
|
else {
|
|
7182
|
-
let n =
|
|
7559
|
+
let n = Jt(e.center, t) * 2, r = mt.current, i = applyEntityConfig({
|
|
7183
7560
|
...r,
|
|
7184
|
-
id: r?.id ??
|
|
7561
|
+
id: r?.id ?? Bt(),
|
|
7185
7562
|
type: "square",
|
|
7186
7563
|
center: e.center,
|
|
7187
7564
|
length: n
|
|
7188
7565
|
}, D);
|
|
7189
|
-
|
|
7566
|
+
on();
|
|
7190
7567
|
let a = L.current;
|
|
7191
7568
|
if (a && !R.current.has(i.id)) {
|
|
7192
7569
|
let e = new SquareRenderer(a, i, O, k, j, N);
|
|
7193
7570
|
R.current.set(i.id, e);
|
|
7194
7571
|
}
|
|
7195
|
-
Q.current.onSquareAdd?.(i),
|
|
7572
|
+
Q.current.onSquareAdd?.(i), ht.current = null, mt.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
7196
7573
|
}
|
|
7197
7574
|
return;
|
|
7198
7575
|
}
|
|
7199
7576
|
if (e === "polyline") {
|
|
7200
|
-
|
|
7577
|
+
_t.current = [..._t.current, t];
|
|
7201
7578
|
return;
|
|
7202
7579
|
}
|
|
7203
|
-
let n =
|
|
7580
|
+
let n = dt.current;
|
|
7204
7581
|
if (n && n.src && n.width) {
|
|
7205
7582
|
let e = {
|
|
7206
7583
|
...n,
|
|
7207
|
-
id: n.id ??
|
|
7584
|
+
id: n.id ?? Bt(),
|
|
7208
7585
|
type: "marker",
|
|
7209
7586
|
center: t,
|
|
7210
7587
|
src: n.src,
|
|
7211
7588
|
width: n.width
|
|
7212
7589
|
};
|
|
7213
|
-
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(),
|
|
7590
|
+
Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), dt.current = null, W.current = !1;
|
|
7214
7591
|
return;
|
|
7215
7592
|
}
|
|
7216
|
-
let r =
|
|
7593
|
+
let r = Bn.current;
|
|
7217
7594
|
if (r) {
|
|
7218
7595
|
let e = {
|
|
7219
|
-
id:
|
|
7596
|
+
id: Bt(),
|
|
7220
7597
|
type: "marker",
|
|
7221
7598
|
name: r.name,
|
|
7222
7599
|
center: t,
|
|
@@ -7227,7 +7604,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7227
7604
|
return;
|
|
7228
7605
|
}
|
|
7229
7606
|
}
|
|
7230
|
-
if (
|
|
7607
|
+
if (St.current.length > 0) {
|
|
7231
7608
|
let e = L.current?.getZoom() ?? 12;
|
|
7232
7609
|
if (q.current) {
|
|
7233
7610
|
let { entityId: e, activeHandle: n } = q.current, r = R.current.get(e);
|
|
@@ -7238,7 +7615,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7238
7615
|
q.current = null;
|
|
7239
7616
|
return;
|
|
7240
7617
|
}
|
|
7241
|
-
for (let n of
|
|
7618
|
+
for (let n of St.current) {
|
|
7242
7619
|
let r = R.current.get(n);
|
|
7243
7620
|
if (!r?.getEditHandleAt) continue;
|
|
7244
7621
|
let i = r.getEditHandleAt(t, e);
|
|
@@ -7261,12 +7638,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7261
7638
|
}
|
|
7262
7639
|
}
|
|
7263
7640
|
}
|
|
7264
|
-
let i =
|
|
7641
|
+
let i = Fn.current, a = In.current, o = Ln.current, s = kn(e.originalEvent.target);
|
|
7265
7642
|
if (s) {
|
|
7266
7643
|
let e = i.find((e) => String(e.id) === s);
|
|
7267
7644
|
if (e) {
|
|
7268
7645
|
if (a?.(e), e.popup) {
|
|
7269
|
-
let t = e.popup.content ??
|
|
7646
|
+
let t = e.popup.content ?? Fe?.(e);
|
|
7270
7647
|
t && mergePopupConfig(e.popup, I, t).trigger === "click" && o(s, "click", n);
|
|
7271
7648
|
}
|
|
7272
7649
|
return;
|
|
@@ -7278,7 +7655,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7278
7655
|
let e = i.find((e) => e.id === t);
|
|
7279
7656
|
if (e) {
|
|
7280
7657
|
if (a?.(e), e.popup) {
|
|
7281
|
-
let r = e.popup.content ??
|
|
7658
|
+
let r = e.popup.content ?? Fe?.(e);
|
|
7282
7659
|
r && mergePopupConfig(e.popup, I, r).trigger === "click" && o(t, "click", n);
|
|
7283
7660
|
}
|
|
7284
7661
|
return;
|
|
@@ -7289,7 +7666,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7289
7666
|
let t = i.find((t) => t.id === e);
|
|
7290
7667
|
if (t) {
|
|
7291
7668
|
if (a?.(t), t.popup) {
|
|
7292
|
-
let r = t.popup.content ??
|
|
7669
|
+
let r = t.popup.content ?? Fe?.(t);
|
|
7293
7670
|
r && mergePopupConfig(t.popup, I, r).trigger === "click" && o(e, "click", n);
|
|
7294
7671
|
}
|
|
7295
7672
|
return;
|
|
@@ -7297,67 +7674,67 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7297
7674
|
}
|
|
7298
7675
|
}, [
|
|
7299
7676
|
I,
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
]),
|
|
7677
|
+
Fe,
|
|
7678
|
+
kn
|
|
7679
|
+
]), jn = useCallback((e) => {
|
|
7303
7680
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7304
7681
|
if (q.current) {
|
|
7305
7682
|
let { entityId: e, activeHandle: n } = q.current;
|
|
7306
7683
|
R.current.get(e)?.updateEditPreview?.(n, t);
|
|
7307
7684
|
return;
|
|
7308
7685
|
}
|
|
7309
|
-
let n =
|
|
7310
|
-
n === "rectangle" && r &&
|
|
7311
|
-
let i =
|
|
7312
|
-
n === "circle" && i &&
|
|
7313
|
-
let a =
|
|
7314
|
-
n === "polygon" && a.length > 0 &&
|
|
7315
|
-
let o =
|
|
7316
|
-
n === "square" && o &&
|
|
7317
|
-
let s =
|
|
7318
|
-
n === "polyline" && s.length > 0 &&
|
|
7319
|
-
let c =
|
|
7686
|
+
let n = Vn.current, r = Hn.current;
|
|
7687
|
+
n === "rectangle" && r && Wt(r, t);
|
|
7688
|
+
let i = ft.current;
|
|
7689
|
+
n === "circle" && i && Yt(i.center, t);
|
|
7690
|
+
let a = pt.current;
|
|
7691
|
+
n === "polygon" && a.length > 0 && $t(a, t);
|
|
7692
|
+
let o = ht.current;
|
|
7693
|
+
n === "square" && o && an(o.center, t);
|
|
7694
|
+
let s = _t.current;
|
|
7695
|
+
n === "polyline" && s.length > 0 && ln(s, t);
|
|
7696
|
+
let c = Fn.current, l = Ln.current;
|
|
7320
7697
|
for (let [e, n] of R.current) if (n.isPointInEntity(t)) {
|
|
7321
7698
|
let t = c.find((t) => t.id === e);
|
|
7322
7699
|
if (!t?.popup) continue;
|
|
7323
|
-
let n = t.popup.content ??
|
|
7700
|
+
let n = t.popup.content ?? Fe?.(t);
|
|
7324
7701
|
if (!n) continue;
|
|
7325
7702
|
let r = mergePopupConfig(t.popup, I, n);
|
|
7326
7703
|
if (r.trigger === "hover") {
|
|
7327
|
-
|
|
7704
|
+
Ye.current && clearTimeout(Ye.current), Ye.current = window.setTimeout(() => {
|
|
7328
7705
|
l(e, "hover");
|
|
7329
7706
|
}, r.hoverDelay);
|
|
7330
7707
|
return;
|
|
7331
7708
|
}
|
|
7332
7709
|
}
|
|
7333
|
-
if (
|
|
7710
|
+
if (Ye.current &&= (clearTimeout(Ye.current), null), B?.openedBy === "hover") {
|
|
7334
7711
|
let e = R.current.get(B.entityId);
|
|
7335
|
-
e && !e.isPointInEntity(t) &&
|
|
7712
|
+
e && !e.isPointInEntity(t) && Ot(B.entityId);
|
|
7336
7713
|
}
|
|
7337
7714
|
}, [
|
|
7338
7715
|
I,
|
|
7339
|
-
|
|
7716
|
+
Fe,
|
|
7340
7717
|
B,
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
]),
|
|
7348
|
-
if (e.preventDefault(),
|
|
7349
|
-
|
|
7718
|
+
Ot,
|
|
7719
|
+
Wt,
|
|
7720
|
+
Yt,
|
|
7721
|
+
$t,
|
|
7722
|
+
an,
|
|
7723
|
+
ln
|
|
7724
|
+
]), Mn = useCallback((e) => {
|
|
7725
|
+
if (e.preventDefault(), Pt.current) {
|
|
7726
|
+
Pt.current(null), Pt.current = null, Lt({}), zt(), it(null), pn(Ft.current);
|
|
7350
7727
|
return;
|
|
7351
7728
|
}
|
|
7352
|
-
if (
|
|
7353
|
-
if (
|
|
7729
|
+
if (yt.current) return;
|
|
7730
|
+
if (St.current.length > 0) {
|
|
7354
7731
|
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7355
7732
|
if (q.current) {
|
|
7356
7733
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7357
7734
|
return;
|
|
7358
7735
|
}
|
|
7359
7736
|
let n = L.current?.getZoom() ?? 12;
|
|
7360
|
-
for (let e of
|
|
7737
|
+
for (let e of St.current) {
|
|
7361
7738
|
let r = R.current.get(e);
|
|
7362
7739
|
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7363
7740
|
let i = r.getEditHandleAt(t, n);
|
|
@@ -7368,14 +7745,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7368
7745
|
}
|
|
7369
7746
|
}
|
|
7370
7747
|
}
|
|
7371
|
-
if (
|
|
7372
|
-
if (
|
|
7748
|
+
if (Rn.current !== "edit") return;
|
|
7749
|
+
if (Bn.current) {
|
|
7373
7750
|
H(null), U(null), Y();
|
|
7374
7751
|
return;
|
|
7375
7752
|
}
|
|
7376
|
-
let t =
|
|
7753
|
+
let t = Vn.current;
|
|
7377
7754
|
if (t === "rectangle") {
|
|
7378
|
-
if (
|
|
7755
|
+
if (Hn.current) lt(null), Gt();
|
|
7379
7756
|
else {
|
|
7380
7757
|
U(null);
|
|
7381
7758
|
let e = L.current;
|
|
@@ -7384,7 +7761,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7384
7761
|
return;
|
|
7385
7762
|
}
|
|
7386
7763
|
if (t === "circle") {
|
|
7387
|
-
if (
|
|
7764
|
+
if (ft.current) ft.current = null, Xt();
|
|
7388
7765
|
else {
|
|
7389
7766
|
U(null);
|
|
7390
7767
|
let e = L.current;
|
|
@@ -7393,22 +7770,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7393
7770
|
return;
|
|
7394
7771
|
}
|
|
7395
7772
|
if (t === "polygon") {
|
|
7396
|
-
let e =
|
|
7773
|
+
let e = pt.current;
|
|
7397
7774
|
if (e.length >= 3) {
|
|
7398
7775
|
let t = K.current, n = applyEntityConfig({
|
|
7399
7776
|
...t,
|
|
7400
|
-
id: t?.id ??
|
|
7777
|
+
id: t?.id ?? Bt(),
|
|
7401
7778
|
type: "polygon",
|
|
7402
7779
|
coordinates: [...e]
|
|
7403
7780
|
}, D);
|
|
7404
|
-
|
|
7781
|
+
en();
|
|
7405
7782
|
let r = L.current;
|
|
7406
7783
|
if (r && !R.current.has(n.id)) {
|
|
7407
7784
|
let e = new PolygonRenderer(r, n, O, k, j, N);
|
|
7408
7785
|
R.current.set(n.id, e);
|
|
7409
7786
|
}
|
|
7410
|
-
Q.current.onPolygonAdd?.(n),
|
|
7411
|
-
} else if (e.length > 0)
|
|
7787
|
+
Q.current.onPolygonAdd?.(n), pt.current = [], K.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7788
|
+
} else if (e.length > 0) pt.current = [], en();
|
|
7412
7789
|
else {
|
|
7413
7790
|
U(null);
|
|
7414
7791
|
let e = L.current;
|
|
@@ -7417,7 +7794,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7417
7794
|
return;
|
|
7418
7795
|
}
|
|
7419
7796
|
if (t === "square") {
|
|
7420
|
-
if (
|
|
7797
|
+
if (ht.current) ht.current = null, on();
|
|
7421
7798
|
else {
|
|
7422
7799
|
U(null);
|
|
7423
7800
|
let e = L.current;
|
|
@@ -7426,22 +7803,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7426
7803
|
return;
|
|
7427
7804
|
}
|
|
7428
7805
|
if (t === "polyline") {
|
|
7429
|
-
let e =
|
|
7806
|
+
let e = _t.current;
|
|
7430
7807
|
if (e.length >= 2) {
|
|
7431
|
-
let t =
|
|
7808
|
+
let t = gt.current, n = applyEntityConfig({
|
|
7432
7809
|
...t,
|
|
7433
|
-
id: t?.id ??
|
|
7810
|
+
id: t?.id ?? Bt(),
|
|
7434
7811
|
type: "polyline",
|
|
7435
7812
|
coordinates: [...e]
|
|
7436
7813
|
}, D);
|
|
7437
|
-
|
|
7814
|
+
un();
|
|
7438
7815
|
let r = L.current;
|
|
7439
7816
|
if (r && !R.current.has(n.id)) {
|
|
7440
7817
|
let e = new PolylineRenderer(r, n, O, k, N);
|
|
7441
7818
|
R.current.set(n.id, e);
|
|
7442
7819
|
}
|
|
7443
|
-
Q.current.onPolylineAdd?.(n),
|
|
7444
|
-
} else if (e.length > 0)
|
|
7820
|
+
Q.current.onPolylineAdd?.(n), _t.current = [], gt.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7821
|
+
} else if (e.length > 0) _t.current = [], un();
|
|
7445
7822
|
else {
|
|
7446
7823
|
U(null);
|
|
7447
7824
|
let e = L.current;
|
|
@@ -7452,11 +7829,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7452
7829
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
7453
7830
|
x: e.point.x,
|
|
7454
7831
|
y: e.point.y
|
|
7455
|
-
}, i =
|
|
7832
|
+
}, i = Fn.current, a = kn(e.originalEvent.target);
|
|
7456
7833
|
if (a) {
|
|
7457
7834
|
let e = i.find((e) => String(e.id) === a);
|
|
7458
7835
|
if (e) {
|
|
7459
|
-
|
|
7836
|
+
Nn(e, r, n);
|
|
7460
7837
|
return;
|
|
7461
7838
|
}
|
|
7462
7839
|
}
|
|
@@ -7465,7 +7842,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7465
7842
|
if (o && L.current?.getLayer(o) && L.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
7466
7843
|
let e = i.find((e) => e.id === t);
|
|
7467
7844
|
if (e) {
|
|
7468
|
-
|
|
7845
|
+
Nn(e, r, n);
|
|
7469
7846
|
return;
|
|
7470
7847
|
}
|
|
7471
7848
|
}
|
|
@@ -7473,24 +7850,24 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7473
7850
|
for (let [e, t] of R.current) if (t.isPointInEntity(n)) {
|
|
7474
7851
|
let t = i.find((t) => t.id === e);
|
|
7475
7852
|
if (t) {
|
|
7476
|
-
|
|
7853
|
+
Nn(t, r, n);
|
|
7477
7854
|
return;
|
|
7478
7855
|
}
|
|
7479
7856
|
}
|
|
7480
7857
|
}, [
|
|
7481
|
-
|
|
7858
|
+
kn,
|
|
7482
7859
|
Y,
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
]),
|
|
7489
|
-
let r =
|
|
7860
|
+
Gt,
|
|
7861
|
+
Xt,
|
|
7862
|
+
en,
|
|
7863
|
+
on,
|
|
7864
|
+
un
|
|
7865
|
+
]), Nn = useCallback((e, t, n) => {
|
|
7866
|
+
let r = He.current?.getBoundingClientRect(), i = r ? {
|
|
7490
7867
|
x: t.x + r.left,
|
|
7491
7868
|
y: t.y + r.top
|
|
7492
7869
|
} : t;
|
|
7493
|
-
|
|
7870
|
+
Ze({
|
|
7494
7871
|
position: i,
|
|
7495
7872
|
lngLat: n,
|
|
7496
7873
|
items: [{
|
|
@@ -7510,8 +7887,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7510
7887
|
}
|
|
7511
7888
|
}]
|
|
7512
7889
|
});
|
|
7513
|
-
}, []),
|
|
7514
|
-
|
|
7890
|
+
}, []), Pn = useCallback(() => {
|
|
7891
|
+
Ze(null);
|
|
7515
7892
|
}, []);
|
|
7516
7893
|
useEffect(() => {
|
|
7517
7894
|
let e = document.createElement("div");
|
|
@@ -7523,7 +7900,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7523
7900
|
pointer-events: none;
|
|
7524
7901
|
height: 100%;
|
|
7525
7902
|
z-index: ${I?.zIndex ?? 1e3};
|
|
7526
|
-
`, document.body.appendChild(e),
|
|
7903
|
+
`, document.body.appendChild(e), qe.current = e, () => {
|
|
7527
7904
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7528
7905
|
};
|
|
7529
7906
|
}, [I?.zIndex]), useEffect(() => {
|
|
@@ -7536,61 +7913,61 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7536
7913
|
pointer-events: none;
|
|
7537
7914
|
height: 100%;
|
|
7538
7915
|
z-index: ${(I?.zIndex ?? 1e3) + 100};
|
|
7539
|
-
`, document.body.appendChild(e),
|
|
7916
|
+
`, document.body.appendChild(e), Qe.current = e, () => {
|
|
7540
7917
|
document.body.contains(e) && document.body.removeChild(e);
|
|
7541
7918
|
};
|
|
7542
7919
|
}, [I?.zIndex]);
|
|
7543
|
-
let
|
|
7544
|
-
|
|
7545
|
-
let
|
|
7546
|
-
|
|
7547
|
-
let
|
|
7548
|
-
|
|
7549
|
-
let
|
|
7550
|
-
|
|
7551
|
-
let
|
|
7552
|
-
|
|
7553
|
-
let zn = useRef(at);
|
|
7554
|
-
zn.current = at;
|
|
7920
|
+
let Fn = useRef(T);
|
|
7921
|
+
Fn.current = T;
|
|
7922
|
+
let In = useRef(Le);
|
|
7923
|
+
In.current = Le;
|
|
7924
|
+
let Ln = useRef(Dt);
|
|
7925
|
+
Ln.current = Dt;
|
|
7926
|
+
let Rn = useRef(V);
|
|
7927
|
+
Rn.current = V;
|
|
7928
|
+
let zn = useRef(b);
|
|
7929
|
+
zn.current = b;
|
|
7555
7930
|
let Bn = useRef(ot);
|
|
7556
7931
|
Bn.current = ot;
|
|
7557
7932
|
let Vn = useRef(st);
|
|
7558
7933
|
Vn.current = st;
|
|
7934
|
+
let Hn = useRef(ct);
|
|
7935
|
+
Hn.current = ct;
|
|
7559
7936
|
let Q = useRef(v);
|
|
7560
7937
|
Q.current = v;
|
|
7561
|
-
let
|
|
7562
|
-
|
|
7938
|
+
let Un = useRef(D);
|
|
7939
|
+
Un.current = D, useEffect(() => {
|
|
7563
7940
|
let e = (e) => {
|
|
7564
7941
|
if (e.key === "Escape" && q.current) {
|
|
7565
7942
|
R.current.get(q.current.entityId)?.cancelEditPreview?.(), q.current = null;
|
|
7566
7943
|
return;
|
|
7567
7944
|
}
|
|
7568
7945
|
if (e.key === "Escape" && V === "edit") {
|
|
7569
|
-
if (
|
|
7946
|
+
if (ot && (H(null), U(null), Y()), st === "rectangle") if (ct) lt(null), Gt();
|
|
7570
7947
|
else {
|
|
7571
7948
|
U(null);
|
|
7572
7949
|
let e = L.current;
|
|
7573
7950
|
e && (e.getCanvas().style.cursor = "");
|
|
7574
7951
|
}
|
|
7575
|
-
if (
|
|
7952
|
+
if (st === "circle") if (ft.current) ft.current = null, Xt();
|
|
7576
7953
|
else {
|
|
7577
7954
|
U(null);
|
|
7578
7955
|
let e = L.current;
|
|
7579
7956
|
e && (e.getCanvas().style.cursor = "");
|
|
7580
7957
|
}
|
|
7581
|
-
if (
|
|
7958
|
+
if (st === "polygon") if (pt.current.length > 0) pt.current = [], en();
|
|
7582
7959
|
else {
|
|
7583
7960
|
U(null);
|
|
7584
7961
|
let e = L.current;
|
|
7585
7962
|
e && (e.getCanvas().style.cursor = "");
|
|
7586
7963
|
}
|
|
7587
|
-
if (
|
|
7964
|
+
if (st === "square") if (ht.current) ht.current = null, on();
|
|
7588
7965
|
else {
|
|
7589
7966
|
U(null);
|
|
7590
7967
|
let e = L.current;
|
|
7591
7968
|
e && (e.getCanvas().style.cursor = "");
|
|
7592
7969
|
}
|
|
7593
|
-
if (
|
|
7970
|
+
if (st === "polyline") if (_t.current.length > 0) _t.current = [], un();
|
|
7594
7971
|
else {
|
|
7595
7972
|
U(null);
|
|
7596
7973
|
let e = L.current;
|
|
@@ -7603,55 +7980,55 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7603
7980
|
};
|
|
7604
7981
|
}, [
|
|
7605
7982
|
V,
|
|
7606
|
-
at,
|
|
7607
7983
|
ot,
|
|
7608
7984
|
st,
|
|
7985
|
+
ct,
|
|
7609
7986
|
Y,
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7987
|
+
Gt,
|
|
7988
|
+
Xt,
|
|
7989
|
+
en,
|
|
7990
|
+
on,
|
|
7991
|
+
un
|
|
7615
7992
|
]), useEffect(() => {
|
|
7616
7993
|
let e = L.current;
|
|
7617
7994
|
if (!e || !B) return;
|
|
7618
7995
|
let t = B.entityId, n = B.config, r = () => {
|
|
7619
|
-
let r =
|
|
7996
|
+
let r = Fn.current.find((e) => e.id === t);
|
|
7620
7997
|
if (!r) {
|
|
7621
|
-
|
|
7998
|
+
kt();
|
|
7622
7999
|
return;
|
|
7623
8000
|
}
|
|
7624
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
7625
|
-
|
|
8001
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Je.current);
|
|
8002
|
+
Je.current && (Je.current.style.left = `${i.x}px`, Je.current.style.top = `${i.y}px`);
|
|
7626
8003
|
}, i = setTimeout(() => {
|
|
7627
8004
|
r();
|
|
7628
8005
|
}, 50);
|
|
7629
8006
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7630
8007
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7631
8008
|
};
|
|
7632
|
-
}, [B?.entityId,
|
|
7633
|
-
let e = L.current, t =
|
|
7634
|
-
if (!e || !
|
|
7635
|
-
let n =
|
|
8009
|
+
}, [B?.entityId, kt]), useEffect(() => {
|
|
8010
|
+
let e = L.current, t = He.current;
|
|
8011
|
+
if (!e || !Xe || !t) return;
|
|
8012
|
+
let n = Xe.lngLat, r = () => {
|
|
7636
8013
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
7637
8014
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
7638
|
-
|
|
8015
|
+
Pn();
|
|
7639
8016
|
return;
|
|
7640
8017
|
}
|
|
7641
8018
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
7642
|
-
|
|
8019
|
+
$e.current && ($e.current.style.left = `${s}px`, $e.current.style.top = `${c}px`);
|
|
7643
8020
|
};
|
|
7644
8021
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
7645
8022
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
7646
8023
|
};
|
|
7647
|
-
}, [
|
|
7648
|
-
if (!
|
|
8024
|
+
}, [Xe?.lngLat, Pn]), useEffect(() => {
|
|
8025
|
+
if (!He.current) return;
|
|
7649
8026
|
let e = {
|
|
7650
8027
|
version: 8,
|
|
7651
8028
|
sources: {},
|
|
7652
8029
|
layers: []
|
|
7653
8030
|
}, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: m = !0, boxZoom: h = !0 } = x, _ = new mapboxgl.Map({
|
|
7654
|
-
container:
|
|
8031
|
+
container: He.current,
|
|
7655
8032
|
style: p || e,
|
|
7656
8033
|
center: l,
|
|
7657
8034
|
zoom: u,
|
|
@@ -7685,9 +8062,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7685
8062
|
}
|
|
7686
8063
|
z.current.clear(), T.forEach((e) => {
|
|
7687
8064
|
z.current.set(e.id, e);
|
|
7688
|
-
}),
|
|
7689
|
-
}), _.on("click",
|
|
7690
|
-
_.off("click",
|
|
8065
|
+
}), On(S), bn(), Ut(), Kt(), Qt(), nn(), cn(), tt(_), Ie?.(_);
|
|
8066
|
+
}), _.on("click", An), _.on("mousemove", jn), _.on("contextmenu", Mn), () => {
|
|
8067
|
+
_.off("click", An), _.off("mousemove", jn), _.off("contextmenu", Mn), xn(), zt(), Y(), X(), Z(), _.remove(), L.current = null;
|
|
7691
8068
|
};
|
|
7692
8069
|
}, []), useEffect(() => {
|
|
7693
8070
|
if (L.current) {
|
|
@@ -7695,53 +8072,53 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7695
8072
|
L.current.once("load", () => {
|
|
7696
8073
|
z.current.clear(), T.forEach((e) => {
|
|
7697
8074
|
z.current.set(e.id, e);
|
|
7698
|
-
}),
|
|
8075
|
+
}), bn();
|
|
7699
8076
|
});
|
|
7700
8077
|
return;
|
|
7701
8078
|
}
|
|
7702
8079
|
z.current.clear(), T.forEach((e) => {
|
|
7703
8080
|
z.current.set(e.id, e);
|
|
7704
|
-
}),
|
|
8081
|
+
}), bn();
|
|
7705
8082
|
}
|
|
7706
|
-
}, [T,
|
|
7707
|
-
!L.current || !L.current.isStyleLoaded() || (
|
|
8083
|
+
}, [T, bn]), useEffect(() => {
|
|
8084
|
+
!L.current || !L.current.isStyleLoaded() || (xn(), bn());
|
|
7708
8085
|
}, [
|
|
7709
8086
|
O,
|
|
7710
8087
|
k,
|
|
7711
8088
|
j,
|
|
7712
8089
|
M,
|
|
7713
8090
|
N,
|
|
7714
|
-
|
|
7715
|
-
|
|
8091
|
+
xn,
|
|
8092
|
+
bn
|
|
7716
8093
|
]), useEffect(() => {
|
|
7717
8094
|
if (L.current) {
|
|
7718
8095
|
if (!L.current.isStyleLoaded()) {
|
|
7719
8096
|
L.current.once("load", () => {
|
|
7720
|
-
|
|
8097
|
+
On(S);
|
|
7721
8098
|
});
|
|
7722
8099
|
return;
|
|
7723
8100
|
}
|
|
7724
|
-
|
|
7725
|
-
}
|
|
7726
|
-
}, [S,
|
|
7727
|
-
let
|
|
7728
|
-
|
|
7729
|
-
let
|
|
7730
|
-
|
|
7731
|
-
let
|
|
7732
|
-
|
|
7733
|
-
let
|
|
7734
|
-
|
|
7735
|
-
let
|
|
7736
|
-
|
|
7737
|
-
let
|
|
7738
|
-
|
|
7739
|
-
let
|
|
7740
|
-
|
|
7741
|
-
let
|
|
7742
|
-
|
|
7743
|
-
let
|
|
7744
|
-
|
|
8101
|
+
On(S);
|
|
8102
|
+
}
|
|
8103
|
+
}, [S, On]);
|
|
8104
|
+
let Wn = useRef(void 0), Gn = useRef(!0), Kn = useRef(S);
|
|
8105
|
+
Kn.current = S;
|
|
8106
|
+
let qn = useRef(On);
|
|
8107
|
+
qn.current = On;
|
|
8108
|
+
let Jn = useRef(xn);
|
|
8109
|
+
Jn.current = xn;
|
|
8110
|
+
let Yn = useRef(bn);
|
|
8111
|
+
Yn.current = bn;
|
|
8112
|
+
let Xn = useRef(Ut);
|
|
8113
|
+
Xn.current = Ut;
|
|
8114
|
+
let Zn = useRef(Kt);
|
|
8115
|
+
Zn.current = Kt;
|
|
8116
|
+
let Qn = useRef(Qt);
|
|
8117
|
+
Qn.current = Qt;
|
|
8118
|
+
let $n = useRef(nn);
|
|
8119
|
+
$n.current = nn;
|
|
8120
|
+
let er = useRef(cn);
|
|
8121
|
+
er.current = cn, useEffect(() => {
|
|
7745
8122
|
let e = L.current;
|
|
7746
8123
|
if (!e) return;
|
|
7747
8124
|
let t = p || {
|
|
@@ -7749,27 +8126,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7749
8126
|
sources: {},
|
|
7750
8127
|
layers: []
|
|
7751
8128
|
};
|
|
7752
|
-
if (
|
|
7753
|
-
|
|
8129
|
+
if (Gn.current) {
|
|
8130
|
+
Gn.current = !1, Wn.current = p;
|
|
7754
8131
|
return;
|
|
7755
8132
|
}
|
|
7756
|
-
|
|
8133
|
+
Wn.current !== p && (Wn.current = p, e.setStyle(t), e.once("style.load", () => {
|
|
7757
8134
|
if (!e.getStyle().glyphs) {
|
|
7758
8135
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
7759
8136
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
7760
8137
|
}
|
|
7761
|
-
|
|
8138
|
+
Ge.current.clear(), qn.current(Kn.current), Jn.current(), Yn.current(), Xn.current(), Zn.current(), Qn.current(), $n.current(), er.current();
|
|
7762
8139
|
}));
|
|
7763
8140
|
}, [p]), useEffect(() => {
|
|
7764
8141
|
let e = new Set(E.map(String));
|
|
7765
8142
|
for (let [t, n] of R.current) n.setSelected(e.has(String(t)));
|
|
7766
8143
|
}, [E]);
|
|
7767
|
-
let
|
|
8144
|
+
let tr = useRef({});
|
|
7768
8145
|
useEffect(() => {
|
|
7769
8146
|
let e = L.current;
|
|
7770
8147
|
if (!e) return;
|
|
7771
|
-
let t =
|
|
7772
|
-
!n && !r && !i && !a || (
|
|
8148
|
+
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;
|
|
8149
|
+
!n && !r && !i && !a || (tr.current = {
|
|
7773
8150
|
center: l,
|
|
7774
8151
|
zoom: u,
|
|
7775
8152
|
pitch: d,
|
|
@@ -7786,8 +8163,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7786
8163
|
d,
|
|
7787
8164
|
f
|
|
7788
8165
|
]);
|
|
7789
|
-
let
|
|
7790
|
-
if (
|
|
8166
|
+
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)(), $ = (() => {
|
|
8167
|
+
if (Ee === !1) return null;
|
|
7791
8168
|
let e, t, n;
|
|
7792
8169
|
if (S && S.length > 0) {
|
|
7793
8170
|
let r = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
@@ -7800,18 +8177,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7800
8177
|
} else e = `base-layer-source-${r.id}`;
|
|
7801
8178
|
t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
|
|
7802
8179
|
}
|
|
7803
|
-
return
|
|
8180
|
+
return Ee === !0 ? {
|
|
7804
8181
|
enabled: !0,
|
|
7805
8182
|
source: e,
|
|
7806
8183
|
sourceLayer: t,
|
|
7807
8184
|
classField: n
|
|
7808
8185
|
} : {
|
|
7809
|
-
...
|
|
7810
|
-
source:
|
|
7811
|
-
sourceLayer:
|
|
7812
|
-
classField:
|
|
8186
|
+
...Ee,
|
|
8187
|
+
source: Ee.source || e,
|
|
8188
|
+
sourceLayer: Ee.sourceLayer || t,
|
|
8189
|
+
classField: Ee.classField || n
|
|
7813
8190
|
};
|
|
7814
|
-
})(),
|
|
8191
|
+
})(), ar = (() => F ? F === !0 ? { enabled: !0 } : F : null)(), or = (() => Oe ? Oe === !0 ? { enabled: !0 } : Oe : null)(), sr = (() => Me || null)(), cr = useMemo(() => {
|
|
7815
8192
|
let e = [];
|
|
7816
8193
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
7817
8194
|
let n = L.current;
|
|
@@ -7821,7 +8198,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7821
8198
|
}
|
|
7822
8199
|
} else e.push(`base-layer-${t.id}`);
|
|
7823
8200
|
return e;
|
|
7824
|
-
}, [S,
|
|
8201
|
+
}, [S, et]), lr = useMemo(() => {
|
|
7825
8202
|
if (V !== "picker") return;
|
|
7826
8203
|
let e = J.cursorImage;
|
|
7827
8204
|
if (!e) return;
|
|
@@ -7856,16 +8233,16 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7856
8233
|
break;
|
|
7857
8234
|
}
|
|
7858
8235
|
return `url(${e.url}) ${i} ${a}, crosshair`;
|
|
7859
|
-
}, [V, J.cursorImage]),
|
|
7860
|
-
...
|
|
7861
|
-
"--mapbox-picker-cursor":
|
|
7862
|
-
} :
|
|
8236
|
+
}, [V, J.cursorImage]), ur = useMemo(() => lr ? {
|
|
8237
|
+
...Ve,
|
|
8238
|
+
"--mapbox-picker-cursor": lr
|
|
8239
|
+
} : Ve, [Ve, lr]);
|
|
7863
8240
|
return /* @__PURE__ */ jsxs("div", {
|
|
7864
|
-
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${
|
|
7865
|
-
style:
|
|
8241
|
+
className: `comp-mapbox ${V === "picker" ? "comp-mapbox--picker-mode" : ""} ${Be}`,
|
|
8242
|
+
style: ur,
|
|
7866
8243
|
children: [
|
|
7867
8244
|
/* @__PURE__ */ jsx("div", {
|
|
7868
|
-
ref:
|
|
8245
|
+
ref: He,
|
|
7869
8246
|
className: "comp-mapbox__map"
|
|
7870
8247
|
}),
|
|
7871
8248
|
V === "picker" && J.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
@@ -7879,14 +8256,14 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7879
8256
|
})]
|
|
7880
8257
|
}),
|
|
7881
8258
|
/* @__PURE__ */ jsxs("div", {
|
|
7882
|
-
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ||
|
|
8259
|
+
className: `comp-mapbox__edit-controls${V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || sr && sr.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
|
|
7883
8260
|
children: [
|
|
7884
8261
|
V === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7885
8262
|
markerTemplates: v.markerTemplates || [],
|
|
7886
|
-
selectedTemplate:
|
|
7887
|
-
onTemplateSelect:
|
|
7888
|
-
drawMode:
|
|
7889
|
-
onDrawModeChange:
|
|
8263
|
+
selectedTemplate: ot,
|
|
8264
|
+
onTemplateSelect: dn,
|
|
8265
|
+
drawMode: st,
|
|
8266
|
+
onDrawModeChange: fn,
|
|
7890
8267
|
showRectangleTool: v.showRectangleTool,
|
|
7891
8268
|
showCircleTool: v.showCircleTool,
|
|
7892
8269
|
showPolygonTool: v.showPolygonTool,
|
|
@@ -7894,8 +8271,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7894
8271
|
showPolylineTool: v.showPolylineTool
|
|
7895
8272
|
}),
|
|
7896
8273
|
/* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7897
|
-
ref:
|
|
7898
|
-
map:
|
|
8274
|
+
ref: We,
|
|
8275
|
+
map: et,
|
|
7899
8276
|
showButton: !!($ && $.enabled !== !1),
|
|
7900
8277
|
highlightWidth: $?.highlightWidth,
|
|
7901
8278
|
defaultRoadTypes: $?.defaultRoadTypes,
|
|
@@ -7906,80 +8283,80 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
7906
8283
|
className: $?.className,
|
|
7907
8284
|
style: $?.style
|
|
7908
8285
|
}),
|
|
7909
|
-
|
|
7910
|
-
ref:
|
|
7911
|
-
map:
|
|
7912
|
-
pointCount:
|
|
7913
|
-
showPointCountInput:
|
|
7914
|
-
visualType:
|
|
7915
|
-
onSelectFinished:
|
|
8286
|
+
sr && sr.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
8287
|
+
ref: Ue,
|
|
8288
|
+
map: et,
|
|
8289
|
+
pointCount: sr.pointCount,
|
|
8290
|
+
showPointCountInput: sr.showPointCountInput,
|
|
8291
|
+
visualType: sr.visualType,
|
|
8292
|
+
onSelectFinished: sr.onSelectFinished
|
|
7916
8293
|
})
|
|
7917
8294
|
]
|
|
7918
8295
|
}),
|
|
7919
|
-
(
|
|
8296
|
+
(nr?.enabled !== !1 || rr?.enabled !== !1 || ir?.enabled !== !1 || ar && ar.enabled !== !1 || or && or.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
7920
8297
|
className: "comp-mapbox__controls",
|
|
7921
8298
|
children: [
|
|
7922
|
-
|
|
7923
|
-
map:
|
|
7924
|
-
precision:
|
|
7925
|
-
className: tr.className,
|
|
7926
|
-
style: tr.style
|
|
7927
|
-
}),
|
|
7928
|
-
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7929
|
-
map: $e,
|
|
7930
|
-
maxWidth: nr.maxWidth,
|
|
7931
|
-
unit: nr.unit,
|
|
8299
|
+
nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
8300
|
+
map: et,
|
|
8301
|
+
precision: nr.precision,
|
|
7932
8302
|
className: nr.className,
|
|
7933
8303
|
style: nr.style
|
|
7934
8304
|
}),
|
|
7935
|
-
|
|
7936
|
-
map:
|
|
8305
|
+
rr && rr.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
8306
|
+
map: et,
|
|
8307
|
+
maxWidth: rr.maxWidth,
|
|
8308
|
+
unit: rr.unit,
|
|
8309
|
+
className: rr.className,
|
|
8310
|
+
style: rr.style
|
|
8311
|
+
}),
|
|
8312
|
+
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
8313
|
+
map: et,
|
|
7937
8314
|
entityConfig: D,
|
|
7938
8315
|
onDrawModeChange: (e) => {
|
|
7939
|
-
|
|
8316
|
+
yt.current = e;
|
|
7940
8317
|
},
|
|
7941
|
-
className: ir.className,
|
|
7942
|
-
style: ir.style
|
|
7943
|
-
}),
|
|
7944
|
-
ar && ar.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7945
|
-
map: $e,
|
|
7946
|
-
value: C,
|
|
7947
|
-
onChange: Me,
|
|
7948
|
-
rasterPaintLayerIds: sr,
|
|
7949
8318
|
className: ar.className,
|
|
7950
8319
|
style: ar.style
|
|
7951
8320
|
}),
|
|
7952
|
-
|
|
7953
|
-
map:
|
|
8321
|
+
or && or.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
8322
|
+
map: et,
|
|
8323
|
+
value: C,
|
|
8324
|
+
onChange: Ne,
|
|
8325
|
+
rasterPaintLayerIds: cr,
|
|
8326
|
+
className: or.className,
|
|
8327
|
+
style: or.style
|
|
8328
|
+
}),
|
|
8329
|
+
ir && ir.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
8330
|
+
map: et,
|
|
7954
8331
|
initialCenter: l,
|
|
7955
8332
|
initialZoom: u,
|
|
7956
8333
|
initialPitch: d,
|
|
7957
8334
|
initialBearing: f,
|
|
7958
|
-
duration:
|
|
7959
|
-
className:
|
|
7960
|
-
style:
|
|
8335
|
+
duration: ir.duration,
|
|
8336
|
+
className: ir.className,
|
|
8337
|
+
style: ir.style
|
|
7961
8338
|
})
|
|
7962
8339
|
]
|
|
7963
8340
|
}),
|
|
7964
|
-
!(
|
|
7965
|
-
ref:
|
|
7966
|
-
map:
|
|
8341
|
+
!(sr && sr.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
8342
|
+
ref: Ue,
|
|
8343
|
+
map: et,
|
|
7967
8344
|
showButton: !1
|
|
7968
8345
|
}),
|
|
7969
|
-
B &&
|
|
8346
|
+
B && qe.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7970
8347
|
popupState: B,
|
|
7971
|
-
onClose: () =>
|
|
7972
|
-
portalContainer:
|
|
7973
|
-
popupRef:
|
|
8348
|
+
onClose: () => Ot(B.entityId),
|
|
8349
|
+
portalContainer: qe.current,
|
|
8350
|
+
popupRef: Je
|
|
7974
8351
|
}),
|
|
7975
|
-
|
|
7976
|
-
menuState:
|
|
7977
|
-
onClose:
|
|
7978
|
-
portalContainer:
|
|
7979
|
-
menuRef:
|
|
8352
|
+
Xe && Qe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
8353
|
+
menuState: Xe,
|
|
8354
|
+
onClose: Pn,
|
|
8355
|
+
portalContainer: Qe.current,
|
|
8356
|
+
menuRef: $e
|
|
7980
8357
|
})
|
|
7981
8358
|
]
|
|
7982
8359
|
});
|
|
7983
8360
|
});
|
|
7984
8361
|
Mapbox.displayName = "Mapbox";
|
|
7985
|
-
export { BaseCanvasRenderer, COLOR_SCHEMES, CanvasCircleRenderer, CanvasImageRenderer, CanvasRadarRenderer, CircleRenderer, ContextMenu, CoordinateDisplay, DEFAULT_NAME_CONFIG, DEFAULT_SELECT_NAME_CONFIG, EditControl, EntityPopup, Mapbox, MarkerRenderer, POPUP_DEFAULTS, PolygonRenderer, PolylineRenderer, RADAR_DEFAULTS, ROAD_TYPE_OPTIONS, RectangleRenderer, ResetViewControl, RoadHighlightControl, ScaleControl, SquareRenderer, UnitRenderer, bearing, calculatePopupPosition, confidenceToOpacity, destinationPoint, distance, mergePopupConfig, resolveNameConfig };
|
|
8362
|
+
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 };
|