leaflet-polydraw 0.9.6 → 1.1.0
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/README.md +46 -1057
- package/dist/icons/icon-bbox.svg +10 -45
- package/dist/icons/icon-cancel.svg +7 -0
- package/dist/icons/icon-collapse.svg +79 -0
- package/dist/icons/icon-confirm.svg +20 -0
- package/dist/icons/icon-double-elbows.svg +11 -0
- package/dist/icons/icon-draw.svg +55 -1
- package/dist/icons/icon-erase.svg +14 -2
- package/dist/icons/icon-p2p-draw.svg +113 -0
- package/dist/icons/icon-p2p-subtract.svg +108 -0
- package/dist/icons/icon-polydraw2.svg +60 -0
- package/dist/icons/icon-resize.svg +7 -0
- package/dist/icons/icon-rotate.svg +3 -0
- package/dist/icons/icon-simplify2.svg +12 -44
- package/dist/leaflet-polydraw.css +1 -1
- package/dist/polydraw.es.js +2600 -455
- package/dist/polydraw.es.js.map +1 -1
- package/dist/polydraw.umd.min.js +1 -1
- package/dist/polydraw.umd.min.js.map +1 -1
- package/dist/styles/polydraw.css +38 -5
- package/dist/types/buttons.d.ts +1 -1
- package/dist/types/buttons.d.ts.map +1 -1
- package/dist/types/compatibility/event-adapter.d.ts +46 -0
- package/dist/types/compatibility/event-adapter.d.ts.map +1 -0
- package/dist/types/compatibility/leaflet-adapter.d.ts +154 -0
- package/dist/types/compatibility/leaflet-adapter.d.ts.map +1 -0
- package/dist/types/compatibility/version-detector.d.ts +44 -0
- package/dist/types/compatibility/version-detector.d.ts.map +1 -0
- package/dist/types/config.d.ts +3 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/coordinate-utils.d.ts +10 -0
- package/dist/types/coordinate-utils.d.ts.map +1 -1
- package/dist/types/enums.d.ts +9 -1
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/icon-factory.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/managers/mode-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-draw-manager.d.ts +8 -0
- package/dist/types/managers/polygon-draw-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-interaction-manager.d.ts +6 -0
- package/dist/types/managers/polygon-interaction-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-mutation-manager.d.ts.map +1 -1
- package/dist/types/polydraw.d.ts +38 -11
- package/dist/types/polydraw.d.ts.map +1 -1
- package/dist/types/polygon.util.d.ts +2 -0
- package/dist/types/polygon.util.d.ts.map +1 -1
- package/dist/types/popup-factory.d.ts +30 -0
- package/dist/types/popup-factory.d.ts.map +1 -0
- package/dist/types/transform/polygon-transform-controller.d.ts +32 -0
- package/dist/types/transform/polygon-transform-controller.d.ts.map +1 -0
- package/dist/types/transform/transform-overlay.d.ts +34 -0
- package/dist/types/transform/transform-overlay.d.ts.map +1 -0
- package/dist/types/transform/transform-types.d.ts +44 -0
- package/dist/types/transform/transform-types.d.ts.map +1 -0
- package/dist/types/transform/transform-utils.d.ts +26 -0
- package/dist/types/transform/transform-utils.d.ts.map +1 -0
- package/dist/types/types/polydraw-interfaces.d.ts +121 -34
- package/dist/types/types/polydraw-interfaces.d.ts.map +1 -1
- package/dist/types/utils/config-merge.util.d.ts +2 -0
- package/dist/types/utils/config-merge.util.d.ts.map +1 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +29 -15
- package/dist/icons/icon-add-elbow.svg +0 -128
package/dist/polydraw.es.js
CHANGED
|
@@ -2,41 +2,12 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var _a, _b;
|
|
5
|
-
import * as L from "leaflet";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const markers = { "deleteMarker": true, "infoMarker": true, "menuMarker": true, "coordsTitle": true, "zIndexOffset": 0, "markerIcon": { "styleClasses": ["polygon-marker"], "zIndexOffset": null }, "holeIcon": { "styleClasses": ["polygon-marker", "hole"], "zIndexOffset": null }, "markerInfoIcon": { "position": 3, "showArea": true, "showPerimeter": true, "useMetrics": true, "usePerimeterMinValue": false, "areaLabel": "Area", "perimeterLabel": "Perimeter", "values": { "min": { "metric": "50", "imperial": "100" }, "unknown": { "metric": "-", "imperial": "-" } }, "units": { "unknownUnit": "", "metric": { "onlyMetrics": true, "perimeter": { "m": "m", "km": "km" }, "area": { "m2": "m²", "km2": "km²", "daa": "daa", "ha": "ha" } }, "imperial": { "perimeter": { "feet": "ft", "yards": "yd", "miles": "mi" }, "area": { "feet2": "ft²", "yards2": "yd²", "acres": "ac", "miles2": "mi²" } } }, "styleClasses": ["polygon-marker", "info"], "zIndexOffset": 1e4 }, "markerMenuIcon": { "position": 7, "styleClasses": ["polygon-marker", "menu"], "zIndexOffset": 1e4 }, "markerDeleteIcon": { "position": 5, "styleClasses": ["polygon-marker", "delete"], "zIndexOffset": 1e4 }, "holeMarkers": { "menuMarker": false, "deleteMarker": true, "infoMarker": false }, "visualOptimization": { "sharpAngleThreshold": 30, "thresholdBoundingBox": 0.05, "thresholdDistance": 0.05, "useDistance": true, "useBoundingBox": false, "useAngles": false } };
|
|
12
|
-
const polyLineOptions = { "opacity": 1, "smoothFactor": 0, "noClip": true, "clickable": false, "weight": 2 };
|
|
13
|
-
const subtractLineOptions = { "opacity": 1, "smoothFactor": 0, "noClip": true, "clickable": false, "weight": 2 };
|
|
14
|
-
const polygonOptions = { "smoothFactor": 0.3, "noClip": true };
|
|
15
|
-
const holeOptions = { "weight": 2, "opacity": 1, "fillOpacity": 0.5 };
|
|
16
|
-
const polygonCreation = { "method": "concaveman", "simplification": { "mode": "simple", "tolerance": 1e-5, "highQuality": false } };
|
|
17
|
-
const simplification = { "simplifyTolerance": { "tolerance": 1e-4, "highQuality": false, "mutate": false }, "dynamicMode": { "fractionGuard": 0.9, "multiplier": 2 } };
|
|
18
|
-
const menuOperations = { "simplify": { "processHoles": true }, "doubleElbows": { "processHoles": true }, "bbox": { "processHoles": true } };
|
|
19
|
-
const boundingBox = { "addMidPointMarkers": true };
|
|
20
|
-
const bezier$1 = { "resolution": 1e4, "sharpness": 0.75 };
|
|
21
|
-
const colors = { "dragPolygons": { "subtract": "#D9460F" }, "p2p": { "closingMarker": "#4CAF50" }, "edgeHover": "#7a9441", "edgeDeletion": { "hover": "#D9460F" }, "polyline": "#50622b", "subtractLine": "#D9460F", "polygon": { "border": "#50622b", "fill": "#b4cd8a" }, "hole": { "border": "#aa0000", "fill": "#ffcccc" }, "styles": { "controlButton": { "backgroundColor": "#fff", "color": "#000" }, "controlButtonHover": { "backgroundColor": "#f4f4f4" }, "controlButtonActive": { "backgroundColor": "rgb(128, 218, 255)", "color": "#fff" }, "indicatorActive": { "backgroundColor": "#ffcc00" }, "p2pMarker": { "backgroundColor": "#fff", "borderColor": "#50622b" } } };
|
|
22
|
-
const defaultConfig = {
|
|
23
|
-
mergePolygons,
|
|
24
|
-
kinks: kinks$1,
|
|
25
|
-
modes,
|
|
26
|
-
dragPolygons,
|
|
27
|
-
edgeDeletion,
|
|
28
|
-
markers,
|
|
29
|
-
polyLineOptions,
|
|
30
|
-
subtractLineOptions,
|
|
31
|
-
polygonOptions,
|
|
32
|
-
holeOptions,
|
|
33
|
-
polygonCreation,
|
|
34
|
-
simplification,
|
|
35
|
-
menuOperations,
|
|
36
|
-
boundingBox,
|
|
37
|
-
bezier: bezier$1,
|
|
38
|
-
colors
|
|
39
|
-
};
|
|
5
|
+
import * as L$1 from "leaflet";
|
|
6
|
+
var LeafletVersion = /* @__PURE__ */ ((LeafletVersion2) => {
|
|
7
|
+
LeafletVersion2["V1"] = "1.x";
|
|
8
|
+
LeafletVersion2["V2"] = "2.x";
|
|
9
|
+
return LeafletVersion2;
|
|
10
|
+
})(LeafletVersion || {});
|
|
40
11
|
var DrawMode = /* @__PURE__ */ ((DrawMode2) => {
|
|
41
12
|
DrawMode2[DrawMode2["Off"] = 0] = "Off";
|
|
42
13
|
DrawMode2[DrawMode2["Add"] = 1] = "Add";
|
|
@@ -45,6 +16,7 @@ var DrawMode = /* @__PURE__ */ ((DrawMode2) => {
|
|
|
45
16
|
DrawMode2[DrawMode2["AppendMarker"] = 8] = "AppendMarker";
|
|
46
17
|
DrawMode2[DrawMode2["LoadPredefined"] = 16] = "LoadPredefined";
|
|
47
18
|
DrawMode2[DrawMode2["PointToPoint"] = 32] = "PointToPoint";
|
|
19
|
+
DrawMode2[DrawMode2["PointToPointSubtract"] = 64] = "PointToPointSubtract";
|
|
48
20
|
return DrawMode2;
|
|
49
21
|
})(DrawMode || {});
|
|
50
22
|
var MarkerPosition = /* @__PURE__ */ ((MarkerPosition2) => {
|
|
@@ -59,6 +31,244 @@ var MarkerPosition = /* @__PURE__ */ ((MarkerPosition2) => {
|
|
|
59
31
|
MarkerPosition2[MarkerPosition2["Hole"] = 8] = "Hole";
|
|
60
32
|
return MarkerPosition2;
|
|
61
33
|
})(MarkerPosition || {});
|
|
34
|
+
const defaultConfig = {
|
|
35
|
+
mergePolygons: true,
|
|
36
|
+
kinks: false,
|
|
37
|
+
modes: {
|
|
38
|
+
draw: true,
|
|
39
|
+
subtract: true,
|
|
40
|
+
deleteAll: true,
|
|
41
|
+
p2p: true,
|
|
42
|
+
p2pSubtract: true,
|
|
43
|
+
attachElbow: true,
|
|
44
|
+
dragElbow: true,
|
|
45
|
+
dragPolygons: true,
|
|
46
|
+
edgeDeletion: true
|
|
47
|
+
},
|
|
48
|
+
defaultMode: DrawMode.Off,
|
|
49
|
+
dragPolygons: {
|
|
50
|
+
opacity: 0.7,
|
|
51
|
+
dragCursor: "move",
|
|
52
|
+
hoverCursor: "grab",
|
|
53
|
+
markerBehavior: "hide",
|
|
54
|
+
markerAnimationDuration: 200,
|
|
55
|
+
modifierSubtract: {
|
|
56
|
+
keys: {
|
|
57
|
+
windows: "ctrlKey",
|
|
58
|
+
mac: "metaKey",
|
|
59
|
+
linux: "ctrlKey"
|
|
60
|
+
},
|
|
61
|
+
hideMarkersOnDrag: true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
edgeDeletion: {
|
|
65
|
+
keys: {
|
|
66
|
+
windows: "ctrlKey",
|
|
67
|
+
mac: "metaKey",
|
|
68
|
+
linux: "ctrlKey"
|
|
69
|
+
},
|
|
70
|
+
minVertices: 3
|
|
71
|
+
},
|
|
72
|
+
markers: {
|
|
73
|
+
deleteMarker: true,
|
|
74
|
+
infoMarker: true,
|
|
75
|
+
menuMarker: true,
|
|
76
|
+
coordsTitle: true,
|
|
77
|
+
zIndexOffset: 0,
|
|
78
|
+
markerIcon: {
|
|
79
|
+
styleClasses: ["polygon-marker"],
|
|
80
|
+
zIndexOffset: null
|
|
81
|
+
},
|
|
82
|
+
holeIcon: {
|
|
83
|
+
styleClasses: ["polygon-marker", "hole"],
|
|
84
|
+
zIndexOffset: null
|
|
85
|
+
},
|
|
86
|
+
markerInfoIcon: {
|
|
87
|
+
position: 3,
|
|
88
|
+
showArea: true,
|
|
89
|
+
showPerimeter: true,
|
|
90
|
+
useMetrics: true,
|
|
91
|
+
usePerimeterMinValue: false,
|
|
92
|
+
areaLabel: "Area",
|
|
93
|
+
perimeterLabel: "Perimeter",
|
|
94
|
+
values: {
|
|
95
|
+
min: {
|
|
96
|
+
metric: "50",
|
|
97
|
+
imperial: "100"
|
|
98
|
+
},
|
|
99
|
+
unknown: {
|
|
100
|
+
metric: "-",
|
|
101
|
+
imperial: "-"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
units: {
|
|
105
|
+
unknownUnit: "",
|
|
106
|
+
metric: {
|
|
107
|
+
onlyMetrics: true,
|
|
108
|
+
perimeter: {
|
|
109
|
+
m: "m",
|
|
110
|
+
km: "km"
|
|
111
|
+
},
|
|
112
|
+
area: {
|
|
113
|
+
m2: "m²",
|
|
114
|
+
km2: "km²",
|
|
115
|
+
daa: "daa",
|
|
116
|
+
ha: "ha"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
imperial: {
|
|
120
|
+
perimeter: {
|
|
121
|
+
feet: "ft",
|
|
122
|
+
yards: "yd",
|
|
123
|
+
miles: "mi"
|
|
124
|
+
},
|
|
125
|
+
area: {
|
|
126
|
+
feet2: "ft²",
|
|
127
|
+
yards2: "yd²",
|
|
128
|
+
acres: "ac",
|
|
129
|
+
miles2: "mi²"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
styleClasses: ["polygon-marker", "info"],
|
|
134
|
+
zIndexOffset: 1e4
|
|
135
|
+
},
|
|
136
|
+
markerMenuIcon: {
|
|
137
|
+
position: 1,
|
|
138
|
+
styleClasses: ["polygon-marker", "menu"],
|
|
139
|
+
zIndexOffset: 1e4
|
|
140
|
+
},
|
|
141
|
+
markerDeleteIcon: {
|
|
142
|
+
position: 5,
|
|
143
|
+
styleClasses: ["polygon-marker", "delete"],
|
|
144
|
+
zIndexOffset: 1e4
|
|
145
|
+
},
|
|
146
|
+
holeMarkers: {
|
|
147
|
+
menuMarker: false,
|
|
148
|
+
deleteMarker: true,
|
|
149
|
+
infoMarker: false
|
|
150
|
+
},
|
|
151
|
+
visualOptimization: {
|
|
152
|
+
sharpAngleThreshold: 30,
|
|
153
|
+
thresholdBoundingBox: 0.05,
|
|
154
|
+
thresholdDistance: 0.05,
|
|
155
|
+
useDistance: true,
|
|
156
|
+
useBoundingBox: false,
|
|
157
|
+
useAngles: false
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
polyLineOptions: {
|
|
161
|
+
opacity: 1,
|
|
162
|
+
weight: 2
|
|
163
|
+
},
|
|
164
|
+
subtractLineOptions: {
|
|
165
|
+
opacity: 1,
|
|
166
|
+
weight: 2
|
|
167
|
+
},
|
|
168
|
+
polygonOptions: {
|
|
169
|
+
weight: 2,
|
|
170
|
+
opacity: 1,
|
|
171
|
+
fillOpacity: 0.2,
|
|
172
|
+
smoothFactor: 0.3,
|
|
173
|
+
noClip: true
|
|
174
|
+
},
|
|
175
|
+
holeOptions: {
|
|
176
|
+
weight: 2,
|
|
177
|
+
opacity: 1,
|
|
178
|
+
fillOpacity: 0.5
|
|
179
|
+
},
|
|
180
|
+
polygonCreation: {
|
|
181
|
+
method: "concaveman",
|
|
182
|
+
simplification: {
|
|
183
|
+
mode: "simple",
|
|
184
|
+
tolerance: 1e-5,
|
|
185
|
+
highQuality: false
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
simplification: {
|
|
189
|
+
simplifyTolerance: {
|
|
190
|
+
tolerance: 1e-4,
|
|
191
|
+
highQuality: false,
|
|
192
|
+
mutate: false
|
|
193
|
+
},
|
|
194
|
+
dynamicMode: {
|
|
195
|
+
fractionGuard: 0.9,
|
|
196
|
+
multiplier: 2
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
menuOperations: {
|
|
200
|
+
simplify: {
|
|
201
|
+
enabled: true,
|
|
202
|
+
processHoles: true
|
|
203
|
+
},
|
|
204
|
+
doubleElbows: {
|
|
205
|
+
enabled: true,
|
|
206
|
+
processHoles: true
|
|
207
|
+
},
|
|
208
|
+
bbox: {
|
|
209
|
+
enabled: true,
|
|
210
|
+
processHoles: true
|
|
211
|
+
},
|
|
212
|
+
bezier: {
|
|
213
|
+
enabled: true
|
|
214
|
+
},
|
|
215
|
+
scale: {
|
|
216
|
+
enabled: true
|
|
217
|
+
},
|
|
218
|
+
rotate: {
|
|
219
|
+
enabled: true
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
boundingBox: {
|
|
223
|
+
addMidPointMarkers: true
|
|
224
|
+
},
|
|
225
|
+
bezier: {
|
|
226
|
+
resolution: 1e4,
|
|
227
|
+
sharpness: 0.75
|
|
228
|
+
},
|
|
229
|
+
colors: {
|
|
230
|
+
dragPolygons: {
|
|
231
|
+
subtract: "#D9460F"
|
|
232
|
+
},
|
|
233
|
+
p2p: {
|
|
234
|
+
closingMarker: "#4CAF50"
|
|
235
|
+
},
|
|
236
|
+
edgeHover: "#7a9441",
|
|
237
|
+
edgeDeletion: {
|
|
238
|
+
hover: "#D9460F"
|
|
239
|
+
},
|
|
240
|
+
polyline: "#50622b",
|
|
241
|
+
subtractLine: "#D9460F",
|
|
242
|
+
polygon: {
|
|
243
|
+
border: "#50622b",
|
|
244
|
+
fill: "#b4cd8a"
|
|
245
|
+
},
|
|
246
|
+
hole: {
|
|
247
|
+
border: "#aa0000",
|
|
248
|
+
fill: "#ffcccc"
|
|
249
|
+
},
|
|
250
|
+
styles: {
|
|
251
|
+
controlButton: {
|
|
252
|
+
backgroundColor: "#fff",
|
|
253
|
+
color: "#000"
|
|
254
|
+
},
|
|
255
|
+
controlButtonHover: {
|
|
256
|
+
backgroundColor: "#f4f4f4"
|
|
257
|
+
},
|
|
258
|
+
controlButtonActive: {
|
|
259
|
+
backgroundColor: "rgb(128, 218, 255)",
|
|
260
|
+
color: "#fff"
|
|
261
|
+
},
|
|
262
|
+
indicatorActive: {
|
|
263
|
+
backgroundColor: "#ffcc00"
|
|
264
|
+
},
|
|
265
|
+
p2pMarker: {
|
|
266
|
+
backgroundColor: "#fff",
|
|
267
|
+
borderColor: "#50622b"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
62
272
|
const EARTH_RADIUS = {
|
|
63
273
|
/**
|
|
64
274
|
* Mean radius in meters - good enough for this tool's precision requirements
|
|
@@ -15955,7 +16165,7 @@ class PolyDrawUtil {
|
|
|
15955
16165
|
if (isNaN(ll.lat) || isNaN(ll.lng)) ;
|
|
15956
16166
|
tmpLatLng.push(ll);
|
|
15957
16167
|
});
|
|
15958
|
-
const polyLine = new L.Polyline(tmpLatLng);
|
|
16168
|
+
const polyLine = new L$1.Polyline(tmpLatLng);
|
|
15959
16169
|
const bounds = polyLine.getBounds();
|
|
15960
16170
|
if (padding !== 0) {
|
|
15961
16171
|
return bounds.pad(padding);
|
|
@@ -15966,23 +16176,23 @@ class PolyDrawUtil {
|
|
|
15966
16176
|
class Compass {
|
|
15967
16177
|
constructor(minLat = 0, minLng = 0, maxLat = 0, maxLng = 0) {
|
|
15968
16178
|
__publicField(this, "direction", {
|
|
15969
|
-
East: new L.LatLng(0, 0),
|
|
15970
|
-
North: new L.LatLng(0, 0),
|
|
15971
|
-
NorthEast: new L.LatLng(0, 0),
|
|
15972
|
-
NorthWest: new L.LatLng(0, 0),
|
|
15973
|
-
South: new L.LatLng(0, 0),
|
|
15974
|
-
SouthEast: new L.LatLng(0, 0),
|
|
15975
|
-
SouthWest: new L.LatLng(0, 0),
|
|
15976
|
-
West: new L.LatLng(0, 0)
|
|
16179
|
+
East: new L$1.LatLng(0, 0),
|
|
16180
|
+
North: new L$1.LatLng(0, 0),
|
|
16181
|
+
NorthEast: new L$1.LatLng(0, 0),
|
|
16182
|
+
NorthWest: new L$1.LatLng(0, 0),
|
|
16183
|
+
South: new L$1.LatLng(0, 0),
|
|
16184
|
+
SouthEast: new L$1.LatLng(0, 0),
|
|
16185
|
+
SouthWest: new L$1.LatLng(0, 0),
|
|
16186
|
+
West: new L$1.LatLng(0, 0)
|
|
15977
16187
|
});
|
|
15978
|
-
this.direction.North = new L.LatLng(maxLat, (minLng + maxLng) / 2);
|
|
15979
|
-
this.direction.NorthEast = new L.LatLng(maxLat, maxLng);
|
|
15980
|
-
this.direction.East = new L.LatLng((minLat + maxLat) / 2, maxLng);
|
|
15981
|
-
this.direction.SouthEast = new L.LatLng(minLat, maxLng);
|
|
15982
|
-
this.direction.South = new L.LatLng(minLat, (minLng + maxLng) / 2);
|
|
15983
|
-
this.direction.SouthWest = new L.LatLng(minLat, minLng);
|
|
15984
|
-
this.direction.West = new L.LatLng((minLat + maxLat) / 2, minLng);
|
|
15985
|
-
this.direction.NorthWest = new L.LatLng(maxLat, minLng);
|
|
16188
|
+
this.direction.North = new L$1.LatLng(maxLat, (minLng + maxLng) / 2);
|
|
16189
|
+
this.direction.NorthEast = new L$1.LatLng(maxLat, maxLng);
|
|
16190
|
+
this.direction.East = new L$1.LatLng((minLat + maxLat) / 2, maxLng);
|
|
16191
|
+
this.direction.SouthEast = new L$1.LatLng(minLat, maxLng);
|
|
16192
|
+
this.direction.South = new L$1.LatLng(minLat, (minLng + maxLng) / 2);
|
|
16193
|
+
this.direction.SouthWest = new L$1.LatLng(minLat, minLng);
|
|
16194
|
+
this.direction.West = new L$1.LatLng((minLat + maxLat) / 2, minLng);
|
|
16195
|
+
this.direction.NorthWest = new L$1.LatLng(maxLat, minLng);
|
|
15986
16196
|
}
|
|
15987
16197
|
getDirection(direction) {
|
|
15988
16198
|
switch (direction) {
|
|
@@ -16766,10 +16976,10 @@ class TurfHelper {
|
|
|
16766
16976
|
for (let i = 0; i < effectiveLen; i++) {
|
|
16767
16977
|
const p1 = points[i];
|
|
16768
16978
|
const p2 = points[(i + 1) % effectiveLen];
|
|
16769
|
-
doubleized.push(new L.LatLng(p1.lat, p1.lng));
|
|
16979
|
+
doubleized.push(new L$1.LatLng(p1.lat, p1.lng));
|
|
16770
16980
|
const midPoint = midpoint(point$1([p1.lng, p1.lat]), point$1([p2.lng, p2.lat]));
|
|
16771
16981
|
doubleized.push(
|
|
16772
|
-
new L.LatLng(midPoint.geometry.coordinates[1], midPoint.geometry.coordinates[0])
|
|
16982
|
+
new L$1.LatLng(midPoint.geometry.coordinates[1], midPoint.geometry.coordinates[0])
|
|
16773
16983
|
);
|
|
16774
16984
|
}
|
|
16775
16985
|
return doubleized;
|
|
@@ -17242,141 +17452,697 @@ class TurfHelper {
|
|
|
17242
17452
|
return feature2;
|
|
17243
17453
|
}
|
|
17244
17454
|
}
|
|
17245
|
-
|
|
17246
|
-
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
draw.title = "Draw";
|
|
17257
|
-
draw.innerHTML = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M15 7.49996L17.5 9.99996M7.5 20L19.25 8.24996C19.9404 7.5596 19.9404 6.44032 19.25 5.74996V5.74996C18.5596 5.0596 17.4404 5.05961 16.75 5.74996L5 17.5V20H7.5ZM7.5 20H15.8787C17.0503 20 18 19.0502 18 17.8786V17.8786C18 17.316 17.7765 16.7765 17.3787 16.3786L17 16M4.5 4.99996C6.5 2.99996 10 3.99996 10 5.99996C10 8.5 4 8.5 4 11C4 11.8759 4.53314 12.5256 5.22583 13" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>';
|
|
17258
|
-
L.DomEvent.on(draw, "mousedown", L.DomEvent.stopPropagation);
|
|
17259
|
-
L.DomEvent.on(draw, "touchstart", L.DomEvent.stopPropagation);
|
|
17260
|
-
L.DomEvent.on(draw, "click", L.DomEvent.stop).on(draw, "click", onDrawClick);
|
|
17455
|
+
class LeafletVersionDetector {
|
|
17456
|
+
/**
|
|
17457
|
+
* Detects the Leaflet version being used
|
|
17458
|
+
* @returns The detected Leaflet version
|
|
17459
|
+
*/
|
|
17460
|
+
static getVersion() {
|
|
17461
|
+
if (this._detectedVersion) {
|
|
17462
|
+
return this._detectedVersion;
|
|
17463
|
+
}
|
|
17464
|
+
this._detectedVersion = this.detectVersion();
|
|
17465
|
+
return this._detectedVersion;
|
|
17261
17466
|
}
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17467
|
+
/**
|
|
17468
|
+
* Performs the actual version detection
|
|
17469
|
+
* @returns The detected Leaflet version
|
|
17470
|
+
*/
|
|
17471
|
+
static detectVersion() {
|
|
17472
|
+
if (typeof L === "undefined") {
|
|
17473
|
+
return LeafletVersion.V2;
|
|
17474
|
+
}
|
|
17475
|
+
if (L.version) {
|
|
17476
|
+
if (L.version.startsWith("2.")) {
|
|
17477
|
+
return LeafletVersion.V2;
|
|
17478
|
+
}
|
|
17479
|
+
if (L.version.startsWith("1.")) {
|
|
17480
|
+
return LeafletVersion.V1;
|
|
17481
|
+
}
|
|
17482
|
+
}
|
|
17483
|
+
if (typeof L.marker !== "function") {
|
|
17484
|
+
return LeafletVersion.V2;
|
|
17485
|
+
}
|
|
17486
|
+
if (typeof L.marker === "function" && typeof L.polyline === "function" && typeof L.polygon === "function") {
|
|
17487
|
+
return LeafletVersion.V1;
|
|
17488
|
+
}
|
|
17489
|
+
if (L.Marker && typeof L.Marker === "function" && L.Polyline && typeof L.Polyline === "function") {
|
|
17490
|
+
return LeafletVersion.V2;
|
|
17491
|
+
}
|
|
17492
|
+
return LeafletVersion.V1;
|
|
17270
17493
|
}
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
L.DomEvent.on(p2p, "touchstart", L.DomEvent.stopPropagation);
|
|
17278
|
-
L.DomEvent.on(p2p, "click", L.DomEvent.stop).on(p2p, "click", onPointToPointClick);
|
|
17494
|
+
/**
|
|
17495
|
+
* Checks if we're running Leaflet v1.x
|
|
17496
|
+
* @returns true if running v1.x
|
|
17497
|
+
*/
|
|
17498
|
+
static isV1() {
|
|
17499
|
+
return this.getVersion() === LeafletVersion.V1;
|
|
17279
17500
|
}
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
|
|
17286
|
-
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
17287
|
-
viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">
|
|
17288
|
-
<style type="text/css">
|
|
17289
|
-
.st0{fill:#000000}
|
|
17290
|
-
.st1{fill:#333333;fill-opacity:0;}
|
|
17291
|
-
</style>
|
|
17292
|
-
<title>trash</title>
|
|
17293
|
-
<rect class="st1" width="48" height="48"/>
|
|
17294
|
-
<polygon class="st0" points="26.6,10 26.6,7.8 21.4,7.8 21.4,10 12.6,10 12.6,12.8 35.4,12.8 35.4,10 "/>
|
|
17295
|
-
<path class="st0" d="M35.4,15.4H12.6v4.3h1.8V37c0,1.1,0.9,2,2,2h15.2c1.1,0,2-0.9,2-2V19.7h1.8V15.4z M19.7,34.2c0,0.5-0.4,1-1,1
|
|
17296
|
-
c-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1c0.5,0,1,0.4,1,1V34.2z M25.3,33.8c0,0.7-0.6,1.3-1.3,1.3c-0.7,0-1.3-0.6-1.3-1.3V23
|
|
17297
|
-
c0-0.7,0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3V33.8z M30.3,34.2c0,0.5-0.4,1-1,1c-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1
|
|
17298
|
-
c0.5,0,1,0.4,1,1V34.2z"/>
|
|
17299
|
-
</svg>`;
|
|
17300
|
-
L.DomEvent.on(erase, "mousedown", L.DomEvent.stopPropagation);
|
|
17301
|
-
L.DomEvent.on(erase, "touchstart", L.DomEvent.stopPropagation);
|
|
17302
|
-
L.DomEvent.on(erase, "click", L.DomEvent.stop).on(erase, "click", onEraseClick);
|
|
17501
|
+
/**
|
|
17502
|
+
* Checks if we're running Leaflet v2.x
|
|
17503
|
+
* @returns true if running v2.x
|
|
17504
|
+
*/
|
|
17505
|
+
static isV2() {
|
|
17506
|
+
return this.getVersion() === LeafletVersion.V2;
|
|
17303
17507
|
}
|
|
17304
|
-
}
|
|
17305
|
-
class PolygonUtil {
|
|
17306
17508
|
/**
|
|
17307
|
-
*
|
|
17308
|
-
* @param polygon Array of LatLng points.
|
|
17309
|
-
* @returns The center LatLng.
|
|
17509
|
+
* Resets the cached version detection (useful for testing)
|
|
17310
17510
|
*/
|
|
17311
|
-
static
|
|
17312
|
-
|
|
17313
|
-
let y = 0;
|
|
17314
|
-
let z = 0;
|
|
17315
|
-
polygon2.forEach((v) => {
|
|
17316
|
-
let lat1 = v.lat;
|
|
17317
|
-
let lon1 = v.lng;
|
|
17318
|
-
lat1 = lat1 * MATH.DEG_TO_RAD;
|
|
17319
|
-
lon1 = lon1 * MATH.DEG_TO_RAD;
|
|
17320
|
-
x += Math.cos(lat1) * Math.cos(lon1);
|
|
17321
|
-
y += Math.cos(lat1) * Math.sin(lon1);
|
|
17322
|
-
z += Math.sin(lat1);
|
|
17323
|
-
});
|
|
17324
|
-
let lng = Math.atan2(y, x);
|
|
17325
|
-
const hyp = Math.sqrt(x * x + y * y);
|
|
17326
|
-
let lat = Math.atan2(z, hyp);
|
|
17327
|
-
lat = lat * MATH.RAD_TO_DEG;
|
|
17328
|
-
lng = lng * MATH.RAD_TO_DEG;
|
|
17329
|
-
const center2 = { lat, lng };
|
|
17330
|
-
return center2;
|
|
17511
|
+
static reset() {
|
|
17512
|
+
this._detectedVersion = null;
|
|
17331
17513
|
}
|
|
17332
17514
|
/**
|
|
17333
|
-
* Gets
|
|
17334
|
-
* @
|
|
17335
|
-
* @returns The southwest LatLng.
|
|
17515
|
+
* Gets detailed version information for debugging
|
|
17516
|
+
* @returns Object with version details
|
|
17336
17517
|
*/
|
|
17337
|
-
static
|
|
17338
|
-
const
|
|
17339
|
-
return
|
|
17518
|
+
static getVersionInfo() {
|
|
17519
|
+
const version = this.getVersion();
|
|
17520
|
+
return {
|
|
17521
|
+
version,
|
|
17522
|
+
leafletVersion: typeof L !== "undefined" ? L.version : void 0,
|
|
17523
|
+
hasFactoryMethods: typeof L !== "undefined" && typeof L.marker === "function",
|
|
17524
|
+
hasConstructors: typeof L !== "undefined" && L.Marker && typeof L.Marker === "function",
|
|
17525
|
+
globalLAvailable: typeof L !== "undefined"
|
|
17526
|
+
};
|
|
17340
17527
|
}
|
|
17341
|
-
|
|
17342
|
-
|
|
17343
|
-
|
|
17528
|
+
}
|
|
17529
|
+
__publicField(LeafletVersionDetector, "_detectedVersion", null);
|
|
17530
|
+
class LeafletAdapter {
|
|
17531
|
+
constructor() {
|
|
17532
|
+
__publicField(this, "version");
|
|
17533
|
+
/**
|
|
17534
|
+
* DOM utility methods compatibility
|
|
17535
|
+
*/
|
|
17536
|
+
__publicField(this, "domUtil", {
|
|
17537
|
+
create: (tagName, className, container) => {
|
|
17538
|
+
if (typeof L !== "undefined" && L.DomUtil) {
|
|
17539
|
+
return L.DomUtil.create(tagName, className, container);
|
|
17540
|
+
} else {
|
|
17541
|
+
const element = document.createElement(tagName);
|
|
17542
|
+
if (className) {
|
|
17543
|
+
element.className = className;
|
|
17544
|
+
}
|
|
17545
|
+
if (container) {
|
|
17546
|
+
container.appendChild(element);
|
|
17547
|
+
}
|
|
17548
|
+
return element;
|
|
17549
|
+
}
|
|
17550
|
+
},
|
|
17551
|
+
addClass: (el, name) => {
|
|
17552
|
+
if (this.version === LeafletVersion.V1) {
|
|
17553
|
+
L.DomUtil.addClass(el, name);
|
|
17554
|
+
} else {
|
|
17555
|
+
el.classList.add(name);
|
|
17556
|
+
}
|
|
17557
|
+
},
|
|
17558
|
+
removeClass: (el, name) => {
|
|
17559
|
+
if (this.version === LeafletVersion.V1) {
|
|
17560
|
+
L.DomUtil.removeClass(el, name);
|
|
17561
|
+
} else {
|
|
17562
|
+
el.classList.remove(name);
|
|
17563
|
+
}
|
|
17564
|
+
},
|
|
17565
|
+
hasClass: (el, name) => {
|
|
17566
|
+
if (this.version === LeafletVersion.V1) {
|
|
17567
|
+
return L.DomUtil.hasClass(el, name);
|
|
17568
|
+
} else {
|
|
17569
|
+
return el.classList.contains(name);
|
|
17570
|
+
}
|
|
17571
|
+
},
|
|
17572
|
+
setPosition: (el, point2) => {
|
|
17573
|
+
L.DomUtil.setPosition(el, point2);
|
|
17574
|
+
},
|
|
17575
|
+
getPosition: (el) => {
|
|
17576
|
+
return L.DomUtil.getPosition(el);
|
|
17577
|
+
}
|
|
17578
|
+
});
|
|
17579
|
+
/**
|
|
17580
|
+
* DOM event methods compatibility
|
|
17581
|
+
*/
|
|
17582
|
+
__publicField(this, "domEvent", {
|
|
17583
|
+
on: (obj, types, fn, context) => {
|
|
17584
|
+
L.DomEvent.on(obj, types, fn, context);
|
|
17585
|
+
return this;
|
|
17586
|
+
},
|
|
17587
|
+
off: (obj, types, fn, context) => {
|
|
17588
|
+
L.DomEvent.off(obj, types, fn, context);
|
|
17589
|
+
return this;
|
|
17590
|
+
},
|
|
17591
|
+
stopPropagation: (e) => {
|
|
17592
|
+
L.DomEvent.stopPropagation(e);
|
|
17593
|
+
return this;
|
|
17594
|
+
},
|
|
17595
|
+
preventDefault: (e) => {
|
|
17596
|
+
L.DomEvent.preventDefault(e);
|
|
17597
|
+
return this;
|
|
17598
|
+
},
|
|
17599
|
+
stop: (e) => {
|
|
17600
|
+
L.DomEvent.stop(e);
|
|
17601
|
+
return this;
|
|
17602
|
+
},
|
|
17603
|
+
disableClickPropagation: (el) => {
|
|
17604
|
+
L.DomEvent.disableClickPropagation(el);
|
|
17605
|
+
return this;
|
|
17606
|
+
},
|
|
17607
|
+
disableScrollPropagation: (el) => {
|
|
17608
|
+
L.DomEvent.disableScrollPropagation(el);
|
|
17609
|
+
return this;
|
|
17610
|
+
},
|
|
17611
|
+
getMousePosition: (e, container) => {
|
|
17612
|
+
if (this.version === LeafletVersion.V1) {
|
|
17613
|
+
return L.DomEvent.getMousePosition(e, container);
|
|
17614
|
+
} else {
|
|
17615
|
+
return L.DomEvent.getPointerPosition ? L.DomEvent.getPointerPosition(e, container) : L.DomEvent.getMousePosition(e, container);
|
|
17616
|
+
}
|
|
17617
|
+
}
|
|
17618
|
+
});
|
|
17619
|
+
/**
|
|
17620
|
+
* Utility methods compatibility
|
|
17621
|
+
*/
|
|
17622
|
+
__publicField(this, "util", {
|
|
17623
|
+
extend: (dest, ...sources) => {
|
|
17624
|
+
if (this.version === LeafletVersion.V1) {
|
|
17625
|
+
return L.Util.extend(dest, ...sources);
|
|
17626
|
+
} else {
|
|
17627
|
+
return Object.assign(dest, ...sources);
|
|
17628
|
+
}
|
|
17629
|
+
},
|
|
17630
|
+
bind: (fn, obj) => {
|
|
17631
|
+
if (this.version === LeafletVersion.V1) {
|
|
17632
|
+
return L.Util.bind(fn, obj);
|
|
17633
|
+
} else {
|
|
17634
|
+
return fn.bind(obj);
|
|
17635
|
+
}
|
|
17636
|
+
},
|
|
17637
|
+
stamp: (obj) => {
|
|
17638
|
+
return L.Util.stamp(obj);
|
|
17639
|
+
},
|
|
17640
|
+
throttle: (fn, time, context) => {
|
|
17641
|
+
return L.Util.throttle(fn, time, context);
|
|
17642
|
+
},
|
|
17643
|
+
wrapNum: (x, range, includeMax) => {
|
|
17644
|
+
return L.Util.wrapNum(x, range, includeMax);
|
|
17645
|
+
},
|
|
17646
|
+
falseFn: () => {
|
|
17647
|
+
return L.Util.falseFn();
|
|
17648
|
+
},
|
|
17649
|
+
formatNum: (num, digits) => {
|
|
17650
|
+
return L.Util.formatNum(num, digits);
|
|
17651
|
+
},
|
|
17652
|
+
trim: (str) => {
|
|
17653
|
+
if (this.version === LeafletVersion.V1) {
|
|
17654
|
+
return L.Util.trim(str);
|
|
17655
|
+
} else {
|
|
17656
|
+
return str.trim();
|
|
17657
|
+
}
|
|
17658
|
+
},
|
|
17659
|
+
splitWords: (str) => {
|
|
17660
|
+
return L.Util.splitWords(str);
|
|
17661
|
+
},
|
|
17662
|
+
setOptions: (obj, options) => {
|
|
17663
|
+
return L.Util.setOptions(obj, options);
|
|
17664
|
+
},
|
|
17665
|
+
getParamString: (obj, existingUrl, uppercase) => {
|
|
17666
|
+
if (this.version === LeafletVersion.V1) {
|
|
17667
|
+
return L.Util.getParamString(obj, existingUrl, uppercase);
|
|
17668
|
+
} else {
|
|
17669
|
+
const params = new URLSearchParams();
|
|
17670
|
+
for (const key in obj) {
|
|
17671
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
17672
|
+
const paramKey = uppercase ? key.toUpperCase() : key;
|
|
17673
|
+
params.set(paramKey, obj[key]);
|
|
17674
|
+
}
|
|
17675
|
+
}
|
|
17676
|
+
const paramString = params.toString();
|
|
17677
|
+
if (existingUrl) {
|
|
17678
|
+
const separator = existingUrl.indexOf("?") === -1 ? "?" : "&";
|
|
17679
|
+
return existingUrl + separator + paramString;
|
|
17680
|
+
}
|
|
17681
|
+
return paramString ? "?" + paramString : "";
|
|
17682
|
+
}
|
|
17683
|
+
},
|
|
17684
|
+
template: (str, data) => {
|
|
17685
|
+
return L.Util.template(str, data);
|
|
17686
|
+
},
|
|
17687
|
+
isArray: (obj) => {
|
|
17688
|
+
if (this.version === LeafletVersion.V1) {
|
|
17689
|
+
return L.Util.isArray(obj);
|
|
17690
|
+
} else {
|
|
17691
|
+
return Array.isArray(obj);
|
|
17692
|
+
}
|
|
17693
|
+
},
|
|
17694
|
+
indexOf: (array, item) => {
|
|
17695
|
+
return L.Util.indexOf(array, item);
|
|
17696
|
+
},
|
|
17697
|
+
requestAnimFrame: (fn, context, immediate) => {
|
|
17698
|
+
if (this.version === LeafletVersion.V1) {
|
|
17699
|
+
return L.Util.requestAnimFrame(fn, context, immediate);
|
|
17700
|
+
} else {
|
|
17701
|
+
return requestAnimationFrame(context ? fn.bind(context) : fn);
|
|
17702
|
+
}
|
|
17703
|
+
},
|
|
17704
|
+
cancelAnimFrame: (id) => {
|
|
17705
|
+
if (this.version === LeafletVersion.V1) {
|
|
17706
|
+
L.Util.cancelAnimFrame(id);
|
|
17707
|
+
} else {
|
|
17708
|
+
cancelAnimationFrame(id);
|
|
17709
|
+
}
|
|
17710
|
+
}
|
|
17711
|
+
});
|
|
17712
|
+
this.version = LeafletVersionDetector.getVersion();
|
|
17344
17713
|
}
|
|
17345
|
-
|
|
17346
|
-
|
|
17347
|
-
|
|
17714
|
+
/**
|
|
17715
|
+
* Creates a tile layer compatible with both Leaflet versions
|
|
17716
|
+
*/
|
|
17717
|
+
createTileLayer(urlTemplate, options) {
|
|
17718
|
+
if (this.version === LeafletVersion.V1) {
|
|
17719
|
+
return L.tileLayer(urlTemplate, options);
|
|
17720
|
+
} else {
|
|
17721
|
+
return new L.TileLayer(urlTemplate, options);
|
|
17722
|
+
}
|
|
17348
17723
|
}
|
|
17349
|
-
|
|
17350
|
-
|
|
17351
|
-
|
|
17724
|
+
/**
|
|
17725
|
+
* Creates a map compatible with both Leaflet versions
|
|
17726
|
+
*/
|
|
17727
|
+
createMap(element, options) {
|
|
17728
|
+
if (this.version === LeafletVersion.V1) {
|
|
17729
|
+
return L.map(element, options);
|
|
17730
|
+
} else {
|
|
17731
|
+
return new L.Map(element, options);
|
|
17732
|
+
}
|
|
17352
17733
|
}
|
|
17353
|
-
|
|
17354
|
-
|
|
17355
|
-
|
|
17734
|
+
/**
|
|
17735
|
+
* Creates a marker compatible with both Leaflet versions
|
|
17736
|
+
*/
|
|
17737
|
+
createMarker(latlng, options) {
|
|
17738
|
+
if (this.version === LeafletVersion.V1) {
|
|
17739
|
+
return L.marker(latlng, options);
|
|
17740
|
+
} else {
|
|
17741
|
+
return new L.Marker(latlng, options);
|
|
17742
|
+
}
|
|
17356
17743
|
}
|
|
17357
|
-
|
|
17358
|
-
|
|
17359
|
-
|
|
17744
|
+
/**
|
|
17745
|
+
* Creates a polyline compatible with both Leaflet versions
|
|
17746
|
+
*/
|
|
17747
|
+
createPolyline(latlngs, options) {
|
|
17748
|
+
if (this.version === LeafletVersion.V1) {
|
|
17749
|
+
return L.polyline(latlngs, options);
|
|
17750
|
+
} else {
|
|
17751
|
+
return new L.Polyline(latlngs, options);
|
|
17752
|
+
}
|
|
17360
17753
|
}
|
|
17361
|
-
|
|
17362
|
-
|
|
17363
|
-
|
|
17754
|
+
/**
|
|
17755
|
+
* Creates a polygon compatible with both Leaflet versions
|
|
17756
|
+
*/
|
|
17757
|
+
createPolygon(latlngs, options) {
|
|
17758
|
+
if (this.version === LeafletVersion.V1) {
|
|
17759
|
+
return L.polygon(latlngs, options);
|
|
17760
|
+
} else {
|
|
17761
|
+
return new L.Polygon(latlngs, options);
|
|
17762
|
+
}
|
|
17364
17763
|
}
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17764
|
+
/**
|
|
17765
|
+
* Creates a div icon compatible with both Leaflet versions
|
|
17766
|
+
*/
|
|
17767
|
+
createDivIcon(options) {
|
|
17768
|
+
if (this.version === LeafletVersion.V1) {
|
|
17769
|
+
return L.divIcon(options);
|
|
17770
|
+
} else {
|
|
17771
|
+
return new L.DivIcon(options);
|
|
17772
|
+
}
|
|
17368
17773
|
}
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17774
|
+
/**
|
|
17775
|
+
* Creates a LatLng object compatible with both Leaflet versions
|
|
17776
|
+
*/
|
|
17777
|
+
createLatLng(lat, lng, alt) {
|
|
17778
|
+
if (this.version === LeafletVersion.V1) {
|
|
17779
|
+
return L.latLng(lat, lng, alt);
|
|
17780
|
+
} else {
|
|
17781
|
+
return new L.LatLng(lat, lng, alt);
|
|
17782
|
+
}
|
|
17374
17783
|
}
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
|
|
17784
|
+
/**
|
|
17785
|
+
* Creates a LatLngBounds object compatible with both Leaflet versions
|
|
17786
|
+
*/
|
|
17787
|
+
createLatLngBounds(corner1, corner2) {
|
|
17788
|
+
if (this.version === LeafletVersion.V1) {
|
|
17789
|
+
return L.latLngBounds(corner1, corner2);
|
|
17790
|
+
} else {
|
|
17791
|
+
return new L.LatLngBounds(corner1, corner2);
|
|
17792
|
+
}
|
|
17793
|
+
}
|
|
17794
|
+
/**
|
|
17795
|
+
* Creates a Point object compatible with both Leaflet versions
|
|
17796
|
+
*/
|
|
17797
|
+
createPoint(x, y, round) {
|
|
17798
|
+
if (this.version === LeafletVersion.V1) {
|
|
17799
|
+
return L.point(x, y, round);
|
|
17800
|
+
} else {
|
|
17801
|
+
return new L.Point(x, y, round);
|
|
17802
|
+
}
|
|
17803
|
+
}
|
|
17804
|
+
/**
|
|
17805
|
+
* Creates a popup compatible with both Leaflet versions
|
|
17806
|
+
*/
|
|
17807
|
+
createPopup(options, source) {
|
|
17808
|
+
if (this.version === LeafletVersion.V1) {
|
|
17809
|
+
return L.popup(options, source);
|
|
17810
|
+
} else {
|
|
17811
|
+
return new L.Popup(options, source);
|
|
17812
|
+
}
|
|
17813
|
+
}
|
|
17814
|
+
/**
|
|
17815
|
+
* Creates a feature group compatible with both Leaflet versions
|
|
17816
|
+
*/
|
|
17817
|
+
createFeatureGroup(layers) {
|
|
17818
|
+
if (this.version === LeafletVersion.V1) {
|
|
17819
|
+
return L.featureGroup(layers);
|
|
17820
|
+
} else {
|
|
17821
|
+
return new L.FeatureGroup(layers);
|
|
17822
|
+
}
|
|
17823
|
+
}
|
|
17824
|
+
/**
|
|
17825
|
+
* Creates a layer group compatible with both Leaflet versions
|
|
17826
|
+
*/
|
|
17827
|
+
createLayerGroup(layers) {
|
|
17828
|
+
if (this.version === LeafletVersion.V1) {
|
|
17829
|
+
return L.layerGroup(layers);
|
|
17830
|
+
} else {
|
|
17831
|
+
return new L.LayerGroup(layers);
|
|
17832
|
+
}
|
|
17833
|
+
}
|
|
17834
|
+
/**
|
|
17835
|
+
* Browser detection compatibility
|
|
17836
|
+
*/
|
|
17837
|
+
getBrowser() {
|
|
17838
|
+
const self = this;
|
|
17839
|
+
return {
|
|
17840
|
+
get ie() {
|
|
17841
|
+
return self.version === LeafletVersion.V1 ? L.Browser.ie : false;
|
|
17842
|
+
},
|
|
17843
|
+
get ielt9() {
|
|
17844
|
+
return self.version === LeafletVersion.V1 ? L.Browser.ielt9 : false;
|
|
17845
|
+
},
|
|
17846
|
+
get edge() {
|
|
17847
|
+
return self.version === LeafletVersion.V1 ? L.Browser.edge : false;
|
|
17848
|
+
},
|
|
17849
|
+
get webkit() {
|
|
17850
|
+
return self.version === LeafletVersion.V1 ? L.Browser.webkit : false;
|
|
17851
|
+
},
|
|
17852
|
+
get android() {
|
|
17853
|
+
return self.version === LeafletVersion.V1 ? L.Browser.android : /Android/.test(navigator.userAgent);
|
|
17854
|
+
},
|
|
17855
|
+
get android23() {
|
|
17856
|
+
return self.version === LeafletVersion.V1 ? L.Browser.android23 : false;
|
|
17857
|
+
},
|
|
17858
|
+
get androidStock() {
|
|
17859
|
+
return self.version === LeafletVersion.V1 ? L.Browser.androidStock : false;
|
|
17860
|
+
},
|
|
17861
|
+
get opera() {
|
|
17862
|
+
return self.version === LeafletVersion.V1 ? L.Browser.opera : false;
|
|
17863
|
+
},
|
|
17864
|
+
get chrome() {
|
|
17865
|
+
return self.version === LeafletVersion.V1 ? L.Browser.chrome : /Chrome/.test(navigator.userAgent);
|
|
17866
|
+
},
|
|
17867
|
+
get gecko() {
|
|
17868
|
+
return self.version === LeafletVersion.V1 ? L.Browser.gecko : false;
|
|
17869
|
+
},
|
|
17870
|
+
get safari() {
|
|
17871
|
+
return self.version === LeafletVersion.V1 ? L.Browser.safari : /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent);
|
|
17872
|
+
},
|
|
17873
|
+
get phantom() {
|
|
17874
|
+
return self.version === LeafletVersion.V1 ? L.Browser.phantom : false;
|
|
17875
|
+
},
|
|
17876
|
+
get opera12() {
|
|
17877
|
+
return self.version === LeafletVersion.V1 ? L.Browser.opera12 : false;
|
|
17878
|
+
},
|
|
17879
|
+
get win() {
|
|
17880
|
+
return self.version === LeafletVersion.V1 ? L.Browser.win : /Win/.test(navigator.platform);
|
|
17881
|
+
},
|
|
17882
|
+
get ie3d() {
|
|
17883
|
+
return self.version === LeafletVersion.V1 ? L.Browser.ie3d : false;
|
|
17884
|
+
},
|
|
17885
|
+
get webkit3d() {
|
|
17886
|
+
return self.version === LeafletVersion.V1 ? L.Browser.webkit3d : false;
|
|
17887
|
+
},
|
|
17888
|
+
get gecko3d() {
|
|
17889
|
+
return self.version === LeafletVersion.V1 ? L.Browser.gecko3d : false;
|
|
17890
|
+
},
|
|
17891
|
+
get any3d() {
|
|
17892
|
+
return self.version === LeafletVersion.V1 ? L.Browser.any3d : true;
|
|
17893
|
+
},
|
|
17894
|
+
get mobile() {
|
|
17895
|
+
return L.Browser.mobile;
|
|
17896
|
+
},
|
|
17897
|
+
get mobileWebkit() {
|
|
17898
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileWebkit : false;
|
|
17899
|
+
},
|
|
17900
|
+
get mobileWebkit3d() {
|
|
17901
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileWebkit3d : false;
|
|
17902
|
+
},
|
|
17903
|
+
get msPointer() {
|
|
17904
|
+
return self.version === LeafletVersion.V1 ? L.Browser.msPointer : false;
|
|
17905
|
+
},
|
|
17906
|
+
get pointer() {
|
|
17907
|
+
return L.Browser.pointer || true;
|
|
17908
|
+
},
|
|
17909
|
+
get touch() {
|
|
17910
|
+
return L.Browser.touch;
|
|
17911
|
+
},
|
|
17912
|
+
get touchNative() {
|
|
17913
|
+
return self.version === LeafletVersion.V1 ? L.Browser.touchNative : false;
|
|
17914
|
+
},
|
|
17915
|
+
get mobileOpera() {
|
|
17916
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileOpera : false;
|
|
17917
|
+
},
|
|
17918
|
+
get mobileGecko() {
|
|
17919
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileGecko : false;
|
|
17920
|
+
},
|
|
17921
|
+
get retina() {
|
|
17922
|
+
return L.Browser.retina;
|
|
17923
|
+
},
|
|
17924
|
+
get passiveEvents() {
|
|
17925
|
+
return self.version === LeafletVersion.V1 ? L.Browser.passiveEvents : true;
|
|
17926
|
+
},
|
|
17927
|
+
get canvas() {
|
|
17928
|
+
return self.version === LeafletVersion.V1 ? L.Browser.canvas : true;
|
|
17929
|
+
},
|
|
17930
|
+
get svg() {
|
|
17931
|
+
return self.version === LeafletVersion.V1 ? L.Browser.svg : true;
|
|
17932
|
+
},
|
|
17933
|
+
get vml() {
|
|
17934
|
+
return self.version === LeafletVersion.V1 ? L.Browser.vml : false;
|
|
17935
|
+
},
|
|
17936
|
+
get inlineSvg() {
|
|
17937
|
+
return self.version === LeafletVersion.V1 ? L.Browser.inlineSvg : true;
|
|
17938
|
+
}
|
|
17939
|
+
};
|
|
17940
|
+
}
|
|
17941
|
+
/**
|
|
17942
|
+
* Gets the current Leaflet version being used
|
|
17943
|
+
*/
|
|
17944
|
+
getVersion() {
|
|
17945
|
+
return this.version;
|
|
17946
|
+
}
|
|
17947
|
+
/**
|
|
17948
|
+
* Checks if we're running Leaflet v1.x
|
|
17949
|
+
*/
|
|
17950
|
+
isV1() {
|
|
17951
|
+
return this.version === LeafletVersion.V1;
|
|
17952
|
+
}
|
|
17953
|
+
/**
|
|
17954
|
+
* Checks if we're running Leaflet v2.x
|
|
17955
|
+
*/
|
|
17956
|
+
isV2() {
|
|
17957
|
+
return this.version === LeafletVersion.V2;
|
|
17958
|
+
}
|
|
17959
|
+
}
|
|
17960
|
+
const leafletAdapter = new LeafletAdapter();
|
|
17961
|
+
const iconPolydraw2Svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- Generated by Pixelmator Pro 3.7 -->\n\n<svg\n width="512"\n height="512"\n viewBox="0 0 512 512"\n version="1.1"\n id="svg1"\n sodipodi:docname="icon-polydraw2.svg"\n inkscape:version="1.4.2 (ebf0e940, 2025-05-08)"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <defs\n id="defs1" />\n <sodipodi:namedview\n id="namedview1"\n pagecolor="#ffffff"\n bordercolor="#000000"\n borderopacity="0.25"\n inkscape:showpageshadow="2"\n inkscape:pageopacity="0.0"\n inkscape:pagecheckerboard="0"\n inkscape:deskcolor="#d1d1d1"\n inkscape:zoom="2.1854905"\n inkscape:cx="327.38645"\n inkscape:cy="233.586"\n inkscape:window-width="1728"\n inkscape:window-height="1084"\n inkscape:window-x="0"\n inkscape:window-y="33"\n inkscape:window-maximized="0"\n inkscape:current-layer="svg1" />\n <path\n id="Shape"\n fill="#000000"\n fill-rule="evenodd"\n stroke="none"\n d="M 73.574318 425.686768 C 72.433441 425.875031 69.474998 425.094574 67 423.952454 C 64.525002 422.810333 61.487499 420.925354 60.25 419.763611 C 58 417.651367 58 417.651367 58 348.144531 C 58 278.637695 58 278.637695 64.15226 268.068848 C 67.536011 262.255981 73.313545 252.549988 76.991226 246.5 C 80.668915 240.450012 89.670906 225.375 96.995644 213 C 104.320389 200.625 112.662483 186.674988 115.533646 182 C 118.4048 177.325012 128.697449 160.120361 138.406174 143.767456 C 148.114914 127.414551 163.517715 101.539551 172.634628 86.267456 C 181.751526 70.995361 190.896469 56.245453 192.956696 53.489868 C 195.254944 50.415955 198.736298 47.372833 201.964966 45.615601 C 205.547699 43.665619 209.185913 42.598907 213.363663 42.27356 C 218.336411 41.886292 220.809326 42.291656 226.404907 44.411316 C 230.202591 45.849945 237.402588 49.329651 242.404907 52.144043 C 247.407211 54.958435 255.774994 59.756927 261 62.807404 C 266.225006 65.857849 274.774994 70.941406 280 74.104187 C 285.225006 77.266937 292.061249 81.349854 295.191681 83.177338 C 298.322083 85.004791 304.593597 88.698059 309.128387 91.384552 C 313.663147 94.071075 319.525085 98.281769 322.154938 100.741699 C 325.42041 103.796173 327.611938 107.003418 329.066864 110.857117 C 330.739197 115.286774 331.103424 118.018188 330.760925 123.56131 C 330.43689 128.805359 329.575104 132.072418 327.412292 136.25589 C 325.810547 139.354187 318.023956 152.826599 310.108765 166.19458 C 302.193604 179.562561 293.868591 193.52121 291.608765 197.213776 C 289.348938 200.906342 284.985504 208.106354 281.912231 213.213776 C 278.838959 218.321198 270.711334 231.950012 263.8508 243.5 C 256.990295 255.049988 247.400177 271.25 242.539444 279.5 C 237.678696 287.75 231.360229 298.325012 228.498383 303 C 225.636551 307.674988 220.191147 316.829224 216.397522 323.342712 C 212.603882 329.856201 205.890396 341.105133 201.478653 348.340332 C 193.756912 361.003967 193.215347 361.63028 186.978653 365.109344 C 183.41539 367.097076 171.620941 373.526276 160.768753 379.396423 C 149.916565 385.266602 131.916565 395.056671 120.768745 401.1521 C 109.620934 407.247559 94.90844 415.184448 88.074318 418.789642 C 81.240189 422.394806 74.715187 425.498535 73.574318 425.686768 Z M 116 376.754456 C 118.096039 376.543518 128.525452 371.474579 142 364.117859 C 154.375 357.361481 165.393753 350.964722 166.486115 349.902863 C 167.980591 348.450134 168.219772 347.57196 167.452347 346.355347 C 166.891403 345.466064 160.147644 341.00293 152.466217 336.437256 C 144.784805 331.871613 135.350006 326.168945 131.5 323.764709 C 127.650002 321.360443 116.453964 314.692322 106.619926 308.946655 C 96.785881 303.200989 87.533401 297.970886 86.058846 297.324219 C 84.417702 296.604492 82.819748 296.493042 81.938927 297.036957 C 80.957619 297.642883 80.340988 300.480957 80 305.960907 C 79.724998 310.380402 79.653214 323.273193 79.840477 334.611572 C 80.180962 355.226837 80.180962 355.226837 83.340477 358.518677 C 85.078217 360.329193 92.349998 365.252136 99.5 369.458588 C 110.254417 375.785583 113.104576 377.045837 116 376.754456 Z M 184.979996 329 C 185.880753 329 187.322388 328.4375 188.183624 327.75 C 189.044861 327.0625 191.986755 322.899994 194.721161 318.5 C 197.455582 314.100006 212.197037 289.575012 227.47995 264 C 242.762863 238.424988 257.119476 214.503387 259.383514 210.840851 C 261.647583 207.178284 265.524994 200.687805 268 196.417542 C 270.475006 192.147247 273.957123 186.14389 275.738068 183.076691 C 277.523224 180.002289 278.981506 176.072205 278.988068 174.317993 C 278.999237 171.335541 278.294434 170.703522 267.75 164.240753 C 261.5625 160.448364 253.125 155.321045 249 152.84668 C 244.875 150.372314 235.754837 144.907379 228.732956 140.702332 C 221.71109 136.497284 212.486084 130.958221 208.232956 128.39328 C 203.979828 125.828369 197.371674 121.899323 193.548157 119.662079 C 189.72464 117.424835 185.418167 115.421448 183.978195 115.210114 C 181.979828 114.916809 180.644867 115.640442 178.338669 118.267059 C 176.676895 120.159729 172.969727 125.711395 170.10054 130.604126 C 167.231339 135.496857 162.066681 144.159821 158.62352 149.855194 C 155.180359 155.550537 149.634521 164.775543 146.299438 170.355194 C 142.964355 175.934845 136.29039 187.024994 131.468384 195 C 126.646393 202.975006 120.571129 213.100006 117.967812 217.5 C 115.364487 221.899994 109.518463 231.575012 104.976639 239 C 100.434822 246.424988 94.708519 255.988464 92.251534 260.252167 C 88.991837 265.908813 87.948189 268.65741 88.390656 270.420349 C 88.845047 272.230804 92.629936 274.990234 103.491547 281.429932 C 111.463524 286.156433 124.176689 293.686981 131.743027 298.16452 C 139.309357 302.642059 149.324997 308.65036 154 311.516296 C 158.675003 314.382263 167.189499 319.488525 172.921127 322.863556 C 178.65274 326.238586 184.079239 329 184.979996 329 Z M 285.661102 134.977844 C 287.97934 134.99408 289.512512 134.179626 291.411102 131.923279 C 292.908417 130.143829 294 127.609955 294 125.913757 C 294 123.644043 293.152191 122.405426 290.25 120.435181 C 288.1875 119.034973 283.720306 116.145264 280.322876 114.01358 C 276.925446 111.881897 270.400452 107.99884 265.822876 105.384521 C 261.2453 102.770203 255.024994 98.976471 252 96.954041 C 248.975006 94.93161 244.25 92.081146 241.5 90.61969 C 238.75 89.158264 233.350006 85.931335 229.5 83.448761 C 224.476532 80.209473 221.661926 79.01474 219.531921 79.217499 C 217.432587 79.417297 215.882141 80.515015 214.234802 82.967804 C 212.798111 85.106964 212.019608 87.555267 212.202881 89.357971 C 212.456848 91.855927 213.807068 93.077637 221.5 97.770203 C 226.449997 100.789642 237.024994 107.196594 245 112.007874 C 252.975006 116.819153 264.674988 123.950684 271 127.855682 C 278.806824 132.675537 283.515167 134.962799 285.661102 134.977844 Z" />\n <path\n id="path1"\n fill="#000000"\n fill-rule="evenodd"\n stroke="none"\n d="M 479.5 119.5 C 479.5 153.5 479.5 153.5 472.5 153.761627 C 468.649994 153.905518 461.225006 154.708954 456 155.547028 C 450.774994 156.385132 443.466675 157.966583 439.759277 159.061371 C 436.05188 160.156189 430.343719 162.619598 427.074493 164.535645 C 423.805267 166.451691 419.672913 169.245789 417.891449 170.744781 C 416.110016 172.243774 412.965179 176.08078 410.902954 179.271454 C 408.507751 182.977295 406.493622 187.858795 405.326721 192.786346 C 403.980774 198.469788 403.509888 204.334198 403.537537 215.067841 C 403.560455 223.970093 404.286011 234.276245 405.403107 241.567841 C 406.408508 248.130524 408.366913 258.674988 409.755096 265 C 411.14325 271.325012 412.907196 279.200012 413.674927 282.5 C 414.442657 285.799988 416.815094 297.049988 418.946991 307.5 C 421.078888 317.950012 423.76297 332.401184 424.911591 339.613708 C 426.481873 349.47406 427 357.319122 427 371.235504 C 427 387.630524 426.716309 390.871338 424.515106 399.621765 C 423.148407 405.05481 420.216461 413.182556 417.999634 417.683472 C 415.167511 423.433655 411.734741 428.242035 406.454742 433.854706 C 401.146912 439.496948 395.939392 443.700836 388.720215 448.171234 C 383.099091 451.652039 375.575012 455.78241 372 457.349823 C 368.424988 458.917206 361.261017 461.749329 356.080017 463.643402 C 350.899017 465.537445 342.574005 467.951355 337.580017 469.007568 C 332.585999 470.063812 324 471.644897 318.5 472.521088 C 311.866943 473.57782 299.745911 474.237183 282.5 474.479462 C 268.200012 474.680359 252 474.489349 246.5 474.054932 C 241 473.620544 230.875 472.51828 224 471.605438 C 217.125 470.692596 207.424561 469.276886 202.443451 468.459412 C 197.462357 467.641907 190.037354 466.282959 185.943451 465.439453 C 181.849548 464.595978 176.25 463.281586 173.5 462.518616 C 170.75 461.755646 165.800003 460.43631 162.5 459.586731 C 159.199997 458.737183 152 456.93927 146.5 455.59137 C 141 454.243469 130.649994 451.291107 123.5 449.030579 C 116.349998 446.77002 108.587502 444.226166 106.25 443.377533 C 103.345978 442.323242 102 441.251038 102 439.992004 C 102 438.763947 105.25164 436.022705 111.75 431.772461 C 117.112503 428.265137 124.951981 423.494568 129.171066 421.171265 C 136.842117 416.947052 136.842117 416.947052 147.671066 419.885193 C 153.626984 421.50116 166.824997 424.88266 177 427.399658 C 187.175003 429.916656 200.449997 432.864655 206.5 433.950775 C 212.550003 435.036896 221.550003 436.377319 226.5 436.929504 C 231.449997 437.481689 241.350006 438.46051 248.5 439.104675 C 256.607147 439.835083 270.156616 440.060425 284.5 439.703461 C 297.763824 439.373352 311.521454 438.469299 317 437.56781 C 322.225006 436.708008 331 434.605408 336.5 432.895386 C 342 431.185333 349.424988 428.45224 353 426.821869 C 356.575012 425.191498 361.75 422.78241 364.5 421.468353 C 367.25 420.154297 372.440887 416.632446 376.035309 413.642029 C 379.923035 410.407593 383.626404 406.239136 385.176788 403.352478 C 386.610199 400.683624 388.82962 395.208862 390.108826 391.18631 C 392.043091 385.103973 392.427551 381.771362 392.392365 371.391907 C 392.368134 364.243286 391.617584 354.764648 390.63559 349.205566 C 389.692627 343.867493 388.22879 335.674988 387.382629 331 C 386.536469 326.325012 384.929169 318.225006 383.810822 313 C 382.692505 307.774994 380.661194 299 379.296814 293.5 C 377.932434 288 375.796661 278.774994 374.55069 273 C 373.304718 267.225006 371.555939 258 370.66452 252.5 C 369.773102 247 368.583893 238.419525 368.021881 233.432281 C 367.459839 228.445038 367.007843 219.445038 367.017456 213.432281 C 367.027069 207.419525 367.668945 198.633209 368.443848 193.907166 C 369.21875 189.181091 370.563477 182.881104 371.432129 179.907166 C 372.300781 176.933228 374.471405 171.682648 376.255737 168.239197 C 378.0401 164.795746 381.511963 159.235352 383.971008 155.882751 C 386.430054 152.530182 392.055054 146.895081 396.471008 143.360352 C 400.886963 139.825592 408.100006 135.196167 412.5 133.072693 C 416.899994 130.949249 424.549988 127.878998 429.5 126.249969 C 434.450012 124.620911 444.125 122.492981 451 121.521179 C 457.875 120.549408 467.100006 119.697083 471.5 119.627167 L 479.5 119.5 Z" />\n <path\n id="path2"\n fill="#B6BCC4"\n fill-rule="evenodd"\n stroke="none"\n d="M 116 375.742615 C 113.270905 375.979401 110.6278 374.942505 104 371.035126 C 99.324997 368.278992 92.867485 364.331085 89.649971 362.261993 C 86.432457 360.192871 83.16996 357.284851 82.399971 355.799683 C 81.305717 353.689026 81 347.452454 81 327.240784 C 81 306.114777 81.26738 301.027008 82.460983 299.441132 C 83.890869 297.541321 84.034538 297.562286 89.210983 300.426575 C 92.119942 302.036163 97.425003 305.010712 101 307.036682 C 104.574997 309.062622 110.100868 312.245667 113.279701 314.110107 C 116.458542 315.974548 123.533379 320.200012 129.001572 323.5 C 134.469757 326.799988 142.838348 331.745026 147.59845 334.488953 C 152.358566 337.232849 158.333725 340.837097 160.876587 342.498352 C 163.445404 344.176575 165.630447 346.4263 165.793533 347.560852 C 166.040268 349.277313 162.373489 351.662323 142.793533 362.520905 C 128.02803 370.709534 118.218613 375.55014 116 375.742615 Z" />\n <path\n id="path3"\n fill="#aaffaa"\n fill-rule="evenodd"\n stroke="none"\n d="M 185.255783 329 C 184.243942 329 179.609955 326.806396 174.958038 324.125366 C 170.306122 321.444336 152.324997 310.802734 135 300.477417 C 117.675003 290.152069 100.349998 279.633148 96.5 277.102051 C 90.249817 272.99295 89.471245 272.125092 89.231583 269 C 89.029724 266.367798 90.047935 263.640442 93.338226 258 C 95.744507 253.875 114.914024 221.924988 135.937164 187 C 156.960297 152.075012 175.408127 121.924988 176.932327 120 C 179.126877 117.228363 180.520828 116.438263 183.630585 116.203308 C 187.107788 115.940613 189.902344 117.306458 208.028793 128.128174 C 219.287949 134.850037 238.175003 146.155121 250 153.25058 C 261.825012 160.346039 273.075012 167.400116 275 168.926331 C 277.098694 170.590271 278.626709 172.762299 278.816498 174.351379 C 279.006622 175.943481 277.794708 179.496368 275.780823 183.250732 C 273.937134 186.687836 254.255646 219.779419 232.044174 256.787598 C 209.832703 293.795776 190.632736 325.183258 189.377579 326.537598 C 188.122437 327.891907 186.267624 329 185.255783 329 Z" />\n</svg>\n';
|
|
17962
|
+
const iconP2PSubtractSvg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- Generated by Pixelmator Pro 3.7 -->\n\n<svg\n width="512"\n height="512"\n viewBox="0 0 512 512"\n version="1.1"\n id="svg1"\n sodipodi:docname="icon-p2p-subtract.svg"\n inkscape:version="1.4.2 (ebf0e940, 2025-05-08)"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <defs\n id="defs1" />\n <sodipodi:namedview\n id="namedview1"\n pagecolor="#ffffff"\n bordercolor="#000000"\n borderopacity="0.25"\n inkscape:showpageshadow="2"\n inkscape:pageopacity="0.0"\n inkscape:pagecheckerboard="0"\n inkscape:deskcolor="#d1d1d1"\n inkscape:zoom="0.57779708"\n inkscape:cx="236.24211"\n inkscape:cy="80.478081"\n inkscape:window-width="1200"\n inkscape:window-height="770"\n inkscape:window-x="218"\n inkscape:window-y="226"\n inkscape:window-maximized="0"\n inkscape:current-layer="svg1"\n showguides="true">\n <sodipodi:guide\n position="294.40467,66.478038"\n orientation="0,-1"\n id="guide1"\n inkscape:locked="false" />\n <sodipodi:guide\n position="443.95598,219.9443"\n orientation="1,0"\n id="guide2"\n inkscape:locked="false" />\n <sodipodi:guide\n position="479.19058,322.51614"\n orientation="1,0"\n id="guide3"\n inkscape:locked="false" />\n <sodipodi:guide\n position="292.83869,31.243437"\n orientation="0,-1"\n id="guide4"\n inkscape:locked="false" />\n <sodipodi:guide\n position="263.86802,466.58651"\n orientation="0,-1"\n id="guide5"\n inkscape:locked="false" />\n <sodipodi:guide\n position="261.51904,432.1349"\n orientation="0,-1"\n id="guide6"\n inkscape:locked="false" />\n <sodipodi:guide\n position="32.885628,329.56306"\n orientation="1,0"\n id="guide7"\n inkscape:locked="false" />\n </sodipodi:namedview>\n <path\n id="path2"\n fill="#000000"\n fill-rule="evenodd"\n stroke="none"\n d="m 193.81183,478.59424 c -90.05259,0.005 -55.41437,-0.20995 -62.99516,-0.88359 -3.1082,-0.2762 -27.10921,-21.64334 -46.819084,-41.47757 -19.70986,-19.83423 -38.405351,-39.29924 -41.545547,-43.25557 -3.140161,-3.95634 -6.620273,-10.71524 -7.733575,-15.01969 -1.731782,-6.69578 -1.640384,-9.15249 0.632805,-17.00722 2.629257,-9.08499 3.6462,-10.16288 97.354641,-103.18631 67.81987,-67.32409 96.74165,-95.00594 101.89931,-97.5306 4.69396,-2.29769 10.02467,-3.49792 15.30881,-3.44687 5.93187,0.0573 10.33676,1.33387 16.41655,4.7576 5.37383,3.02609 23.90609,20.08661 52.45656,48.29048 24.28094,23.98618 46.73845,47.41164 49.90564,52.05662 4.53335,6.64854 5.89358,10.35999 6.39341,17.4445 0.53601,7.59755 -0.0725,10.28802 -3.90756,17.27501 -3.19113,5.81394 -24.29994,28.16258 -70.95801,75.12564 -36.52859,36.76731 -66.37253,67.62363 -66.92611,68.17388 -19.82934,19.70981 -39.70971,38.18329 -39.48268,38.68369 z M 278.39348,341.263 c -68.04391,-67.49005 -88.70387,-86.89199 -89.81039,-86.65746 -1.10652,0.23458 -27.94601,26.11747 -59.64337,57.51756 -31.697381,31.40008 -57.438314,57.93966 -57.202104,58.97682 0.23622,1.03714 15.75768,17.2724 34.492134,36.07839 34.06266,34.19266 34.06266,34.19266 53.59952,34.19266 19.53691,0 19.53691,0 55.27489,-35.28546 19.65593,-19.40699 41.93704,-41.9313 49.51367,-50.05396 z m 60.93865,-60.02398 c -66.90002,-66.62079 -87.2881,-86.35609 -88.46817,-86.83735 -1.29064,-0.52641 -8.78712,5.68385 -18.81344,15.58544 l -16.66788,16.46053 44.40871,44.02713 c 24.42482,24.21491 44.78655,44.02712 45.24827,44.02712 0.46173,0 8.36641,-7.48416 17.56604,-16.63144 z"\n style="stroke-width:1.5931"\n sodipodi:nodetypes="csssssssscssssssccsssssssccsscsscc" />\n <path\n style="fill:#800000;fill-opacity:1;stroke:#010101;stroke-width:7.48758"\n d="m 214.60419,225.76607 35.34452,-32.835 89.30798,87.87273 -34.08219,33.77315 z"\n id="path3" />\n <path\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n d="m 238.70454,480.61597 240.58456,-0.0328 0,-435.375911 L 32.679361,44.8696 32.918466,80.474658 444.02166,79.593154 443.68404,445.58764 274.55795,445.01091 Z"\n id="path7"\n sodipodi:nodetypes="ccccccccc" />\n <circle\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path8"\n cx="460.39642"\n cy="461.54739"\n r="39.133694" />\n <circle\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path8-8"\n cx="460.77478"\n cy="65.833855"\n r="39.133694" />\n <circle\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path8-8-0"\n cx="67.175827"\n cy="62.81522"\n r="39.133694" />\n</svg>\n';
|
|
17963
|
+
const iconDrawSvg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- Generated by Pixelmator Pro 3.7 -->\n\n<svg\n width="512"\n height="512"\n viewBox="0 0 512 512"\n version="1.1"\n id="svg1"\n sodipodi:docname="icon-draw.svg"\n inkscape:version="1.4.2 (ebf0e940, 2025-05-08)"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <defs\n id="defs1" />\n <sodipodi:namedview\n id="namedview1"\n pagecolor="#ffffff"\n bordercolor="#000000"\n borderopacity="0.25"\n inkscape:showpageshadow="2"\n inkscape:pageopacity="0.0"\n inkscape:pagecheckerboard="0"\n inkscape:deskcolor="#d1d1d1"\n inkscape:zoom="1.4901425"\n inkscape:cx="137.2352"\n inkscape:cy="249.97609"\n inkscape:window-width="1728"\n inkscape:window-height="1056"\n inkscape:window-x="0"\n inkscape:window-y="61"\n inkscape:window-maximized="0"\n inkscape:current-layer="svg1" />\n <path\n id="Shape"\n fill="#000000"\n fill-rule="evenodd"\n stroke="none"\n d="M 73.574318 425.686768 C 72.433441 425.875031 69.474998 425.094574 67 423.952454 C 64.525002 422.810333 61.487499 420.925354 60.25 419.763611 C 58 417.651367 58 417.651367 58 348.144531 C 58 278.637695 58 278.637695 64.15226 268.068848 C 67.536011 262.255981 73.313545 252.549988 76.991226 246.5 C 80.668915 240.450012 89.670906 225.375 96.995644 213 C 104.320389 200.625 112.662483 186.674988 115.533646 182 C 118.4048 177.325012 128.697449 160.120361 138.406174 143.767456 C 148.114914 127.414551 163.517715 101.539551 172.634628 86.267456 C 181.751526 70.995361 190.896469 56.245453 192.956696 53.489868 C 195.254944 50.415955 198.736298 47.372833 201.964966 45.615601 C 205.547699 43.665619 209.185913 42.598907 213.363663 42.27356 C 218.336411 41.886292 220.809326 42.291656 226.404907 44.411316 C 230.202591 45.849945 237.402588 49.329651 242.404907 52.144043 C 247.407211 54.958435 255.774994 59.756927 261 62.807404 C 266.225006 65.857849 274.774994 70.941406 280 74.104187 C 285.225006 77.266937 292.061249 81.349854 295.191681 83.177338 C 298.322083 85.004791 304.593597 88.698059 309.128387 91.384552 C 313.663147 94.071075 319.525085 98.281769 322.154938 100.741699 C 325.42041 103.796173 327.611938 107.003418 329.066864 110.857117 C 330.739197 115.286774 331.103424 118.018188 330.760925 123.56131 C 330.43689 128.805359 329.575104 132.072418 327.412292 136.25589 C 325.810547 139.354187 318.023956 152.826599 310.108765 166.19458 C 302.193604 179.562561 293.868591 193.52121 291.608765 197.213776 C 289.348938 200.906342 284.985504 208.106354 281.912231 213.213776 C 278.838959 218.321198 270.711334 231.950012 263.8508 243.5 C 256.990295 255.049988 247.400177 271.25 242.539444 279.5 C 237.678696 287.75 231.360229 298.325012 228.498383 303 C 225.636551 307.674988 220.191147 316.829224 216.397522 323.342712 C 212.603882 329.856201 205.890396 341.105133 201.478653 348.340332 C 193.756912 361.003967 193.215347 361.63028 186.978653 365.109344 C 183.41539 367.097076 171.620941 373.526276 160.768753 379.396423 C 149.916565 385.266602 131.916565 395.056671 120.768745 401.1521 C 109.620934 407.247559 94.90844 415.184448 88.074318 418.789642 C 81.240189 422.394806 74.715187 425.498535 73.574318 425.686768 Z M 116 376.754456 C 118.096039 376.543518 128.525452 371.474579 142 364.117859 C 154.375 357.361481 165.393753 350.964722 166.486115 349.902863 C 167.980591 348.450134 168.219772 347.57196 167.452347 346.355347 C 166.891403 345.466064 160.147644 341.00293 152.466217 336.437256 C 144.784805 331.871613 135.350006 326.168945 131.5 323.764709 C 127.650002 321.360443 116.453964 314.692322 106.619926 308.946655 C 96.785881 303.200989 87.533401 297.970886 86.058846 297.324219 C 84.417702 296.604492 82.819748 296.493042 81.938927 297.036957 C 80.957619 297.642883 80.340988 300.480957 80 305.960907 C 79.724998 310.380402 79.653214 323.273193 79.840477 334.611572 C 80.180962 355.226837 80.180962 355.226837 83.340477 358.518677 C 85.078217 360.329193 92.349998 365.252136 99.5 369.458588 C 110.254417 375.785583 113.104576 377.045837 116 376.754456 Z M 184.979996 329 C 185.880753 329 187.322388 328.4375 188.183624 327.75 C 189.044861 327.0625 191.986755 322.899994 194.721161 318.5 C 197.455582 314.100006 212.197037 289.575012 227.47995 264 C 242.762863 238.424988 257.119476 214.503387 259.383514 210.840851 C 261.647583 207.178284 265.524994 200.687805 268 196.417542 C 270.475006 192.147247 273.957123 186.14389 275.738068 183.076691 C 277.523224 180.002289 278.981506 176.072205 278.988068 174.317993 C 278.999237 171.335541 278.294434 170.703522 267.75 164.240753 C 261.5625 160.448364 253.125 155.321045 249 152.84668 C 244.875 150.372314 235.754837 144.907379 228.732956 140.702332 C 221.71109 136.497284 212.486084 130.958221 208.232956 128.39328 C 203.979828 125.828369 197.371674 121.899323 193.548157 119.662079 C 189.72464 117.424835 185.418167 115.421448 183.978195 115.210114 C 181.979828 114.916809 180.644867 115.640442 178.338669 118.267059 C 176.676895 120.159729 172.969727 125.711395 170.10054 130.604126 C 167.231339 135.496857 162.066681 144.159821 158.62352 149.855194 C 155.180359 155.550537 149.634521 164.775543 146.299438 170.355194 C 142.964355 175.934845 136.29039 187.024994 131.468384 195 C 126.646393 202.975006 120.571129 213.100006 117.967812 217.5 C 115.364487 221.899994 109.518463 231.575012 104.976639 239 C 100.434822 246.424988 94.708519 255.988464 92.251534 260.252167 C 88.991837 265.908813 87.948189 268.65741 88.390656 270.420349 C 88.845047 272.230804 92.629936 274.990234 103.491547 281.429932 C 111.463524 286.156433 124.176689 293.686981 131.743027 298.16452 C 139.309357 302.642059 149.324997 308.65036 154 311.516296 C 158.675003 314.382263 167.189499 319.488525 172.921127 322.863556 C 178.65274 326.238586 184.079239 329 184.979996 329 Z M 285.661102 134.977844 C 287.97934 134.99408 289.512512 134.179626 291.411102 131.923279 C 292.908417 130.143829 294 127.609955 294 125.913757 C 294 123.644043 293.152191 122.405426 290.25 120.435181 C 288.1875 119.034973 283.720306 116.145264 280.322876 114.01358 C 276.925446 111.881897 270.400452 107.99884 265.822876 105.384521 C 261.2453 102.770203 255.024994 98.976471 252 96.954041 C 248.975006 94.93161 244.25 92.081146 241.5 90.61969 C 238.75 89.158264 233.350006 85.931335 229.5 83.448761 C 224.476532 80.209473 221.661926 79.01474 219.531921 79.217499 C 217.432587 79.417297 215.882141 80.515015 214.234802 82.967804 C 212.798111 85.106964 212.019608 87.555267 212.202881 89.357971 C 212.456848 91.855927 213.807068 93.077637 221.5 97.770203 C 226.449997 100.789642 237.024994 107.196594 245 112.007874 C 252.975006 116.819153 264.674988 123.950684 271 127.855682 C 278.806824 132.675537 283.515167 134.962799 285.661102 134.977844 Z"\n style="stroke:#000000;stroke-opacity:1;stroke-width:20;stroke-dasharray:none" />\n <path\n id="path1"\n fill="#000000"\n fill-rule="evenodd"\n stroke="none"\n d="M 479.5 119.5 C 479.5 153.5 479.5 153.5 472.5 153.761627 C 468.649994 153.905518 461.225006 154.708954 456 155.547028 C 450.774994 156.385132 443.466675 157.966583 439.759277 159.061371 C 436.05188 160.156189 430.343719 162.619598 427.074493 164.535645 C 423.805267 166.451691 419.672913 169.245789 417.891449 170.744781 C 416.110016 172.243774 412.965179 176.08078 410.902954 179.271454 C 408.507751 182.977295 406.493622 187.858795 405.326721 192.786346 C 403.980774 198.469788 403.509888 204.334198 403.537537 215.067841 C 403.560455 223.970093 404.286011 234.276245 405.403107 241.567841 C 406.408508 248.130524 408.366913 258.674988 409.755096 265 C 411.14325 271.325012 412.907196 279.200012 413.674927 282.5 C 414.442657 285.799988 416.815094 297.049988 418.946991 307.5 C 421.078888 317.950012 423.76297 332.401184 424.911591 339.613708 C 426.481873 349.47406 427 357.319122 427 371.235504 C 427 387.630524 426.716309 390.871338 424.515106 399.621765 C 423.148407 405.05481 420.216461 413.182556 417.999634 417.683472 C 415.167511 423.433655 411.734741 428.242035 406.454742 433.854706 C 401.146912 439.496948 395.939392 443.700836 388.720215 448.171234 C 383.099091 451.652039 375.575012 455.78241 372 457.349823 C 368.424988 458.917206 361.261017 461.749329 356.080017 463.643402 C 350.899017 465.537445 342.574005 467.951355 337.580017 469.007568 C 332.585999 470.063812 324 471.644897 318.5 472.521088 C 311.866943 473.57782 299.745911 474.237183 282.5 474.479462 C 268.200012 474.680359 252 474.489349 246.5 474.054932 C 241 473.620544 230.875 472.51828 224 471.605438 C 217.125 470.692596 207.424561 469.276886 202.443451 468.459412 C 197.462357 467.641907 190.037354 466.282959 185.943451 465.439453 C 181.849548 464.595978 176.25 463.281586 173.5 462.518616 C 170.75 461.755646 165.800003 460.43631 162.5 459.586731 C 159.199997 458.737183 152 456.93927 146.5 455.59137 C 141 454.243469 130.649994 451.291107 123.5 449.030579 C 116.349998 446.77002 108.587502 444.226166 106.25 443.377533 C 103.345978 442.323242 102 441.251038 102 439.992004 C 102 438.763947 105.25164 436.022705 111.75 431.772461 C 117.112503 428.265137 124.951981 423.494568 129.171066 421.171265 C 136.842117 416.947052 136.842117 416.947052 147.671066 419.885193 C 153.626984 421.50116 166.824997 424.88266 177 427.399658 C 187.175003 429.916656 200.449997 432.864655 206.5 433.950775 C 212.550003 435.036896 221.550003 436.377319 226.5 436.929504 C 231.449997 437.481689 241.350006 438.46051 248.5 439.104675 C 256.607147 439.835083 270.156616 440.060425 284.5 439.703461 C 297.763824 439.373352 311.521454 438.469299 317 437.56781 C 322.225006 436.708008 331 434.605408 336.5 432.895386 C 342 431.185333 349.424988 428.45224 353 426.821869 C 356.575012 425.191498 361.75 422.78241 364.5 421.468353 C 367.25 420.154297 372.440887 416.632446 376.035309 413.642029 C 379.923035 410.407593 383.626404 406.239136 385.176788 403.352478 C 386.610199 400.683624 388.82962 395.208862 390.108826 391.18631 C 392.043091 385.103973 392.427551 381.771362 392.392365 371.391907 C 392.368134 364.243286 391.617584 354.764648 390.63559 349.205566 C 389.692627 343.867493 388.22879 335.674988 387.382629 331 C 386.536469 326.325012 384.929169 318.225006 383.810822 313 C 382.692505 307.774994 380.661194 299 379.296814 293.5 C 377.932434 288 375.796661 278.774994 374.55069 273 C 373.304718 267.225006 371.555939 258 370.66452 252.5 C 369.773102 247 368.583893 238.419525 368.021881 233.432281 C 367.459839 228.445038 367.007843 219.445038 367.017456 213.432281 C 367.027069 207.419525 367.668945 198.633209 368.443848 193.907166 C 369.21875 189.181091 370.563477 182.881104 371.432129 179.907166 C 372.300781 176.933228 374.471405 171.682648 376.255737 168.239197 C 378.0401 164.795746 381.511963 159.235352 383.971008 155.882751 C 386.430054 152.530182 392.055054 146.895081 396.471008 143.360352 C 400.886963 139.825592 408.100006 135.196167 412.5 133.072693 C 416.899994 130.949249 424.549988 127.878998 429.5 126.249969 C 434.450012 124.620911 444.125 122.492981 451 121.521179 C 457.875 120.549408 467.100006 119.697083 471.5 119.627167 L 479.5 119.5 Z" />\n <path\n id="path2"\n fill="#B6BCC4"\n fill-rule="evenodd"\n stroke="none"\n d="M 116 375.742615 C 113.270905 375.979401 110.6278 374.942505 104 371.035126 C 99.324997 368.278992 92.867485 364.331085 89.649971 362.261993 C 86.432457 360.192871 83.16996 357.284851 82.399971 355.799683 C 81.305717 353.689026 81 347.452454 81 327.240784 C 81 306.114777 81.26738 301.027008 82.460983 299.441132 C 83.890869 297.541321 84.034538 297.562286 89.210983 300.426575 C 92.119942 302.036163 97.425003 305.010712 101 307.036682 C 104.574997 309.062622 110.100868 312.245667 113.279701 314.110107 C 116.458542 315.974548 123.533379 320.200012 129.001572 323.5 C 134.469757 326.799988 142.838348 331.745026 147.59845 334.488953 C 152.358566 337.232849 158.333725 340.837097 160.876587 342.498352 C 163.445404 344.176575 165.630447 346.4263 165.793533 347.560852 C 166.040268 349.277313 162.373489 351.662323 142.793533 362.520905 C 128.02803 370.709534 118.218613 375.55014 116 375.742615 Z" />\n</svg>\n';
|
|
17964
|
+
const iconSubtractSvg = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M15.0722 3.9967L20.7508 9.83395L17.0544 13.5304L13.0758 17.5H21.0041V19H7.93503L4.00195 15.0669L15.0722 3.9967ZM10.952 17.5L15.4628 12.9994L11.8268 9.3634L6.12327 15.0669L8.55635 17.5H10.952Z" fill="#1F2328"></path> </g></svg>\n';
|
|
17965
|
+
const iconP2PDrawSvg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- Generated by Pixelmator Pro 3.7 -->\n\n<svg\n width="512"\n height="512"\n viewBox="0 0 512 512"\n version="1.1"\n id="svg1"\n sodipodi:docname="icon-p2p-draw.svg"\n inkscape:version="1.4.2 (ebf0e940, 2025-05-08)"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <defs\n id="defs1" />\n <sodipodi:namedview\n id="namedview1"\n pagecolor="#ffffff"\n bordercolor="#000000"\n borderopacity="0.25"\n inkscape:showpageshadow="2"\n inkscape:pageopacity="0.0"\n inkscape:pagecheckerboard="0"\n inkscape:deskcolor="#d1d1d1"\n inkscape:zoom="0.54892083"\n inkscape:cx="330.64878"\n inkscape:cy="521.93319"\n inkscape:window-width="1200"\n inkscape:window-height="770"\n inkscape:window-x="197"\n inkscape:window-y="106"\n inkscape:window-maximized="0"\n inkscape:current-layer="svg1"\n showguides="true">\n <sodipodi:guide\n position="294.40467,66.478038"\n orientation="0,-1"\n id="guide1"\n inkscape:locked="false" />\n <sodipodi:guide\n position="443.95598,219.9443"\n orientation="1,0"\n id="guide2"\n inkscape:locked="false" />\n <sodipodi:guide\n position="479.19058,322.51614"\n orientation="1,0"\n id="guide3"\n inkscape:locked="false" />\n <sodipodi:guide\n position="292.83869,31.243437"\n orientation="0,-1"\n id="guide4"\n inkscape:locked="false" />\n <sodipodi:guide\n position="263.86802,466.58651"\n orientation="0,-1"\n id="guide5"\n inkscape:locked="false" />\n <sodipodi:guide\n position="261.51904,432.1349"\n orientation="0,-1"\n id="guide6"\n inkscape:locked="false" />\n <sodipodi:guide\n position="32.885628,329.56306"\n orientation="1,0"\n id="guide7"\n inkscape:locked="false" />\n </sodipodi:namedview>\n <path\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n d="m 155.32706,480.61597 323.96204,-0.0328 V 45.207259 L 32.679361,44.8696 32.918466,80.474658 444.02166,79.593154 443.68404,445.58764 274.55795,445.01091 Z"\n id="path7"\n sodipodi:nodetypes="ccccccccc" />\n <circle\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path8"\n cx="460.39642"\n cy="461.54739"\n r="39.133694" />\n <circle\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path8-8"\n cx="460.77478"\n cy="65.833855"\n r="39.133694" />\n <circle\n style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path8-8-0"\n cx="67.175827"\n cy="62.81522"\n r="39.133694" />\n <path\n id="path2"\n fill="#000000"\n fill-rule="evenodd"\n stroke="none"\n d="m 78.98285,469.62959 c -2.15438,0.59403 -4.66097,-0.18539 -6.41628,-1.99508 -1.75454,-1.80897 -2.51146,-4.39507 -1.93619,-6.61526 0.51947,-2.00492 2.03533,-7.53933 3.36857,-12.29873 1.33325,-4.75939 4.30224,-15.27334 6.59779,-23.36429 2.29555,-8.09095 6.15891,-21.33074 8.58529,-29.42169 2.42637,-8.09095 6.68243,-22.49895 9.45793,-32.01774 2.77548,-9.51878 6.84771,-23.53737 9.04937,-31.15238 2.20168,-7.61501 5.9929,-20.46541 8.42494,-28.55636 2.43204,-8.09095 5.73937,-19.44463 7.34962,-25.23035 1.61019,-5.78571 4.963,-13.27069 7.45058,-16.63326 3.19549,-4.31937 8.82764,-8.13446 19.19001,-12.99886 8.06689,-3.78683 22.22096,-10.28684 31.45345,-14.44449 9.23249,-4.15765 20.18557,-9.15989 24.34021,-11.11606 4.15463,-1.95616 10.95307,-5.04935 15.10771,-6.87384 4.15464,-1.82444 8.50009,-4.18148 9.65667,-5.23786 1.67549,-1.53041 1.53724,-3.40502 -0.68062,-9.22612 -2.27058,-5.95966 -2.43594,-8.49812 -0.89757,-13.77907 1.22082,-4.19103 5.93592,-10.61436 13.37263,-18.21733 6.77176,-6.92313 13.88209,-12.5016 17.32193,-13.59009 4.56226,-1.44363 7.10301,-1.27942 11.64815,0.75263 3.42626,1.5319 23.38864,20.75839 48.61827,46.82593 23.54283,24.3248 45.07136,47.06101 47.84109,50.52486 3.87236,4.84285 5.0359,8.02217 5.0359,13.76037 0,6.66353 -0.98839,8.54701 -9.23249,17.59373 -5.07785,5.57218 -11.80914,12.26634 -14.95838,14.87589 -4.16093,3.44791 -7.61435,4.74461 -12.63592,4.74461 -3.8005,0 -8.65254,-1.25835 -10.78224,-2.79631 -2.1797,-1.57404 -4.50585,-2.14145 -5.3218,-1.29801 -0.79727,0.82403 -5.18683,10.45458 -9.75461,21.4012 -4.56774,10.94662 -11.46849,27.28897 -15.33492,36.3164 -3.86636,9.02739 -10.0263,22.88636 -13.68865,30.79773 -4.61767,9.97496 -8.2174,15.36144 -11.7432,17.57213 -2.79644,1.75334 -10.87912,5.15636 -17.96148,7.56231 -7.0824,2.40588 -20.43095,6.74835 -29.66344,9.64992 -9.2325,2.90152 -25.66143,8.03285 -36.50872,11.40295 -10.8473,3.37012 -31.2427,9.76063 -45.32314,14.20118 -14.08045,4.4406 -32.77692,10.28616 -41.54781,12.9901 -8.77088,2.70399 -17.53807,5.35501 -19.48265,5.89124 z m 33.10612,-25.66048 c 3.12446,-0.52416 14.55766,-3.75462 25.40714,-7.17876 10.84946,-3.4242 33.51103,-10.53042 50.35905,-15.79168 16.84799,-5.2612 39.69735,-12.37246 50.77636,-15.80282 14.11491,-4.3703 21.4678,-7.59596 24.56816,-10.77783 2.43353,-2.49749 8.0037,-13.10782 12.3782,-23.57846 4.37444,-10.47065 10.39747,-24.87865 13.3844,-32.01773 2.98694,-7.13909 8.32653,-19.60006 11.86571,-27.69101 3.53919,-8.09095 6.70998,-17.0473 7.04619,-19.90292 0.55531,-4.71704 -2.16136,-8.0423 -29.69233,-36.34445 -16.66695,-17.1338 -31.77968,-31.39614 -33.58378,-31.69408 -1.80414,-0.29788 -24.6359,9.2685 -50.73726,21.25867 -26.10136,11.99017 -49.09048,23.38251 -51.08698,25.31628 -1.99652,1.93377 -4.8623,7.74509 -6.36841,12.91403 -1.50609,5.16898 -4.69492,16.21648 -7.08629,24.55002 -2.39131,8.33358 -6.53304,22.55059 -9.20379,31.59346 -2.67075,9.04286 -9.07606,30.84953 -14.23398,48.45926 -5.15796,17.60974 -10.02791,34.72173 -10.82216,38.02655 -0.79426,3.30483 -1.1287,6.33395 -0.7432,6.73146 0.38545,0.39738 3.17643,-1.23918 6.20211,-3.63684 3.02568,-2.39771 17.96511,-17.53251 33.19873,-33.63296 15.23362,-16.1004 31.64089,-33.57371 36.46062,-38.82946 8.52144,-9.29247 8.71621,-9.73111 7.06247,-15.9062 -1.16333,-4.34377 -1.14253,-8.48706 0.0656,-13.11331 1.09469,-4.19134 4.27547,-9.10021 8.36474,-12.90922 3.64809,-3.39805 9.2643,-6.66174 12.56077,-7.29928 4.51031,-0.87242 7.90041,-0.1587 13.9207,2.93089 4.84417,2.48596 9.2219,6.36014 11.18725,9.90054 1.77588,3.19904 3.29934,9.20131 3.38545,13.33846 0.0891,4.28531 -1.16789,10.05847 -2.92143,13.41647 -1.69287,3.24193 -6.10927,7.65094 -9.81417,9.79783 -5.66863,3.2847 -8.24032,3.72914 -16.22634,2.80428 -9.49006,-1.09911 -9.49006,-1.09911 -49.7773,40.47775 -22.15799,22.86729 -40.57747,42.46953 -40.93217,43.56045 -0.43839,1.34819 1.17468,1.67829 5.03591,1.03061 z m 90.33008,-98.22453 c 3.35455,0 6.05979,-1.50174 8.52436,-4.73208 2.60114,-3.40941 3.33739,-6.13886 2.63399,-9.76503 -0.53698,-2.76815 -2.29563,-6.0656 -3.90813,-7.32768 -1.61249,-1.26211 -5.13852,-2.31954 -7.83556,-2.34981 -2.69703,-0.0303 -6.28515,1.23389 -7.97352,2.80925 -1.80844,1.68737 -3.06977,5.24293 -3.06977,8.65344 0,3.48156 1.33823,7.16888 3.35727,9.25053 1.84652,1.90378 5.56862,3.46138 8.27136,3.46138 z m 133.61012,-53.65133 c 1.97597,0 7.95481,-4.72004 14.17476,-11.19037 10.06607,-10.47129 10.6202,-11.45446 8.62363,-15.30071 -1.17346,-2.26069 -22.06639,-24.65026 -46.42867,-49.7546 -28.88352,-29.76325 -45.48253,-45.6442 -47.70791,-45.6442 -1.91767,0 -7.85057,4.5222 -13.54224,10.32229 -7.35863,7.49881 -9.99677,11.39096 -9.64468,14.22899 0.30251,2.43813 17.51825,21.46819 45.79618,50.62263 29.62007,30.53813 46.49498,46.71597 48.72893,46.71597 z"\n style="stroke:#010101;stroke-width:17.0446;stroke-dasharray:none;stroke-opacity:1" />\n <path\n style="fill:#008000;fill-opacity:1;stroke:none;stroke-width:18.6862;stroke-dasharray:none;stroke-opacity:1"\n d="m 243.54683,189.37604 16.45863,-15.44233 96.74466,96.71773 -16.45865,16.25509 z"\n id="path3" />\n <circle\n style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:35;stroke-dasharray:none;stroke-opacity:1"\n id="path9"\n cx="201.17783"\n cy="332.21527"\n r="13.593097" />\n</svg>\n';
|
|
17966
|
+
const iconEraseSvg = '<?xml version="1.0" encoding="utf-8"?>\n<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">\n<style type="text/css">\n .st0{fill:#000000}\n .st1{fill:#333333;fill-opacity:0;}\n</style>\n<title>trash</title>\n<rect class="st1" width="48" height="48"/>\n<polygon class="st0" points="26.6,10 26.6,7.8 21.4,7.8 21.4,10 12.6,10 12.6,12.8 35.4,12.8 35.4,10 "/>\n<path class="st0" d="M35.4,15.4H12.6v4.3h1.8V37c0,1.1,0.9,2,2,2h15.2c1.1,0,2-0.9,2-2V19.7h1.8V15.4z M19.7,34.2c0,0.5-0.4,1-1,1\n c-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1c0.5,0,1,0.4,1,1V34.2z M25.3,33.8c0,0.7-0.6,1.3-1.3,1.3c-0.7,0-1.3-0.6-1.3-1.3V23\n c0-0.7,0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3V33.8z M30.3,34.2c0,0.5-0.4,1-1,1c-0.5,0-1-0.4-1-1V22.6c0-0.5,0.4-1,1-1\n c0.5,0,1,0.4,1,1V34.2z"/>\n</svg>\n';
|
|
17967
|
+
const iconCollapseSvg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- Generated by Pixelmator Pro 3.7 -->\n\n<svg\n width="512"\n height="512"\n viewBox="0 0 512 512"\n version="1.1"\n id="svg1"\n sodipodi:docname="icon-collapse.svg"\n inkscape:version="1.4.2 (ebf0e940, 2025-05-08)"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <defs\n id="defs1" />\n <sodipodi:namedview\n id="namedview1"\n pagecolor="#ffffff"\n bordercolor="#000000"\n borderopacity="0.25"\n inkscape:showpageshadow="2"\n inkscape:pageopacity="0.0"\n inkscape:pagecheckerboard="0"\n inkscape:deskcolor="#d1d1d1"\n inkscape:zoom="3.390154"\n inkscape:cx="264.14729"\n inkscape:cy="179.04791"\n inkscape:window-width="1352"\n inkscape:window-height="797"\n inkscape:window-x="66"\n inkscape:window-y="34"\n inkscape:window-maximized="0"\n inkscape:current-layer="svg1"\n showguides="true">\n <sodipodi:guide\n position="166.90161,256"\n orientation="0,1"\n id="guide2"\n inkscape:locked="false"\n inkscape:label=""\n inkscape:color="rgb(0,134,229)" />\n <sodipodi:guide\n position="256,314.14084"\n orientation="-1,0"\n id="guide3"\n inkscape:locked="false"\n inkscape:label=""\n inkscape:color="rgb(0,134,229)" />\n <sodipodi:guide\n position="299.13272,431.6881"\n orientation="0,-1"\n id="guide4"\n inkscape:locked="false" />\n <sodipodi:guide\n position="80,297.83494"\n orientation="-1,0"\n id="guide5"\n inkscape:locked="false"\n inkscape:label=""\n inkscape:color="rgb(0,134,229)" />\n <sodipodi:guide\n position="432,400.26171"\n orientation="-1,0"\n id="guide6"\n inkscape:locked="false"\n inkscape:label=""\n inkscape:color="rgb(0,134,229)" />\n </sodipodi:namedview>\n <path\n style="fill:none;stroke:#000000;stroke-width:25;stroke-dasharray:none;stroke-opacity:1"\n d="M 80.032872,292.14907 255.78789,117.55799 431.54291,292.14907 v 0 0"\n id="path6" />\n <path\n style="fill:none;stroke:#000000;stroke-width:25;stroke-dasharray:none;stroke-opacity:1"\n d="M 80.104821,394.53856 255.85984,219.94748 431.61486,394.53856 v 0 0"\n id="path6-5" />\n</svg>\n';
|
|
17968
|
+
const sanitizeSvg = (svg) => svg.replace(/<\?xml[^>]*\?>\s*/g, "").replace(/<!--[\s\S]*?-->/g, "").trim();
|
|
17969
|
+
const icons = {
|
|
17970
|
+
activate: sanitizeSvg(iconPolydraw2Svg),
|
|
17971
|
+
draw: sanitizeSvg(iconDrawSvg),
|
|
17972
|
+
subtract: sanitizeSvg(iconSubtractSvg),
|
|
17973
|
+
p2p: sanitizeSvg(iconP2PDrawSvg),
|
|
17974
|
+
p2pSubtract: sanitizeSvg(iconP2PSubtractSvg),
|
|
17975
|
+
erase: sanitizeSvg(iconEraseSvg),
|
|
17976
|
+
collapse: sanitizeSvg(iconCollapseSvg)
|
|
17977
|
+
};
|
|
17978
|
+
const setButtonIcon = (button, svgMarkup) => {
|
|
17979
|
+
button.innerHTML = svgMarkup;
|
|
17980
|
+
const svgElement = button.querySelector("svg");
|
|
17981
|
+
if (!svgElement) return;
|
|
17982
|
+
svgElement.setAttribute("width", "24");
|
|
17983
|
+
svgElement.setAttribute("height", "24");
|
|
17984
|
+
svgElement.style.pointerEvents = "none";
|
|
17985
|
+
svgElement.querySelectorAll("*").forEach((el) => {
|
|
17986
|
+
el.style.pointerEvents = "none";
|
|
17987
|
+
});
|
|
17988
|
+
};
|
|
17989
|
+
function createButtons(container, subContainer, config, onActivateToggle, onDrawClick, onSubtractClick, onEraseClick, onPointToPointClick, onPointToPointSubtractClick) {
|
|
17990
|
+
const activate = leafletAdapter.domUtil.create(
|
|
17991
|
+
"a",
|
|
17992
|
+
"icon-activate",
|
|
17993
|
+
container
|
|
17994
|
+
);
|
|
17995
|
+
activate.href = "#";
|
|
17996
|
+
activate.title = "Activate";
|
|
17997
|
+
setButtonIcon(activate, icons.activate);
|
|
17998
|
+
activate.dataset.activeIcon = icons.activate;
|
|
17999
|
+
activate.dataset.collapsedIcon = icons.collapse;
|
|
18000
|
+
L$1.DomEvent.on(activate, "mousedown", L$1.DomEvent.stopPropagation);
|
|
18001
|
+
L$1.DomEvent.on(activate, "touchstart", L$1.DomEvent.stopPropagation);
|
|
18002
|
+
L$1.DomEvent.on(activate, "click", L$1.DomEvent.stop).on(activate, "click", onActivateToggle);
|
|
18003
|
+
if (config.modes.draw) {
|
|
18004
|
+
const draw = leafletAdapter.domUtil.create("a", "icon-draw", subContainer);
|
|
18005
|
+
draw.href = "#";
|
|
18006
|
+
draw.title = "Draw";
|
|
18007
|
+
setButtonIcon(draw, icons.draw);
|
|
18008
|
+
L$1.DomEvent.on(draw, "mousedown", L$1.DomEvent.stopPropagation);
|
|
18009
|
+
L$1.DomEvent.on(draw, "touchstart", L$1.DomEvent.stopPropagation);
|
|
18010
|
+
L$1.DomEvent.on(draw, "click", L$1.DomEvent.stopPropagation);
|
|
18011
|
+
L$1.DomEvent.on(draw, "click", L$1.DomEvent.stop);
|
|
18012
|
+
L$1.DomEvent.on(draw, "click", onDrawClick);
|
|
18013
|
+
}
|
|
18014
|
+
if (config.modes.subtract) {
|
|
18015
|
+
const subtract = leafletAdapter.domUtil.create(
|
|
18016
|
+
"a",
|
|
18017
|
+
"icon-subtract",
|
|
18018
|
+
subContainer
|
|
18019
|
+
);
|
|
18020
|
+
subtract.href = "#";
|
|
18021
|
+
subtract.title = "Subtract";
|
|
18022
|
+
setButtonIcon(subtract, icons.subtract);
|
|
18023
|
+
L$1.DomEvent.on(subtract, "mousedown", L$1.DomEvent.stopPropagation);
|
|
18024
|
+
L$1.DomEvent.on(subtract, "touchstart", L$1.DomEvent.stopPropagation);
|
|
18025
|
+
L$1.DomEvent.on(subtract, "click", L$1.DomEvent.stopPropagation);
|
|
18026
|
+
L$1.DomEvent.on(subtract, "click", L$1.DomEvent.stop);
|
|
18027
|
+
L$1.DomEvent.on(subtract, "click", onSubtractClick);
|
|
18028
|
+
}
|
|
18029
|
+
if (config.modes.p2p) {
|
|
18030
|
+
const p2p = leafletAdapter.domUtil.create("a", "icon-p2p", subContainer);
|
|
18031
|
+
p2p.href = "#";
|
|
18032
|
+
p2p.title = "Point to Point";
|
|
18033
|
+
setButtonIcon(p2p, icons.p2p);
|
|
18034
|
+
L$1.DomEvent.on(p2p, "mousedown", L$1.DomEvent.stopPropagation);
|
|
18035
|
+
L$1.DomEvent.on(p2p, "touchstart", L$1.DomEvent.stopPropagation);
|
|
18036
|
+
L$1.DomEvent.on(p2p, "click", L$1.DomEvent.stopPropagation);
|
|
18037
|
+
L$1.DomEvent.on(p2p, "click", L$1.DomEvent.stop);
|
|
18038
|
+
L$1.DomEvent.on(p2p, "click", onPointToPointClick);
|
|
18039
|
+
}
|
|
18040
|
+
if (config.modes.p2pSubtract) {
|
|
18041
|
+
const p2pSubtract = leafletAdapter.domUtil.create(
|
|
18042
|
+
"a",
|
|
18043
|
+
"icon-p2p-subtract",
|
|
18044
|
+
subContainer
|
|
18045
|
+
);
|
|
18046
|
+
p2pSubtract.href = "#";
|
|
18047
|
+
p2pSubtract.title = "Point to Point Subtract";
|
|
18048
|
+
setButtonIcon(p2pSubtract, icons.p2pSubtract);
|
|
18049
|
+
L$1.DomEvent.on(p2pSubtract, "mousedown", L$1.DomEvent.stopPropagation);
|
|
18050
|
+
L$1.DomEvent.on(p2pSubtract, "touchstart", L$1.DomEvent.stopPropagation);
|
|
18051
|
+
L$1.DomEvent.on(p2pSubtract, "click", L$1.DomEvent.stopPropagation);
|
|
18052
|
+
L$1.DomEvent.on(p2pSubtract, "click", L$1.DomEvent.stop);
|
|
18053
|
+
L$1.DomEvent.on(p2pSubtract, "click", onPointToPointSubtractClick);
|
|
18054
|
+
}
|
|
18055
|
+
if (config.modes.deleteAll) {
|
|
18056
|
+
const erase = leafletAdapter.domUtil.create(
|
|
18057
|
+
"a",
|
|
18058
|
+
"icon-erase",
|
|
18059
|
+
subContainer
|
|
18060
|
+
);
|
|
18061
|
+
erase.href = "#";
|
|
18062
|
+
erase.title = "Erase All";
|
|
18063
|
+
setButtonIcon(erase, icons.erase);
|
|
18064
|
+
L$1.DomEvent.on(erase, "mousedown", L$1.DomEvent.stopPropagation);
|
|
18065
|
+
L$1.DomEvent.on(erase, "touchstart", L$1.DomEvent.stopPropagation);
|
|
18066
|
+
L$1.DomEvent.on(erase, "click", L$1.DomEvent.stopPropagation);
|
|
18067
|
+
L$1.DomEvent.on(erase, "click", L$1.DomEvent.stop);
|
|
18068
|
+
L$1.DomEvent.on(erase, "click", onEraseClick);
|
|
18069
|
+
}
|
|
18070
|
+
}
|
|
18071
|
+
class PolygonUtil {
|
|
18072
|
+
/**
|
|
18073
|
+
* Calculates the center of the polygon.
|
|
18074
|
+
* @param polygon Array of LatLng points.
|
|
18075
|
+
* @returns The center LatLng.
|
|
18076
|
+
*/
|
|
18077
|
+
static getCenter(polygon2) {
|
|
18078
|
+
let x = 0;
|
|
18079
|
+
let y = 0;
|
|
18080
|
+
let z = 0;
|
|
18081
|
+
polygon2.forEach((v) => {
|
|
18082
|
+
let lat1 = v.lat;
|
|
18083
|
+
let lon1 = v.lng;
|
|
18084
|
+
lat1 = lat1 * MATH.DEG_TO_RAD;
|
|
18085
|
+
lon1 = lon1 * MATH.DEG_TO_RAD;
|
|
18086
|
+
x += Math.cos(lat1) * Math.cos(lon1);
|
|
18087
|
+
y += Math.cos(lat1) * Math.sin(lon1);
|
|
18088
|
+
z += Math.sin(lat1);
|
|
18089
|
+
});
|
|
18090
|
+
let lng = Math.atan2(y, x);
|
|
18091
|
+
const hyp = Math.sqrt(x * x + y * y);
|
|
18092
|
+
let lat = Math.atan2(z, hyp);
|
|
18093
|
+
lat = lat * MATH.RAD_TO_DEG;
|
|
18094
|
+
lng = lng * MATH.RAD_TO_DEG;
|
|
18095
|
+
const center2 = { lat, lng };
|
|
18096
|
+
return center2;
|
|
18097
|
+
}
|
|
18098
|
+
/**
|
|
18099
|
+
* Gets the southwest point of the polygon bounds.
|
|
18100
|
+
* @param polygon Array of LatLng points.
|
|
18101
|
+
* @returns The southwest LatLng.
|
|
18102
|
+
*/
|
|
18103
|
+
static getSouthWest(polygon2) {
|
|
18104
|
+
const bounds = this.getBounds(polygon2);
|
|
18105
|
+
return bounds.getSouthWest();
|
|
18106
|
+
}
|
|
18107
|
+
static getNorthEast(polygon2) {
|
|
18108
|
+
const bounds = this.getBounds(polygon2);
|
|
18109
|
+
return bounds.getNorthEast();
|
|
18110
|
+
}
|
|
18111
|
+
static getNorthWest(polygon2) {
|
|
18112
|
+
const bounds = this.getBounds(polygon2);
|
|
18113
|
+
return bounds.getNorthWest();
|
|
18114
|
+
}
|
|
18115
|
+
static getSouthEast(polygon2) {
|
|
18116
|
+
const bounds = this.getBounds(polygon2);
|
|
18117
|
+
return bounds.getSouthEast();
|
|
18118
|
+
}
|
|
18119
|
+
static getNorth(polygon2) {
|
|
18120
|
+
const bounds = this.getBounds(polygon2);
|
|
18121
|
+
return bounds.getNorth();
|
|
18122
|
+
}
|
|
18123
|
+
static getSouth(polygon2) {
|
|
18124
|
+
const bounds = this.getBounds(polygon2);
|
|
18125
|
+
return bounds.getSouth();
|
|
18126
|
+
}
|
|
18127
|
+
static getWest(polygon2) {
|
|
18128
|
+
const bounds = this.getBounds(polygon2);
|
|
18129
|
+
return bounds.getWest();
|
|
18130
|
+
}
|
|
18131
|
+
static getEast(polygon2) {
|
|
18132
|
+
const bounds = this.getBounds(polygon2);
|
|
18133
|
+
return bounds.getEast();
|
|
18134
|
+
}
|
|
18135
|
+
static getSqmArea(polygon2) {
|
|
18136
|
+
const poly = new L$1.Polygon(polygon2);
|
|
18137
|
+
const geoJsonPoly = poly.toGeoJSON();
|
|
18138
|
+
const area2 = this.turfHelper.getPolygonArea(geoJsonPoly);
|
|
18139
|
+
return area2;
|
|
18140
|
+
}
|
|
18141
|
+
static getPerimeter(polygon2) {
|
|
18142
|
+
const poly = new L$1.Polygon(polygon2);
|
|
18143
|
+
const geoJsonPoly = poly.toGeoJSON();
|
|
18144
|
+
const perimeter = this.turfHelper.getPolygonPerimeter(geoJsonPoly);
|
|
18145
|
+
return perimeter * 1e3;
|
|
17380
18146
|
}
|
|
17381
18147
|
static getPolygonChecksum(polygon2) {
|
|
17382
18148
|
const uniqueLatLngs = polygon2.filter((v, i, a) => {
|
|
@@ -17399,7 +18165,7 @@ class PolygonUtil {
|
|
|
17399
18165
|
if (isNaN(ll.lat) || isNaN(ll.lng)) ;
|
|
17400
18166
|
tmpLatLng.push(ll);
|
|
17401
18167
|
});
|
|
17402
|
-
const polyLine = new L.Polyline(tmpLatLng);
|
|
18168
|
+
const polyLine = new L$1.Polyline(tmpLatLng);
|
|
17403
18169
|
const bounds = polyLine.getBounds();
|
|
17404
18170
|
return bounds;
|
|
17405
18171
|
}
|
|
@@ -17415,6 +18181,60 @@ class PolygonUtil {
|
|
|
17415
18181
|
lng: centerOfMass2.geometry.coordinates[0]
|
|
17416
18182
|
};
|
|
17417
18183
|
}
|
|
18184
|
+
static getCenterOfPolygonByIndexWithOffsetFromCenterOfMass(polygon2, index) {
|
|
18185
|
+
const centerOfMass2 = this.turfHelper.getCenterOfMass(polygon2);
|
|
18186
|
+
const centerLatLng = {
|
|
18187
|
+
lat: centerOfMass2.geometry.coordinates[1],
|
|
18188
|
+
lng: centerOfMass2.geometry.coordinates[0]
|
|
18189
|
+
};
|
|
18190
|
+
const centerOfPolygonMarker = this.getPolygonLatLngAtIndex(polygon2, index) ?? centerLatLng;
|
|
18191
|
+
const offset = {
|
|
18192
|
+
lat: centerOfPolygonMarker.lat - centerLatLng.lat,
|
|
18193
|
+
lng: centerOfPolygonMarker.lng - centerLatLng.lng
|
|
18194
|
+
};
|
|
18195
|
+
const offsetFraction = 0.5;
|
|
18196
|
+
const adjustedLat = centerLatLng.lat + offset.lat * offsetFraction;
|
|
18197
|
+
const adjustedLng = centerLatLng.lng + offset.lng * offsetFraction;
|
|
18198
|
+
const newCenterOfMass = {
|
|
18199
|
+
geometry: {
|
|
18200
|
+
coordinates: [adjustedLng, adjustedLat]
|
|
18201
|
+
}
|
|
18202
|
+
};
|
|
18203
|
+
return {
|
|
18204
|
+
lat: newCenterOfMass.geometry.coordinates[1],
|
|
18205
|
+
lng: newCenterOfMass.geometry.coordinates[0]
|
|
18206
|
+
};
|
|
18207
|
+
}
|
|
18208
|
+
static getPolygonLatLngAtIndex(polygon2, index) {
|
|
18209
|
+
const geometry = polygon2.geometry;
|
|
18210
|
+
if (!geometry) {
|
|
18211
|
+
return null;
|
|
18212
|
+
}
|
|
18213
|
+
let coordinates;
|
|
18214
|
+
if (geometry.type === "Polygon") {
|
|
18215
|
+
coordinates = geometry.coordinates[0];
|
|
18216
|
+
} else if (geometry.type === "MultiPolygon") {
|
|
18217
|
+
coordinates = geometry.coordinates[0][0];
|
|
18218
|
+
} else {
|
|
18219
|
+
return null;
|
|
18220
|
+
}
|
|
18221
|
+
if (!coordinates || coordinates.length === 0) {
|
|
18222
|
+
return null;
|
|
18223
|
+
}
|
|
18224
|
+
if (coordinates.length > 1) {
|
|
18225
|
+
const first = coordinates[0];
|
|
18226
|
+
const last = coordinates[coordinates.length - 1];
|
|
18227
|
+
if (first[0] === last[0] && first[1] === last[1]) {
|
|
18228
|
+
coordinates = coordinates.slice(0, coordinates.length - 1);
|
|
18229
|
+
}
|
|
18230
|
+
}
|
|
18231
|
+
if (coordinates.length === 0) {
|
|
18232
|
+
return null;
|
|
18233
|
+
}
|
|
18234
|
+
const normalizedIndex = (index % coordinates.length + coordinates.length) % coordinates.length;
|
|
18235
|
+
const selected = coordinates[normalizedIndex];
|
|
18236
|
+
return { lat: selected[1], lng: selected[0] };
|
|
18237
|
+
}
|
|
17418
18238
|
}
|
|
17419
18239
|
__publicField(PolygonUtil, "turfHelper", new TurfHelper(defaultConfig));
|
|
17420
18240
|
class PolygonInfo {
|
|
@@ -17723,6 +18543,7 @@ class ModeManager {
|
|
|
17723
18543
|
this.setDrawingModeState();
|
|
17724
18544
|
break;
|
|
17725
18545
|
case DrawMode.PointToPoint:
|
|
18546
|
+
case DrawMode.PointToPointSubtract:
|
|
17726
18547
|
this.setPointToPointModeState();
|
|
17727
18548
|
break;
|
|
17728
18549
|
}
|
|
@@ -17952,15 +18773,15 @@ class PolygonDrawManager {
|
|
|
17952
18773
|
try {
|
|
17953
18774
|
const isFirstMarker = this.p2pMarkers.length === 0;
|
|
17954
18775
|
const markerClassName = isFirstMarker ? "leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker" : "leaflet-polydraw-p2p-marker";
|
|
17955
|
-
const pointMarker = new L.Marker(clickLatLng, {
|
|
17956
|
-
icon:
|
|
18776
|
+
const pointMarker = new L$1.Marker(clickLatLng, {
|
|
18777
|
+
icon: leafletAdapter.createDivIcon({
|
|
17957
18778
|
className: markerClassName,
|
|
17958
18779
|
iconSize: isFirstMarker ? [20, 20] : [16, 16]
|
|
17959
18780
|
}),
|
|
17960
18781
|
draggable: this.config.modes.dragElbow
|
|
17961
18782
|
}).addTo(this.map);
|
|
17962
18783
|
pointMarker.on("mousedown", (e) => {
|
|
17963
|
-
L.DomEvent.stopPropagation(e);
|
|
18784
|
+
L$1.DomEvent.stopPropagation(e);
|
|
17964
18785
|
});
|
|
17965
18786
|
pointMarker.on("drag", () => {
|
|
17966
18787
|
this.updateP2PTracer();
|
|
@@ -17968,7 +18789,7 @@ class PolygonDrawManager {
|
|
|
17968
18789
|
pointMarker.on("click", (e) => {
|
|
17969
18790
|
if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
|
|
17970
18791
|
this.deleteP2PMarker(pointMarker);
|
|
17971
|
-
L.DomEvent.stopPropagation(e);
|
|
18792
|
+
L$1.DomEvent.stopPropagation(e);
|
|
17972
18793
|
}
|
|
17973
18794
|
});
|
|
17974
18795
|
pointMarker.on("mouseover", () => this.onMarkerHoverForEdgeDeletion(pointMarker, true));
|
|
@@ -17997,11 +18818,11 @@ class PolygonDrawManager {
|
|
|
17997
18818
|
pointMarker.on("click", (e) => {
|
|
17998
18819
|
if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
|
|
17999
18820
|
this.deleteP2PMarker(pointMarker);
|
|
18000
|
-
L.DomEvent.stopPropagation(e);
|
|
18821
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18001
18822
|
return;
|
|
18002
18823
|
}
|
|
18003
18824
|
if (this.p2pMarkers.length >= 3) {
|
|
18004
|
-
L.DomEvent.stopPropagation(e);
|
|
18825
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18005
18826
|
this.completePointToPointPolygon();
|
|
18006
18827
|
}
|
|
18007
18828
|
});
|
|
@@ -18015,7 +18836,18 @@ class PolygonDrawManager {
|
|
|
18015
18836
|
* Handle double-click to complete point-to-point polygon
|
|
18016
18837
|
*/
|
|
18017
18838
|
handleDoubleClick(e) {
|
|
18018
|
-
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint) {
|
|
18839
|
+
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint && this.modeManager.getCurrentMode() !== DrawMode.PointToPointSubtract) {
|
|
18840
|
+
return;
|
|
18841
|
+
}
|
|
18842
|
+
if (this.p2pMarkers.length >= 3) {
|
|
18843
|
+
this.completePointToPointPolygon();
|
|
18844
|
+
}
|
|
18845
|
+
}
|
|
18846
|
+
/**
|
|
18847
|
+
* Handle double-tap to complete point-to-point polygon (touch devices)
|
|
18848
|
+
*/
|
|
18849
|
+
handleDoubleTap(_e) {
|
|
18850
|
+
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint && this.modeManager.getCurrentMode() !== DrawMode.PointToPointSubtract) {
|
|
18019
18851
|
return;
|
|
18020
18852
|
}
|
|
18021
18853
|
if (this.p2pMarkers.length >= 3) {
|
|
@@ -18043,7 +18875,7 @@ class PolygonDrawManager {
|
|
|
18043
18875
|
this.resetTracer();
|
|
18044
18876
|
this.eventManager.emit("polydraw:polygon:created", {
|
|
18045
18877
|
polygon: geoPos,
|
|
18046
|
-
mode:
|
|
18878
|
+
mode: this.modeManager.getCurrentMode(),
|
|
18047
18879
|
isPointToPoint: true
|
|
18048
18880
|
});
|
|
18049
18881
|
} catch (error) {
|
|
@@ -18090,12 +18922,22 @@ class PolygonDrawManager {
|
|
|
18090
18922
|
if (!firstPoint) return false;
|
|
18091
18923
|
const zoom = this.map.getZoom();
|
|
18092
18924
|
const baseTolerance = 5e-4;
|
|
18093
|
-
|
|
18925
|
+
let tolerance = baseTolerance / Math.pow(2, Math.max(0, zoom - 10));
|
|
18926
|
+
if (this.isTouchDevice()) {
|
|
18927
|
+
tolerance *= 5;
|
|
18928
|
+
}
|
|
18929
|
+
tolerance *= 3;
|
|
18094
18930
|
const latDiff = Math.abs(clickLatLng.lat - firstPoint.lat);
|
|
18095
18931
|
const lngDiff = Math.abs(clickLatLng.lng - firstPoint.lng);
|
|
18096
18932
|
const isClicking = latDiff < tolerance && lngDiff < tolerance;
|
|
18097
18933
|
return isClicking;
|
|
18098
18934
|
}
|
|
18935
|
+
/**
|
|
18936
|
+
* Check if the current device supports touch
|
|
18937
|
+
*/
|
|
18938
|
+
isTouchDevice() {
|
|
18939
|
+
return isTouchDevice();
|
|
18940
|
+
}
|
|
18099
18941
|
/**
|
|
18100
18942
|
* Update the tracer polyline based on P2P markers
|
|
18101
18943
|
*/
|
|
@@ -18104,8 +18946,10 @@ class PolygonDrawManager {
|
|
|
18104
18946
|
this.tracer.setLatLngs(latlngs);
|
|
18105
18947
|
if (this.p2pMarkers.length >= 2) {
|
|
18106
18948
|
try {
|
|
18949
|
+
const currentMode = this.modeManager.getCurrentMode();
|
|
18950
|
+
const lineColor = currentMode === DrawMode.PointToPointSubtract ? this.config.colors.subtractLine : this.config.colors.polyline;
|
|
18107
18951
|
this.tracer.setStyle({
|
|
18108
|
-
color:
|
|
18952
|
+
color: lineColor,
|
|
18109
18953
|
dashArray: "5, 5"
|
|
18110
18954
|
});
|
|
18111
18955
|
} catch (error) {
|
|
@@ -18143,7 +18987,8 @@ class PolygonDrawManager {
|
|
|
18143
18987
|
* Check if currently in point-to-point drawing mode
|
|
18144
18988
|
*/
|
|
18145
18989
|
isInPointToPointMode() {
|
|
18146
|
-
|
|
18990
|
+
const mode = this.modeManager.getCurrentMode();
|
|
18991
|
+
return mode === DrawMode.PointToPoint || mode === DrawMode.PointToPointSubtract;
|
|
18147
18992
|
}
|
|
18148
18993
|
/**
|
|
18149
18994
|
* Get current tracer points count
|
|
@@ -18162,7 +19007,7 @@ class PolygonDrawManager {
|
|
|
18162
19007
|
if (element) {
|
|
18163
19008
|
element.classList.add("leaflet-polydraw-p2p-first-marker");
|
|
18164
19009
|
firstMarker.setIcon(
|
|
18165
|
-
|
|
19010
|
+
leafletAdapter.createDivIcon({
|
|
18166
19011
|
className: "leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker",
|
|
18167
19012
|
iconSize: [20, 20]
|
|
18168
19013
|
})
|
|
@@ -18194,11 +19039,11 @@ class PolygonDrawManager {
|
|
|
18194
19039
|
firstMarker.on("click", (e) => {
|
|
18195
19040
|
if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
|
|
18196
19041
|
this.deleteP2PMarker(firstMarker);
|
|
18197
|
-
L.DomEvent.stopPropagation(e);
|
|
19042
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18198
19043
|
return;
|
|
18199
19044
|
}
|
|
18200
19045
|
if (this.p2pMarkers.length >= 3) {
|
|
18201
|
-
L.DomEvent.stopPropagation(e);
|
|
19046
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18202
19047
|
this.completePointToPointPolygon();
|
|
18203
19048
|
}
|
|
18204
19049
|
});
|
|
@@ -18561,7 +19406,688 @@ class IconFactory {
|
|
|
18561
19406
|
*/
|
|
18562
19407
|
static createDivIcon(classNames) {
|
|
18563
19408
|
const classes = classNames.join(" ");
|
|
18564
|
-
return
|
|
19409
|
+
return leafletAdapter.createDivIcon({ className: classes });
|
|
19410
|
+
}
|
|
19411
|
+
}
|
|
19412
|
+
var TransformHandleType = /* @__PURE__ */ ((TransformHandleType2) => {
|
|
19413
|
+
TransformHandleType2["TopLeft"] = "top-left";
|
|
19414
|
+
TransformHandleType2["Top"] = "top";
|
|
19415
|
+
TransformHandleType2["TopRight"] = "top-right";
|
|
19416
|
+
TransformHandleType2["Right"] = "right";
|
|
19417
|
+
TransformHandleType2["BottomRight"] = "bottom-right";
|
|
19418
|
+
TransformHandleType2["Bottom"] = "bottom";
|
|
19419
|
+
TransformHandleType2["BottomLeft"] = "bottom-left";
|
|
19420
|
+
TransformHandleType2["Left"] = "left";
|
|
19421
|
+
TransformHandleType2["Rotate"] = "rotate";
|
|
19422
|
+
TransformHandleType2["Pivot"] = "pivot";
|
|
19423
|
+
return TransformHandleType2;
|
|
19424
|
+
})(TransformHandleType || {});
|
|
19425
|
+
const cancelIconSvg = '<?xml version="1.0" encoding="UTF-8"?>\n<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">\n <circle cx="256" cy="256" r="236" fill="#212A32"/>\n <circle cx="256" cy="256" r="190" fill="#ffffff"/>\n <path id="path2" fill="#800000" fill-rule="evenodd" stroke="none"\n d="M 156 373.906311 C 140.875 373.871002 127.9375 373.615112 127.25 373.337708 C 126.5625 373.060303 126 372.072937 126 371.143555 C 126 370.214203 146.628433 343.53772 171.840973 311.862488 C 197.053513 280.187286 217.991867 253.463562 218.370667 252.47644 C 218.806335 251.341125 218.221786 249.464233 216.779678 247.368073 C 215.525864 245.545563 196.612503 221.361847 174.75 193.626465 C 152.887497 165.891052 135 142.531311 135 141.715881 C 135 140.900421 136.012497 139.961914 137.25 139.63028 C 138.487503 139.298645 152.408203 139.021179 168.184906 139.013641 C 184.588272 139.005859 197.976456 139.420746 199.454529 139.982727 C 201.182831 140.639801 210.486664 152.319733 227.533463 175.232727 C 241.555283 194.079712 253.994949 210.166199 255.177185 210.980438 C 257.208252 212.379272 257.562622 212.186401 261.607452 207.480438 C 263.961853 204.74118 276.052643 189 288.47583 172.5 C 300.899048 156 312.286682 141.714874 313.781738 140.75528 C 316.198669 139.203949 319.554993 139.009949 344.058868 139.00528 C 366.27774 139.001007 371.993561 139.274811 373.557343 140.418274 C 375.458923 141.808746 375.448914 141.90155 373.046875 145.150452 C 371.699341 146.973114 352.828827 170.746307 331.112396 197.979767 C 309.395966 225.213257 291.465973 248.396271 291.267914 249.497589 C 291.012512 250.91803 304.435944 268.61731 337.453918 310.395416 C 363.05426 342.787903 384 370.077271 384 371.038422 C 384 371.999603 383.288208 373.059174 382.418213 373.393005 C 381.548218 373.726868 367.485718 373.993347 351.168213 373.98526 C 329.591888 373.974548 320.854309 373.633606 319.132629 372.73526 C 317.830597 372.055847 302.980591 353.049988 286.132629 330.5 C 260.059052 295.602051 255.12793 289.5 253 289.5 C 250.878326 289.5 245.808807 295.701355 219.5 330.479431 C 202.449997 353.018127 187.375 372.023987 186 372.714691 C 184.165009 373.636475 176.184906 373.95343 156 373.906311 Z"/>\n</svg>';
|
|
19426
|
+
const confirmIconSvg = '<?xml version="1.0" encoding="UTF-8"?>\n<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">\n <circle cx="256" cy="256" r="236" fill="#212A32"/>\n <circle cx="256" cy="256" r="190" fill="#ffffff"/>\n <path id="check" fill="#008000" fill-rule="evenodd" stroke="none"\n d="M 223.844696 360 C 222.79425 360 204.506973 341.170593 178.987274 313.812744 \n C 144.992401 277.369232 135.966232 267.145691 136.201645 265.351257 \n C 136.396179 263.868408 143.092361 257.073425 155.444672 245.824249 \n C 166.363129 235.880859 175.214264 228.571442 176.336426 228.571442 \n C 177.515594 228.571442 181.716553 232.304138 186.987961 238.035706 \n C 191.775406 243.241058 201.629044 254.024994 208.884933 262 \n C 216.140823 269.975006 222.682266 276.635315 223.421478 276.80072 \n C 224.16246 276.966553 247.742722 250.494751 275.976837 217.800751 \n C 304.143097 185.185333 328.050385 157.879608 329.104156 157.121368 \n C 330.785767 155.911316 331.44046 156.0336 334.457672 158.121368 \n C 336.348328 159.429626 345.368622 167.190216 354.502747 175.367126 \n C 367.688812 187.171356 371.047394 190.689819 370.805115 192.445557 \n C 370.635864 193.67218 338.242889 231.469543 298.059082 277.32843 \n C 253.148834 328.581238 224.944153 360 223.844696 360 Z"/>\n</svg>';
|
|
19427
|
+
class TransformOverlay {
|
|
19428
|
+
constructor(map, callbacks, mode, onCancel, onConfirm) {
|
|
19429
|
+
__publicField(this, "map");
|
|
19430
|
+
__publicField(this, "pane");
|
|
19431
|
+
__publicField(this, "root");
|
|
19432
|
+
__publicField(this, "draggingHandle", null);
|
|
19433
|
+
__publicField(this, "callbacks");
|
|
19434
|
+
__publicField(this, "rafId", null);
|
|
19435
|
+
__publicField(this, "mode");
|
|
19436
|
+
__publicField(this, "onCancel");
|
|
19437
|
+
__publicField(this, "onConfirm");
|
|
19438
|
+
__publicField(this, "cancelBtn", null);
|
|
19439
|
+
__publicField(this, "confirmBtn", null);
|
|
19440
|
+
__publicField(this, "currentBBox", null);
|
|
19441
|
+
__publicField(this, "currentRotation", 0);
|
|
19442
|
+
this.map = map;
|
|
19443
|
+
this.callbacks = callbacks;
|
|
19444
|
+
this.mode = mode;
|
|
19445
|
+
this.onCancel = onCancel;
|
|
19446
|
+
this.onConfirm = onConfirm;
|
|
19447
|
+
const paneName = "polydraw-transform";
|
|
19448
|
+
let pane = this.map.getPane ? this.map.getPane(paneName) : void 0;
|
|
19449
|
+
if (!pane) pane = this.map.createPane(paneName);
|
|
19450
|
+
pane.style.zIndex = "650";
|
|
19451
|
+
pane.style.pointerEvents = "none";
|
|
19452
|
+
this.pane = pane;
|
|
19453
|
+
this.root = document.createElement("div");
|
|
19454
|
+
this.root.className = "polydraw-transform-root";
|
|
19455
|
+
this.root.style.position = "absolute";
|
|
19456
|
+
this.root.style.left = "0px";
|
|
19457
|
+
this.root.style.top = "0px";
|
|
19458
|
+
this.pane.appendChild(this.root);
|
|
19459
|
+
}
|
|
19460
|
+
destroy() {
|
|
19461
|
+
if (this.rafId != null) {
|
|
19462
|
+
cancelAnimationFrame(this.rafId);
|
|
19463
|
+
this.rafId = null;
|
|
19464
|
+
}
|
|
19465
|
+
this.root.remove();
|
|
19466
|
+
}
|
|
19467
|
+
update(bbox2, pivot, rotation = 0) {
|
|
19468
|
+
if (this.rafId != null) return;
|
|
19469
|
+
this.rafId = requestAnimationFrame(() => {
|
|
19470
|
+
this.rafId = null;
|
|
19471
|
+
this.render(bbox2, pivot, rotation);
|
|
19472
|
+
if (this.cancelBtn || this.confirmBtn) {
|
|
19473
|
+
const isRotateDrag = this.draggingHandle === TransformHandleType.Rotate && this.mode === "rotate";
|
|
19474
|
+
if (!isRotateDrag) {
|
|
19475
|
+
this.updateButtonPositions(bbox2, rotation);
|
|
19476
|
+
}
|
|
19477
|
+
}
|
|
19478
|
+
});
|
|
19479
|
+
}
|
|
19480
|
+
render(bbox2, _pivot, rotation = 0) {
|
|
19481
|
+
const cancelBtn = this.cancelBtn;
|
|
19482
|
+
const confirmBtn = this.confirmBtn;
|
|
19483
|
+
this.root.innerHTML = "";
|
|
19484
|
+
this.currentBBox = bbox2;
|
|
19485
|
+
this.currentRotation = rotation;
|
|
19486
|
+
this.cancelBtn = cancelBtn;
|
|
19487
|
+
this.confirmBtn = confirmBtn;
|
|
19488
|
+
const width = bbox2.maxX - bbox2.minX;
|
|
19489
|
+
const height = bbox2.maxY - bbox2.minY;
|
|
19490
|
+
const centerX = bbox2.minX + width / 2;
|
|
19491
|
+
const centerY = bbox2.minY + height / 2;
|
|
19492
|
+
const box = document.createElement("div");
|
|
19493
|
+
box.className = "polydraw-transform-box";
|
|
19494
|
+
Object.assign(box.style, {
|
|
19495
|
+
position: "absolute",
|
|
19496
|
+
left: `${centerX}px`,
|
|
19497
|
+
top: `${centerY}px`,
|
|
19498
|
+
width: `${width}px`,
|
|
19499
|
+
height: `${height}px`,
|
|
19500
|
+
marginLeft: `${-width / 2}px`,
|
|
19501
|
+
marginTop: `${-height / 2}px`,
|
|
19502
|
+
border: "1px dashed #2b90d9",
|
|
19503
|
+
pointerEvents: "none",
|
|
19504
|
+
transformOrigin: "center center",
|
|
19505
|
+
transform: `rotate(${rotation * 180 / Math.PI}deg)`
|
|
19506
|
+
});
|
|
19507
|
+
this.root.appendChild(box);
|
|
19508
|
+
const makeHandle = (type, x, y) => {
|
|
19509
|
+
const dx = x - centerX;
|
|
19510
|
+
const dy = y - centerY;
|
|
19511
|
+
const cos2 = Math.cos(rotation);
|
|
19512
|
+
const sin2 = Math.sin(rotation);
|
|
19513
|
+
const rotX = centerX + dx * cos2 - dy * sin2;
|
|
19514
|
+
const rotY = centerY + dx * sin2 + dy * cos2;
|
|
19515
|
+
const h = document.createElement("div");
|
|
19516
|
+
h.className = `polydraw-transform-handle handle-${type}`;
|
|
19517
|
+
Object.assign(h.style, {
|
|
19518
|
+
position: "absolute",
|
|
19519
|
+
left: `${rotX - 5}px`,
|
|
19520
|
+
top: `${rotY - 5}px`,
|
|
19521
|
+
width: "10px",
|
|
19522
|
+
height: "10px",
|
|
19523
|
+
borderRadius: "2px",
|
|
19524
|
+
background: "#2b90d9",
|
|
19525
|
+
boxShadow: "0 0 0 1px #fff",
|
|
19526
|
+
cursor: this.cursorForHandle(type),
|
|
19527
|
+
pointerEvents: "auto"
|
|
19528
|
+
});
|
|
19529
|
+
L$1.DomEvent.on(h, "mousedown", (e) => this.startDrag(type, { x: rotX, y: rotY }, e));
|
|
19530
|
+
L$1.DomEvent.on(h, "touchstart", (e) => this.startDrag(type, { x: rotX, y: rotY }, e));
|
|
19531
|
+
this.root.appendChild(h);
|
|
19532
|
+
};
|
|
19533
|
+
if (this.mode === "scale") {
|
|
19534
|
+
makeHandle(TransformHandleType.TopLeft, bbox2.minX, bbox2.minY);
|
|
19535
|
+
makeHandle(TransformHandleType.TopRight, bbox2.maxX, bbox2.minY);
|
|
19536
|
+
makeHandle(TransformHandleType.BottomRight, bbox2.maxX, bbox2.maxY);
|
|
19537
|
+
makeHandle(TransformHandleType.BottomLeft, bbox2.minX, bbox2.maxY);
|
|
19538
|
+
makeHandle(TransformHandleType.Top, centerX, bbox2.minY);
|
|
19539
|
+
makeHandle(TransformHandleType.Right, bbox2.maxX, centerY);
|
|
19540
|
+
makeHandle(TransformHandleType.Bottom, centerX, bbox2.maxY);
|
|
19541
|
+
makeHandle(TransformHandleType.Left, bbox2.minX, centerY);
|
|
19542
|
+
} else {
|
|
19543
|
+
makeHandle(TransformHandleType.Rotate, bbox2.minX, bbox2.minY);
|
|
19544
|
+
makeHandle(TransformHandleType.Rotate, bbox2.maxX, bbox2.minY);
|
|
19545
|
+
makeHandle(TransformHandleType.Rotate, bbox2.maxX, bbox2.maxY);
|
|
19546
|
+
makeHandle(TransformHandleType.Rotate, bbox2.minX, bbox2.maxY);
|
|
19547
|
+
}
|
|
19548
|
+
if (!this.cancelBtn && !this.confirmBtn) {
|
|
19549
|
+
this.updateButtonPositions(bbox2, rotation);
|
|
19550
|
+
} else {
|
|
19551
|
+
this.updateButtonPositions(bbox2, rotation);
|
|
19552
|
+
if (this.cancelBtn) this.root.appendChild(this.cancelBtn);
|
|
19553
|
+
if (this.confirmBtn) this.root.appendChild(this.confirmBtn);
|
|
19554
|
+
}
|
|
19555
|
+
}
|
|
19556
|
+
cursorForHandle(type) {
|
|
19557
|
+
switch (type) {
|
|
19558
|
+
case TransformHandleType.Top:
|
|
19559
|
+
case TransformHandleType.Bottom:
|
|
19560
|
+
return "ns-resize";
|
|
19561
|
+
case TransformHandleType.Left:
|
|
19562
|
+
case TransformHandleType.Right:
|
|
19563
|
+
return "ew-resize";
|
|
19564
|
+
case TransformHandleType.TopLeft:
|
|
19565
|
+
case TransformHandleType.BottomRight:
|
|
19566
|
+
return "nwse-resize";
|
|
19567
|
+
case TransformHandleType.TopRight:
|
|
19568
|
+
case TransformHandleType.BottomLeft:
|
|
19569
|
+
return "nesw-resize";
|
|
19570
|
+
case TransformHandleType.Rotate:
|
|
19571
|
+
return "grab";
|
|
19572
|
+
case TransformHandleType.Pivot:
|
|
19573
|
+
return "move";
|
|
19574
|
+
default:
|
|
19575
|
+
return "default";
|
|
19576
|
+
}
|
|
19577
|
+
}
|
|
19578
|
+
startDrag(type, start, evt) {
|
|
19579
|
+
var _a2, _b2;
|
|
19580
|
+
(_a2 = evt.stopPropagation) == null ? void 0 : _a2.call(evt);
|
|
19581
|
+
(_b2 = evt.preventDefault) == null ? void 0 : _b2.call(evt);
|
|
19582
|
+
this.draggingHandle = type;
|
|
19583
|
+
if (type === TransformHandleType.Rotate && this.mode === "rotate") {
|
|
19584
|
+
this.hideButtons();
|
|
19585
|
+
}
|
|
19586
|
+
const onMove = (e) => this.onDrag(e);
|
|
19587
|
+
const onUp = (e) => this.endDrag(e);
|
|
19588
|
+
L$1.DomEvent.on(document, "mousemove", onMove);
|
|
19589
|
+
L$1.DomEvent.on(document, "mouseup", onUp);
|
|
19590
|
+
L$1.DomEvent.on(document, "touchmove", onMove);
|
|
19591
|
+
L$1.DomEvent.on(document, "touchend", onUp);
|
|
19592
|
+
this.callbacks.onStartHandleDrag(type, start, evt);
|
|
19593
|
+
}
|
|
19594
|
+
onDrag(evt) {
|
|
19595
|
+
if (this.draggingHandle == null) return;
|
|
19596
|
+
const pos = this.getMouseLayerPoint(evt);
|
|
19597
|
+
this.callbacks.onDragHandle(this.draggingHandle, pos, evt);
|
|
19598
|
+
}
|
|
19599
|
+
endDrag(evt) {
|
|
19600
|
+
if (this.draggingHandle == null) return;
|
|
19601
|
+
const type = this.draggingHandle;
|
|
19602
|
+
const wasRotateDrag = type === TransformHandleType.Rotate && this.mode === "rotate";
|
|
19603
|
+
this.draggingHandle = null;
|
|
19604
|
+
const pos = this.getMouseLayerPoint(evt);
|
|
19605
|
+
this.callbacks.onEndHandleDrag(type, pos, evt);
|
|
19606
|
+
if (wasRotateDrag && this.currentBBox) {
|
|
19607
|
+
this.updateButtonPositions(this.currentBBox, this.currentRotation);
|
|
19608
|
+
this.showButtons();
|
|
19609
|
+
}
|
|
19610
|
+
L$1.DomEvent.off(document, "mousemove", this.onDrag);
|
|
19611
|
+
L$1.DomEvent.off(document, "touchmove", this.onDrag);
|
|
19612
|
+
}
|
|
19613
|
+
getMouseLayerPoint(evt) {
|
|
19614
|
+
const containerPoint = this.map.mouseEventToContainerPoint ? this.map.mouseEventToContainerPoint(evt) : leafletAdapter.domEvent.getMousePosition(evt, this.map.getContainer());
|
|
19615
|
+
const layerPoint = this.map.containerPointToLayerPoint(containerPoint);
|
|
19616
|
+
return { x: layerPoint.x, y: layerPoint.y };
|
|
19617
|
+
}
|
|
19618
|
+
updateButtonPositions(bbox2, rotation) {
|
|
19619
|
+
const width = bbox2.maxX - bbox2.minX;
|
|
19620
|
+
const height = bbox2.maxY - bbox2.minY;
|
|
19621
|
+
const centerX = bbox2.minX + width / 2;
|
|
19622
|
+
const centerY = bbox2.minY + height / 2;
|
|
19623
|
+
const corners = [
|
|
19624
|
+
{ x: bbox2.minX, y: bbox2.minY },
|
|
19625
|
+
// top-left
|
|
19626
|
+
{ x: bbox2.maxX, y: bbox2.minY },
|
|
19627
|
+
// top-right
|
|
19628
|
+
{ x: bbox2.maxX, y: bbox2.maxY },
|
|
19629
|
+
// bottom-right
|
|
19630
|
+
{ x: bbox2.minX, y: bbox2.maxY }
|
|
19631
|
+
// bottom-left
|
|
19632
|
+
];
|
|
19633
|
+
const cos2 = Math.cos(rotation);
|
|
19634
|
+
const sin2 = Math.sin(rotation);
|
|
19635
|
+
let topRightCorner = { x: 0, y: Infinity };
|
|
19636
|
+
let minY = Infinity;
|
|
19637
|
+
for (const corner of corners) {
|
|
19638
|
+
const dx = corner.x - centerX;
|
|
19639
|
+
const dy = corner.y - centerY;
|
|
19640
|
+
const rotX = centerX + dx * cos2 - dy * sin2;
|
|
19641
|
+
const rotY = centerY + dx * sin2 + dy * cos2;
|
|
19642
|
+
const isHigher = rotY < minY;
|
|
19643
|
+
const isSameHeight = Math.abs(rotY - minY) < 1;
|
|
19644
|
+
const isMoreRight = rotX > topRightCorner.x;
|
|
19645
|
+
if (isHigher || isSameHeight && isMoreRight) {
|
|
19646
|
+
minY = rotY;
|
|
19647
|
+
topRightCorner = { x: rotX, y: rotY };
|
|
19648
|
+
}
|
|
19649
|
+
}
|
|
19650
|
+
const rotTopRightX = topRightCorner.x;
|
|
19651
|
+
const rotTopRightY = topRightCorner.y;
|
|
19652
|
+
const buttonY = rotTopRightY - 28;
|
|
19653
|
+
const confirmX = rotTopRightX + 5;
|
|
19654
|
+
const cancelX = rotTopRightX - 29;
|
|
19655
|
+
const cancelSvg = cancelIconSvg;
|
|
19656
|
+
const confirmSvg = confirmIconSvg;
|
|
19657
|
+
if (this.onCancel && !this.cancelBtn) {
|
|
19658
|
+
this.cancelBtn = document.createElement("div");
|
|
19659
|
+
this.cancelBtn.className = "polydraw-transform-cancel";
|
|
19660
|
+
this.cancelBtn.innerHTML = cancelSvg;
|
|
19661
|
+
L$1.DomEvent.on(this.cancelBtn, "mousedown", (e) => {
|
|
19662
|
+
var _a2, _b2;
|
|
19663
|
+
(_a2 = e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
19664
|
+
(_b2 = e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
19665
|
+
this.onCancel && this.onCancel();
|
|
19666
|
+
});
|
|
19667
|
+
L$1.DomEvent.on(this.cancelBtn, "touchstart", (e) => {
|
|
19668
|
+
var _a2, _b2;
|
|
19669
|
+
(_a2 = e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
19670
|
+
(_b2 = e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
19671
|
+
this.onCancel && this.onCancel();
|
|
19672
|
+
});
|
|
19673
|
+
this.root.appendChild(this.cancelBtn);
|
|
19674
|
+
}
|
|
19675
|
+
if (this.onConfirm && !this.confirmBtn) {
|
|
19676
|
+
this.confirmBtn = document.createElement("div");
|
|
19677
|
+
this.confirmBtn.className = "polydraw-transform-confirm";
|
|
19678
|
+
this.confirmBtn.innerHTML = confirmSvg;
|
|
19679
|
+
L$1.DomEvent.on(this.confirmBtn, "mousedown", (e) => {
|
|
19680
|
+
var _a2, _b2;
|
|
19681
|
+
(_a2 = e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
19682
|
+
(_b2 = e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
19683
|
+
this.onConfirm && this.onConfirm();
|
|
19684
|
+
});
|
|
19685
|
+
L$1.DomEvent.on(this.confirmBtn, "touchstart", (e) => {
|
|
19686
|
+
var _a2, _b2;
|
|
19687
|
+
(_a2 = e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
19688
|
+
(_b2 = e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
19689
|
+
this.onConfirm && this.onConfirm();
|
|
19690
|
+
});
|
|
19691
|
+
this.root.appendChild(this.confirmBtn);
|
|
19692
|
+
}
|
|
19693
|
+
if (this.cancelBtn) {
|
|
19694
|
+
Object.assign(this.cancelBtn.style, {
|
|
19695
|
+
position: "absolute",
|
|
19696
|
+
left: `${cancelX}px`,
|
|
19697
|
+
top: `${buttonY}px`
|
|
19698
|
+
});
|
|
19699
|
+
}
|
|
19700
|
+
if (this.confirmBtn) {
|
|
19701
|
+
Object.assign(this.confirmBtn.style, {
|
|
19702
|
+
position: "absolute",
|
|
19703
|
+
left: `${confirmX}px`,
|
|
19704
|
+
top: `${buttonY}px`
|
|
19705
|
+
});
|
|
19706
|
+
}
|
|
19707
|
+
}
|
|
19708
|
+
hideButtons() {
|
|
19709
|
+
if (this.cancelBtn) this.cancelBtn.style.display = "none";
|
|
19710
|
+
if (this.confirmBtn) this.confirmBtn.style.display = "none";
|
|
19711
|
+
}
|
|
19712
|
+
showButtons() {
|
|
19713
|
+
if (this.cancelBtn) this.cancelBtn.style.display = "";
|
|
19714
|
+
if (this.confirmBtn) this.confirmBtn.style.display = "";
|
|
19715
|
+
}
|
|
19716
|
+
}
|
|
19717
|
+
function latLngToPixel(map, ll) {
|
|
19718
|
+
const p = map.latLngToLayerPoint(ll);
|
|
19719
|
+
return { x: p.x, y: p.y };
|
|
19720
|
+
}
|
|
19721
|
+
function pixelToLatLng(map, p) {
|
|
19722
|
+
const ll = map.layerPointToLatLng(leafletAdapter.createPoint(p.x, p.y));
|
|
19723
|
+
return { lat: ll.lat, lng: ll.lng };
|
|
19724
|
+
}
|
|
19725
|
+
function getPixelBBox(rings) {
|
|
19726
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
19727
|
+
for (const poly of rings) {
|
|
19728
|
+
for (const ring of poly) {
|
|
19729
|
+
for (const pt of ring) {
|
|
19730
|
+
if (pt.x < minX) minX = pt.x;
|
|
19731
|
+
if (pt.y < minY) minY = pt.y;
|
|
19732
|
+
if (pt.x > maxX) maxX = pt.x;
|
|
19733
|
+
if (pt.y > maxY) maxY = pt.y;
|
|
19734
|
+
}
|
|
19735
|
+
}
|
|
19736
|
+
}
|
|
19737
|
+
return { minX, minY, maxX, maxY };
|
|
19738
|
+
}
|
|
19739
|
+
function getPixelCentroid(bbox2) {
|
|
19740
|
+
return { x: (bbox2.minX + bbox2.maxX) / 2, y: (bbox2.minY + bbox2.maxY) / 2 };
|
|
19741
|
+
}
|
|
19742
|
+
function rotatePointAround(p, pivot, radians2) {
|
|
19743
|
+
const cos2 = Math.cos(radians2);
|
|
19744
|
+
const sin2 = Math.sin(radians2);
|
|
19745
|
+
const dx = p.x - pivot.x;
|
|
19746
|
+
const dy = p.y - pivot.y;
|
|
19747
|
+
return { x: pivot.x + dx * cos2 - dy * sin2, y: pivot.y + dx * sin2 + dy * cos2 };
|
|
19748
|
+
}
|
|
19749
|
+
function scalePointAround(p, pivot, scaleX, scaleY) {
|
|
19750
|
+
const dx = p.x - pivot.x;
|
|
19751
|
+
const dy = p.y - pivot.y;
|
|
19752
|
+
return { x: pivot.x + dx * scaleX, y: pivot.y + dy * scaleY };
|
|
19753
|
+
}
|
|
19754
|
+
function applyTransform(rings, pivot, scaleX, scaleY, rotation) {
|
|
19755
|
+
return rings.map(
|
|
19756
|
+
(poly) => poly.map(
|
|
19757
|
+
(ring) => ring.map(
|
|
19758
|
+
(pt) => rotatePointAround(scalePointAround(pt, pivot, scaleX, scaleY), pivot, rotation)
|
|
19759
|
+
)
|
|
19760
|
+
)
|
|
19761
|
+
);
|
|
19762
|
+
}
|
|
19763
|
+
function ensureClosedLatLngRing(ll) {
|
|
19764
|
+
if (ll.length === 0) return ll;
|
|
19765
|
+
const first = ll[0];
|
|
19766
|
+
const last = ll[ll.length - 1];
|
|
19767
|
+
if (first.lat === last.lat && first.lng === last.lng) return ll;
|
|
19768
|
+
return [...ll, { lat: first.lat, lng: first.lng }];
|
|
19769
|
+
}
|
|
19770
|
+
function normalizeLatLngs(input) {
|
|
19771
|
+
if (!Array.isArray(input)) {
|
|
19772
|
+
return [[input]];
|
|
19773
|
+
}
|
|
19774
|
+
const a = input;
|
|
19775
|
+
if (a.length === 0) return [];
|
|
19776
|
+
if (!Array.isArray(a[0])) {
|
|
19777
|
+
return [[input]];
|
|
19778
|
+
}
|
|
19779
|
+
if (!Array.isArray(a[0][0])) {
|
|
19780
|
+
return [input];
|
|
19781
|
+
}
|
|
19782
|
+
return input;
|
|
19783
|
+
}
|
|
19784
|
+
function projectLatLngs(map, latLngs) {
|
|
19785
|
+
const rings = [];
|
|
19786
|
+
const ringLengths = [];
|
|
19787
|
+
for (const poly of latLngs) {
|
|
19788
|
+
const polyRings = [];
|
|
19789
|
+
const lengths = [];
|
|
19790
|
+
for (const ring of poly) {
|
|
19791
|
+
const pts = ring.map((ll) => latLngToPixel(map, { lat: ll.lat, lng: ll.lng }));
|
|
19792
|
+
polyRings.push(pts);
|
|
19793
|
+
lengths.push(ring.length);
|
|
19794
|
+
}
|
|
19795
|
+
rings.push(polyRings);
|
|
19796
|
+
ringLengths.push(lengths);
|
|
19797
|
+
}
|
|
19798
|
+
return { rings, ringLengths };
|
|
19799
|
+
}
|
|
19800
|
+
function unprojectToLatLngs(map, rings, templateLatLngs) {
|
|
19801
|
+
const out = [];
|
|
19802
|
+
for (let i = 0; i < rings.length; i++) {
|
|
19803
|
+
const poly = [];
|
|
19804
|
+
for (let j = 0; j < rings[i].length; j++) {
|
|
19805
|
+
const ringPts = rings[i][j];
|
|
19806
|
+
const ll = ringPts.map((p) => pixelToLatLng(map, p));
|
|
19807
|
+
const templ = templateLatLngs[i][j];
|
|
19808
|
+
const isClosed = templ.length > 2 && templ[0].lat === templ[templ.length - 1].lat && templ[0].lng === templ[templ.length - 1].lng;
|
|
19809
|
+
poly.push(isClosed ? ensureClosedLatLngRing(ll) : ll);
|
|
19810
|
+
}
|
|
19811
|
+
out.push(poly);
|
|
19812
|
+
}
|
|
19813
|
+
return out;
|
|
19814
|
+
}
|
|
19815
|
+
function snapAngleRadians(angle, stepDeg = 15) {
|
|
19816
|
+
const step = stepDeg * Math.PI / 180;
|
|
19817
|
+
return Math.round(angle / step) * step;
|
|
19818
|
+
}
|
|
19819
|
+
class PolygonTransformController {
|
|
19820
|
+
constructor(map, featureGroup, mode = "scale", onExit) {
|
|
19821
|
+
__publicField(this, "map");
|
|
19822
|
+
__publicField(this, "polygon");
|
|
19823
|
+
__publicField(this, "overlay");
|
|
19824
|
+
__publicField(this, "state");
|
|
19825
|
+
__publicField(this, "normalizedLatLngs");
|
|
19826
|
+
__publicField(this, "wasMapDraggingEnabled", false);
|
|
19827
|
+
__publicField(this, "mode");
|
|
19828
|
+
__publicField(this, "onExit");
|
|
19829
|
+
__publicField(this, "rotateStartAngle", null);
|
|
19830
|
+
__publicField(this, "rotateBaseRotation", 0);
|
|
19831
|
+
__publicField(this, "onKeyDown", (e) => {
|
|
19832
|
+
if (e.key === "Escape") {
|
|
19833
|
+
this.handleCancel();
|
|
19834
|
+
}
|
|
19835
|
+
});
|
|
19836
|
+
__publicField(this, "updateOverlay", () => {
|
|
19837
|
+
const scaledRings = this.state.originalPixelRings.map(
|
|
19838
|
+
(poly) => poly.map(
|
|
19839
|
+
(ring) => ring.map(
|
|
19840
|
+
(pt) => scalePointAround(pt, this.state.pivot, this.state.scaleX, this.state.scaleY)
|
|
19841
|
+
)
|
|
19842
|
+
)
|
|
19843
|
+
);
|
|
19844
|
+
const bbox2 = getPixelBBox(scaledRings);
|
|
19845
|
+
this.overlay.update(bbox2, this.state.pivot, this.state.rotation);
|
|
19846
|
+
});
|
|
19847
|
+
this.map = map;
|
|
19848
|
+
this.mode = mode;
|
|
19849
|
+
this.onExit = onExit;
|
|
19850
|
+
const polygon2 = featureGroup.getLayers().find((l) => l instanceof L$1.Polygon);
|
|
19851
|
+
if (!polygon2) throw new Error("FeatureGroup does not contain a polygon");
|
|
19852
|
+
this.polygon = polygon2;
|
|
19853
|
+
const originalLatLngs = this.polygon.getLatLngs();
|
|
19854
|
+
this.normalizedLatLngs = normalizeLatLngs(originalLatLngs);
|
|
19855
|
+
const proj = projectLatLngs(this.map, this.normalizedLatLngs);
|
|
19856
|
+
const bbox2 = getPixelBBox(proj.rings);
|
|
19857
|
+
const pivot = getPixelCentroid(bbox2);
|
|
19858
|
+
this.state = {
|
|
19859
|
+
isActive: true,
|
|
19860
|
+
originalLatLngs,
|
|
19861
|
+
originalPixelRings: proj.rings,
|
|
19862
|
+
pivot,
|
|
19863
|
+
scaleX: 1,
|
|
19864
|
+
scaleY: 1,
|
|
19865
|
+
rotation: 0,
|
|
19866
|
+
uniformScale: false,
|
|
19867
|
+
snapRotation: false,
|
|
19868
|
+
scaleFromPivot: false
|
|
19869
|
+
};
|
|
19870
|
+
this.overlay = new TransformOverlay(
|
|
19871
|
+
this.map,
|
|
19872
|
+
{
|
|
19873
|
+
onStartHandleDrag: (type, start, e) => this.onStartDrag(type, start, e),
|
|
19874
|
+
onDragHandle: (type, current, e) => this.onDrag(type, current, e),
|
|
19875
|
+
onEndHandleDrag: (_type, _end, _e) => {
|
|
19876
|
+
}
|
|
19877
|
+
},
|
|
19878
|
+
this.mode,
|
|
19879
|
+
() => this.handleCancel(),
|
|
19880
|
+
() => this.handleConfirm()
|
|
19881
|
+
);
|
|
19882
|
+
this.updateOverlay();
|
|
19883
|
+
this.map.on("zoom viewreset move", this.updateOverlay, this);
|
|
19884
|
+
if (this.map.dragging) {
|
|
19885
|
+
const dragging = this.map.dragging;
|
|
19886
|
+
if (typeof dragging.enabled === "function") {
|
|
19887
|
+
this.wasMapDraggingEnabled = dragging.enabled();
|
|
19888
|
+
}
|
|
19889
|
+
dragging.disable();
|
|
19890
|
+
}
|
|
19891
|
+
document.addEventListener("keydown", this.onKeyDown);
|
|
19892
|
+
}
|
|
19893
|
+
destroy() {
|
|
19894
|
+
document.removeEventListener("keydown", this.onKeyDown);
|
|
19895
|
+
this.map.off("zoom viewreset move", this.updateOverlay, this);
|
|
19896
|
+
this.overlay.destroy();
|
|
19897
|
+
this.state.isActive = false;
|
|
19898
|
+
if (this.map.dragging) {
|
|
19899
|
+
const dragging = this.map.dragging;
|
|
19900
|
+
if (this.wasMapDraggingEnabled && typeof dragging.enable === "function") {
|
|
19901
|
+
dragging.enable();
|
|
19902
|
+
}
|
|
19903
|
+
}
|
|
19904
|
+
}
|
|
19905
|
+
onStartDrag(type, start, evt) {
|
|
19906
|
+
const isMac = navigator.userAgent.toLowerCase().includes("mac");
|
|
19907
|
+
const ctrlOrCmd = isMac ? evt.metaKey : evt.ctrlKey;
|
|
19908
|
+
this.state.uniformScale = !!evt.shiftKey;
|
|
19909
|
+
this.state.scaleFromPivot = !!evt.altKey;
|
|
19910
|
+
this.state.snapRotation = !!ctrlOrCmd;
|
|
19911
|
+
if (type === TransformHandleType.Rotate) {
|
|
19912
|
+
const c = this.state.scaleFromPivot ? this.state.pivot : getPixelCentroid(getPixelBBox(this.state.originalPixelRings));
|
|
19913
|
+
const startAngle = Math.atan2(start.y - c.y, start.x - c.x);
|
|
19914
|
+
this.rotateStartAngle = startAngle;
|
|
19915
|
+
this.rotateBaseRotation = this.state.rotation || 0;
|
|
19916
|
+
}
|
|
19917
|
+
}
|
|
19918
|
+
onDrag(type, current, _evt) {
|
|
19919
|
+
const origBBox = getPixelBBox(this.state.originalPixelRings);
|
|
19920
|
+
switch (type) {
|
|
19921
|
+
case TransformHandleType.Rotate: {
|
|
19922
|
+
const rotationCenter = this.state.scaleFromPivot ? this.state.pivot : getPixelCentroid(origBBox);
|
|
19923
|
+
this.handleRotateDrag(current, rotationCenter);
|
|
19924
|
+
break;
|
|
19925
|
+
}
|
|
19926
|
+
case TransformHandleType.Pivot:
|
|
19927
|
+
this.handlePivotDrag(current);
|
|
19928
|
+
break;
|
|
19929
|
+
default: {
|
|
19930
|
+
const scaleCenter = this.state.scaleFromPivot ? this.state.pivot : getPixelCentroid(origBBox);
|
|
19931
|
+
this.handleScaleDrag(type, current, origBBox, scaleCenter);
|
|
19932
|
+
break;
|
|
19933
|
+
}
|
|
19934
|
+
}
|
|
19935
|
+
this.preview();
|
|
19936
|
+
}
|
|
19937
|
+
handleRotateDrag(current, center2) {
|
|
19938
|
+
if (this.mode !== "rotate") return;
|
|
19939
|
+
const angle = Math.atan2(current.y - center2.y, current.x - center2.x);
|
|
19940
|
+
let theta;
|
|
19941
|
+
if (this.rotateStartAngle != null) {
|
|
19942
|
+
const delta = angle - this.rotateStartAngle;
|
|
19943
|
+
theta = this.rotateBaseRotation + delta;
|
|
19944
|
+
} else {
|
|
19945
|
+
theta = angle;
|
|
19946
|
+
}
|
|
19947
|
+
this.state.rotation = this.state.snapRotation ? snapAngleRadians(theta, 15) : theta;
|
|
19948
|
+
}
|
|
19949
|
+
handlePivotDrag(current) {
|
|
19950
|
+
this.state.pivot = current;
|
|
19951
|
+
}
|
|
19952
|
+
handleScaleDrag(type, current, origBBox, center2) {
|
|
19953
|
+
if (this.mode !== "scale") return;
|
|
19954
|
+
const width = origBBox.maxX - origBBox.minX;
|
|
19955
|
+
const height = origBBox.maxY - origBBox.minY;
|
|
19956
|
+
let scaleX = this.state.scaleX;
|
|
19957
|
+
let scaleY = this.state.scaleY;
|
|
19958
|
+
switch (type) {
|
|
19959
|
+
case TransformHandleType.Left:
|
|
19960
|
+
case TransformHandleType.TopLeft:
|
|
19961
|
+
case TransformHandleType.BottomLeft:
|
|
19962
|
+
scaleX = (center2.x - current.x) / (center2.x - origBBox.minX || 1);
|
|
19963
|
+
break;
|
|
19964
|
+
case TransformHandleType.Right:
|
|
19965
|
+
case TransformHandleType.TopRight:
|
|
19966
|
+
case TransformHandleType.BottomRight:
|
|
19967
|
+
scaleX = (current.x - center2.x) / (origBBox.maxX - center2.x || 1);
|
|
19968
|
+
break;
|
|
19969
|
+
}
|
|
19970
|
+
switch (type) {
|
|
19971
|
+
case TransformHandleType.Top:
|
|
19972
|
+
case TransformHandleType.TopLeft:
|
|
19973
|
+
case TransformHandleType.TopRight:
|
|
19974
|
+
scaleY = (center2.y - current.y) / (center2.y - origBBox.minY || 1);
|
|
19975
|
+
break;
|
|
19976
|
+
case TransformHandleType.Bottom:
|
|
19977
|
+
case TransformHandleType.BottomLeft:
|
|
19978
|
+
case TransformHandleType.BottomRight:
|
|
19979
|
+
scaleY = (current.y - center2.y) / (origBBox.maxY - center2.y || 1);
|
|
19980
|
+
break;
|
|
19981
|
+
}
|
|
19982
|
+
if (type === TransformHandleType.Left || type === TransformHandleType.Right) {
|
|
19983
|
+
scaleY = this.state.scaleY;
|
|
19984
|
+
}
|
|
19985
|
+
if (type === TransformHandleType.Top || type === TransformHandleType.Bottom) {
|
|
19986
|
+
scaleX = this.state.scaleX;
|
|
19987
|
+
}
|
|
19988
|
+
if (this.state.uniformScale) {
|
|
19989
|
+
const uniform = Math.abs(width) > Math.abs(height) ? Math.sign(scaleX) * Math.abs(scaleX) : Math.sign(scaleY) * Math.abs(scaleY);
|
|
19990
|
+
scaleX = uniform;
|
|
19991
|
+
scaleY = uniform;
|
|
19992
|
+
}
|
|
19993
|
+
const hasValidScaleX = Number.isFinite(scaleX) && Math.abs(scaleX) > 1e-3;
|
|
19994
|
+
const hasValidScaleY = Number.isFinite(scaleY) && Math.abs(scaleY) > 1e-3;
|
|
19995
|
+
if (hasValidScaleX) {
|
|
19996
|
+
this.state.scaleX = scaleX;
|
|
19997
|
+
}
|
|
19998
|
+
if (hasValidScaleY) {
|
|
19999
|
+
this.state.scaleY = scaleY;
|
|
20000
|
+
}
|
|
20001
|
+
}
|
|
20002
|
+
preview() {
|
|
20003
|
+
const transformed = applyTransform(
|
|
20004
|
+
this.state.originalPixelRings,
|
|
20005
|
+
this.state.pivot,
|
|
20006
|
+
this.state.scaleX,
|
|
20007
|
+
this.state.scaleY,
|
|
20008
|
+
this.state.rotation
|
|
20009
|
+
);
|
|
20010
|
+
const ll = unprojectToLatLngs(this.map, transformed, this.normalizedLatLngs);
|
|
20011
|
+
this.polygon.setLatLngs(ll);
|
|
20012
|
+
this.updateOverlay();
|
|
20013
|
+
}
|
|
20014
|
+
apply() {
|
|
20015
|
+
const coords = this.polygon.getLatLngs();
|
|
20016
|
+
return normalizeLatLngs(coords);
|
|
20017
|
+
}
|
|
20018
|
+
cancel() {
|
|
20019
|
+
this.polygon.setLatLngs(this.state.originalLatLngs);
|
|
20020
|
+
}
|
|
20021
|
+
handleCancel() {
|
|
20022
|
+
this.cancel();
|
|
20023
|
+
this.destroy();
|
|
20024
|
+
if (this.onExit) this.onExit();
|
|
20025
|
+
}
|
|
20026
|
+
handleConfirm() {
|
|
20027
|
+
if (this.onExit) this.onExit();
|
|
20028
|
+
this.destroy();
|
|
20029
|
+
}
|
|
20030
|
+
}
|
|
20031
|
+
class PopupFactory {
|
|
20032
|
+
/**
|
|
20033
|
+
* Creates a menu button element.
|
|
20034
|
+
* @param id Unique identifier for the button.
|
|
20035
|
+
* @param title Tooltip text.
|
|
20036
|
+
* @param cssClasses Additional CSS classes to apply.
|
|
20037
|
+
* @param options Optional configuration (alpha banner, etc.).
|
|
20038
|
+
* @returns HTMLDivElement representing the menu button.
|
|
20039
|
+
*/
|
|
20040
|
+
static createMenuButton(id, title, cssClasses, options) {
|
|
20041
|
+
const button = document.createElement("div");
|
|
20042
|
+
button.classList.add("marker-menu-button", ...cssClasses);
|
|
20043
|
+
button.title = title;
|
|
20044
|
+
button.setAttribute("data-action-id", id);
|
|
20045
|
+
if (options == null ? void 0 : options.alphaBanner) {
|
|
20046
|
+
const alphaBanner = document.createElement("span");
|
|
20047
|
+
alphaBanner.classList.add("alpha-banner");
|
|
20048
|
+
alphaBanner.textContent = "ALPHA";
|
|
20049
|
+
button.appendChild(alphaBanner);
|
|
20050
|
+
}
|
|
20051
|
+
return button;
|
|
20052
|
+
}
|
|
20053
|
+
/**
|
|
20054
|
+
* Builds a menu popup container structure.
|
|
20055
|
+
* @param buttons Array of button elements to include.
|
|
20056
|
+
* @returns HTMLDivElement containing the complete menu structure.
|
|
20057
|
+
*/
|
|
20058
|
+
static buildMenuPopup(buttons) {
|
|
20059
|
+
const outerWrapper = document.createElement("div");
|
|
20060
|
+
outerWrapper.classList.add("alter-marker-outer-wrapper");
|
|
20061
|
+
const wrapper = document.createElement("div");
|
|
20062
|
+
wrapper.classList.add("alter-marker-wrapper");
|
|
20063
|
+
const markerContent = document.createElement("div");
|
|
20064
|
+
markerContent.classList.add("content");
|
|
20065
|
+
const markerContentWrapper = document.createElement("div");
|
|
20066
|
+
markerContentWrapper.classList.add("marker-menu-content");
|
|
20067
|
+
buttons.forEach((button) => {
|
|
20068
|
+
markerContentWrapper.appendChild(button);
|
|
20069
|
+
});
|
|
20070
|
+
markerContent.appendChild(markerContentWrapper);
|
|
20071
|
+
wrapper.appendChild(markerContent);
|
|
20072
|
+
outerWrapper.appendChild(wrapper);
|
|
20073
|
+
return outerWrapper;
|
|
20074
|
+
}
|
|
20075
|
+
/**
|
|
20076
|
+
* Builds an info popup container structure.
|
|
20077
|
+
* @param content HTML element to display inside the popup.
|
|
20078
|
+
* @returns HTMLDivElement containing the complete info popup structure.
|
|
20079
|
+
*/
|
|
20080
|
+
static buildInfoPopup(content) {
|
|
20081
|
+
const outerWrapper = document.createElement("div");
|
|
20082
|
+
outerWrapper.classList.add("info-marker-outer-wrapper");
|
|
20083
|
+
const wrapper = document.createElement("div");
|
|
20084
|
+
wrapper.classList.add("info-marker-wrapper");
|
|
20085
|
+
const markerContent = document.createElement("div");
|
|
20086
|
+
markerContent.classList.add("content");
|
|
20087
|
+
markerContent.appendChild(content);
|
|
20088
|
+
wrapper.appendChild(markerContent);
|
|
20089
|
+
outerWrapper.appendChild(wrapper);
|
|
20090
|
+
return outerWrapper;
|
|
18565
20091
|
}
|
|
18566
20092
|
}
|
|
18567
20093
|
class PolygonInteractionManager {
|
|
@@ -18581,6 +20107,8 @@ class PolygonInteractionManager {
|
|
|
18581
20107
|
__publicField(this, "currentModifierDragMode", false);
|
|
18582
20108
|
__publicField(this, "isModifierKeyHeld", false);
|
|
18583
20109
|
__publicField(this, "_openMenuPopup", null);
|
|
20110
|
+
__publicField(this, "transformModeActive", false);
|
|
20111
|
+
__publicField(this, "transformControllers", /* @__PURE__ */ new WeakMap());
|
|
18584
20112
|
// Read-only access to feature groups
|
|
18585
20113
|
__publicField(this, "getFeatureGroups");
|
|
18586
20114
|
__publicField(this, "removeFeatureGroup");
|
|
@@ -18611,6 +20139,8 @@ class PolygonInteractionManager {
|
|
|
18611
20139
|
dragData.isDragging = false;
|
|
18612
20140
|
this.map.off("mousemove", this.onPolygonMouseMove, this);
|
|
18613
20141
|
this.map.off("mouseup", this.onPolygonMouseUp, this);
|
|
20142
|
+
this.map.off("pointermove", this.onPolygonMouseMove, this);
|
|
20143
|
+
this.map.off("pointerup", this.onPolygonMouseUp, this);
|
|
18614
20144
|
if (this.map.dragging) {
|
|
18615
20145
|
this.map.dragging.enable();
|
|
18616
20146
|
}
|
|
@@ -18663,6 +20193,12 @@ class PolygonInteractionManager {
|
|
|
18663
20193
|
this.getFeatureGroups = featureGroupAccess.getFeatureGroups;
|
|
18664
20194
|
this.removeFeatureGroup = featureGroupAccess.removeFeatureGroup;
|
|
18665
20195
|
}
|
|
20196
|
+
/**
|
|
20197
|
+
* Strongly typed helper to emit polygon updated events without casts.
|
|
20198
|
+
*/
|
|
20199
|
+
emitPolygonUpdated(data) {
|
|
20200
|
+
this.eventManager.emit("polydraw:polygon:updated", data);
|
|
20201
|
+
}
|
|
18666
20202
|
/**
|
|
18667
20203
|
* Add markers to a polygon feature group
|
|
18668
20204
|
*/
|
|
@@ -18694,7 +20230,7 @@ class PolygonInteractionManager {
|
|
|
18694
20230
|
}
|
|
18695
20231
|
const processedClasses = Array.isArray(iconClasses) ? iconClasses : [iconClasses];
|
|
18696
20232
|
const isSpecialMarker = i === menuMarkerIdx && this.config.markers.menuMarker || i === deleteMarkerIdx && this.config.markers.deleteMarker || i === infoMarkerIdx && this.config.markers.infoMarker;
|
|
18697
|
-
const marker = new L.Marker(latlng, {
|
|
20233
|
+
const marker = new L$1.Marker(latlng, {
|
|
18698
20234
|
icon: this.createDivIcon(processedClasses),
|
|
18699
20235
|
draggable: this.config.modes.dragElbow,
|
|
18700
20236
|
title: this.config.markers.coordsTitle ? this.getLatLngInfoString(latlng) : "",
|
|
@@ -18710,7 +20246,7 @@ class PolygonInteractionManager {
|
|
|
18710
20246
|
var _a2, _b2;
|
|
18711
20247
|
if (this.isDraggingMarker) {
|
|
18712
20248
|
(_b2 = (_a2 = e.originalEvent) == null ? void 0 : _a2.stopPropagation) == null ? void 0 : _b2.call(_a2);
|
|
18713
|
-
L.DomEvent.stopPropagation(e);
|
|
20249
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18714
20250
|
}
|
|
18715
20251
|
});
|
|
18716
20252
|
marker.on("dragstart", () => {
|
|
@@ -18723,7 +20259,7 @@ class PolygonInteractionManager {
|
|
|
18723
20259
|
this.markerDragEnd(fg);
|
|
18724
20260
|
}
|
|
18725
20261
|
this._activeMarker = null;
|
|
18726
|
-
L.DomEvent.stopPropagation(e);
|
|
20262
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18727
20263
|
setTimeout(() => {
|
|
18728
20264
|
this.isDraggingMarker = false;
|
|
18729
20265
|
}, 10);
|
|
@@ -18768,7 +20304,10 @@ class PolygonInteractionManager {
|
|
|
18768
20304
|
marker.options.zIndexOffset = this.config.markers.markerMenuIcon.zIndexOffset ?? this.config.markers.zIndexOffset;
|
|
18769
20305
|
marker.on("click", () => {
|
|
18770
20306
|
const polygonGeoJSON = this.getPolygonGeoJSONFromFeatureGroup(featureGroup);
|
|
18771
|
-
const centerOfMass2 = PolygonUtil.
|
|
20307
|
+
const centerOfMass2 = PolygonUtil.getCenterOfPolygonByIndexWithOffsetFromCenterOfMass(
|
|
20308
|
+
polygonGeoJSON,
|
|
20309
|
+
menuMarkerIdx
|
|
20310
|
+
);
|
|
18772
20311
|
const menuPopup = this.generateMenuMarkerPopup(latlngs, featureGroup);
|
|
18773
20312
|
menuPopup.setLatLng(centerOfMass2).openOn(this.map);
|
|
18774
20313
|
});
|
|
@@ -18778,12 +20317,22 @@ class PolygonInteractionManager {
|
|
|
18778
20317
|
if (!popupContent) return;
|
|
18779
20318
|
setTimeout(() => {
|
|
18780
20319
|
const mapContainer = this.map.getContainer();
|
|
18781
|
-
const mapBounds = mapContainer.getBoundingClientRect();
|
|
18782
20320
|
const popupBounds = popupContent.getBoundingClientRect();
|
|
20321
|
+
const mapBounds = mapContainer.getBoundingClientRect();
|
|
20322
|
+
let adjustX = 0;
|
|
20323
|
+
let adjustY = 0;
|
|
18783
20324
|
if (popupBounds.left < mapBounds.left) {
|
|
18784
|
-
|
|
20325
|
+
adjustX = mapBounds.left - popupBounds.left;
|
|
18785
20326
|
} else if (popupBounds.right > mapBounds.right) {
|
|
18786
|
-
|
|
20327
|
+
adjustX = mapBounds.right - popupBounds.right;
|
|
20328
|
+
}
|
|
20329
|
+
if (popupBounds.top < mapBounds.top) {
|
|
20330
|
+
adjustY = mapBounds.top - popupBounds.top;
|
|
20331
|
+
} else if (popupBounds.bottom > mapBounds.bottom) {
|
|
20332
|
+
adjustY = mapBounds.bottom - popupBounds.bottom;
|
|
20333
|
+
}
|
|
20334
|
+
if (adjustX !== 0 || adjustY !== 0) {
|
|
20335
|
+
popupContent.style.transform = `translate(${adjustX}px, ${adjustY}px)`;
|
|
18787
20336
|
}
|
|
18788
20337
|
}, 0);
|
|
18789
20338
|
const container2 = this.map.getContainer();
|
|
@@ -18805,7 +20354,10 @@ class PolygonInteractionManager {
|
|
|
18805
20354
|
marker.options.zIndexOffset = this.config.markers.markerInfoIcon.zIndexOffset ?? this.config.markers.zIndexOffset;
|
|
18806
20355
|
marker.on("click", () => {
|
|
18807
20356
|
const infoPopup = this.generateInfoMarkerPopup(area2, perimeter);
|
|
18808
|
-
const centerOfMass2 = PolygonUtil.
|
|
20357
|
+
const centerOfMass2 = PolygonUtil.getCenterOfPolygonByIndexWithOffsetFromCenterOfMass(
|
|
20358
|
+
polygonGeoJSON,
|
|
20359
|
+
infoMarkerIdx
|
|
20360
|
+
);
|
|
18809
20361
|
infoPopup.setLatLng(centerOfMass2).openOn(this.map);
|
|
18810
20362
|
});
|
|
18811
20363
|
marker.on("popupopen", (e) => {
|
|
@@ -18836,7 +20388,7 @@ class PolygonInteractionManager {
|
|
|
18836
20388
|
}
|
|
18837
20389
|
marker.on("mousedown", (e) => {
|
|
18838
20390
|
if (!this.modeManager.isInOffMode()) {
|
|
18839
|
-
L.DomEvent.stopPropagation(e);
|
|
20391
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18840
20392
|
this.map.fire("mousedown", e);
|
|
18841
20393
|
}
|
|
18842
20394
|
this._activeMarker = marker;
|
|
@@ -18844,7 +20396,7 @@ class PolygonInteractionManager {
|
|
|
18844
20396
|
marker.on("click", (e) => {
|
|
18845
20397
|
if (this.modeManager.isInOffMode()) {
|
|
18846
20398
|
if (this.isEdgeDeletionModifierKeyPressed(e.originalEvent)) {
|
|
18847
|
-
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
20399
|
+
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
18848
20400
|
if (polygonLayer) {
|
|
18849
20401
|
this.elbowClicked(e, polygonLayer, marker.getLatLng());
|
|
18850
20402
|
}
|
|
@@ -18901,7 +20453,7 @@ class PolygonInteractionManager {
|
|
|
18901
20453
|
}
|
|
18902
20454
|
const processedClasses = Array.isArray(iconClasses) ? iconClasses : [iconClasses];
|
|
18903
20455
|
const isSpecialMarker = i === menuMarkerIdx && holeMenuEnabled || i === deleteMarkerIdx && holeDeleteEnabled || i === infoMarkerIdx && holeInfoEnabled;
|
|
18904
|
-
const marker = new L.Marker(latlng, {
|
|
20456
|
+
const marker = new L$1.Marker(latlng, {
|
|
18905
20457
|
icon: this.createDivIcon(processedClasses),
|
|
18906
20458
|
draggable: this.config.modes.dragElbow,
|
|
18907
20459
|
title: this.config.markers.coordsTitle ? this.getLatLngInfoString(latlng) : "",
|
|
@@ -18917,7 +20469,7 @@ class PolygonInteractionManager {
|
|
|
18917
20469
|
var _a3, _b3;
|
|
18918
20470
|
if (this.isDraggingMarker) {
|
|
18919
20471
|
(_b3 = (_a3 = e.originalEvent) == null ? void 0 : _a3.stopPropagation) == null ? void 0 : _b3.call(_a3);
|
|
18920
|
-
L.DomEvent.stopPropagation(e);
|
|
20472
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18921
20473
|
}
|
|
18922
20474
|
});
|
|
18923
20475
|
marker.on("dragstart", () => {
|
|
@@ -18930,7 +20482,7 @@ class PolygonInteractionManager {
|
|
|
18930
20482
|
this.markerDragEnd(fg);
|
|
18931
20483
|
}
|
|
18932
20484
|
this._activeMarker = null;
|
|
18933
|
-
L.DomEvent.stopPropagation(e);
|
|
20485
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18934
20486
|
setTimeout(() => {
|
|
18935
20487
|
this.isDraggingMarker = false;
|
|
18936
20488
|
}, 10);
|
|
@@ -19035,7 +20587,7 @@ class PolygonInteractionManager {
|
|
|
19035
20587
|
}
|
|
19036
20588
|
marker.on("mousedown", (e) => {
|
|
19037
20589
|
if (!this.modeManager.isInOffMode()) {
|
|
19038
|
-
L.DomEvent.stopPropagation(e);
|
|
20590
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19039
20591
|
this.map.fire("mousedown", e);
|
|
19040
20592
|
}
|
|
19041
20593
|
this._activeMarker = marker;
|
|
@@ -19043,14 +20595,14 @@ class PolygonInteractionManager {
|
|
|
19043
20595
|
marker.on("click", (e) => {
|
|
19044
20596
|
if (this.modeManager.isInOffMode()) {
|
|
19045
20597
|
if (this.isEdgeDeletionModifierKeyPressed(e.originalEvent)) {
|
|
19046
|
-
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
20598
|
+
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
19047
20599
|
if (polygonLayer) {
|
|
19048
20600
|
this.elbowClicked(e, polygonLayer, marker.getLatLng());
|
|
19049
20601
|
}
|
|
19050
20602
|
} else {
|
|
19051
20603
|
if (i === deleteMarkerIdx && holeDeleteEnabled) {
|
|
19052
20604
|
this.map.closePopup();
|
|
19053
|
-
const parentPolygon = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
20605
|
+
const parentPolygon = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
19054
20606
|
if (parentPolygon) {
|
|
19055
20607
|
const rawLatLngs = parentPolygon.getLatLngs();
|
|
19056
20608
|
let rings = [];
|
|
@@ -19089,7 +20641,7 @@ class PolygonInteractionManager {
|
|
|
19089
20641
|
});
|
|
19090
20642
|
const newPolygon = this.turfHelper.getMultiPolygon([coords]);
|
|
19091
20643
|
this.removeFeatureGroup(featureGroup);
|
|
19092
|
-
this.
|
|
20644
|
+
this.emitPolygonUpdated({
|
|
19093
20645
|
operation: "removeHole",
|
|
19094
20646
|
polygon: newPolygon
|
|
19095
20647
|
});
|
|
@@ -19138,12 +20690,15 @@ class PolygonInteractionManager {
|
|
|
19138
20690
|
if (edgeStart.lat === edgeEnd.lat && edgeStart.lng === edgeEnd.lng) {
|
|
19139
20691
|
continue;
|
|
19140
20692
|
}
|
|
19141
|
-
const edgePolyline =
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
|
|
20693
|
+
const edgePolyline = leafletAdapter.createPolyline(
|
|
20694
|
+
[edgeStart, edgeEnd],
|
|
20695
|
+
{
|
|
20696
|
+
color: "transparent",
|
|
20697
|
+
weight: 10,
|
|
20698
|
+
opacity: 0,
|
|
20699
|
+
interactive: true
|
|
20700
|
+
}
|
|
20701
|
+
);
|
|
19147
20702
|
edgePolyline._polydrawEdgeInfo = {
|
|
19148
20703
|
ringIndex,
|
|
19149
20704
|
edgeIndex: i,
|
|
@@ -19179,15 +20734,15 @@ class PolygonInteractionManager {
|
|
|
19179
20734
|
};
|
|
19180
20735
|
polygon2.on("mousedown", (e) => {
|
|
19181
20736
|
if (!this.modeManager.isInOffMode()) {
|
|
19182
|
-
L.DomEvent.stopPropagation(e);
|
|
20737
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19183
20738
|
this.map.fire("mousedown", e);
|
|
19184
20739
|
return;
|
|
19185
20740
|
}
|
|
19186
20741
|
if (!this.modeManager.canPerformAction("polygonDrag")) {
|
|
19187
20742
|
return;
|
|
19188
20743
|
}
|
|
19189
|
-
L.DomEvent.stopPropagation(e.originalEvent);
|
|
19190
|
-
L.DomEvent.preventDefault(e.originalEvent);
|
|
20744
|
+
L$1.DomEvent.stopPropagation(e.originalEvent);
|
|
20745
|
+
L$1.DomEvent.preventDefault(e.originalEvent);
|
|
19191
20746
|
const isModifierPressed = this.detectDragSubtractModifierKey(e.originalEvent);
|
|
19192
20747
|
this.currentModifierDragMode = isModifierPressed;
|
|
19193
20748
|
this.isModifierKeyHeld = isModifierPressed;
|
|
@@ -19207,6 +20762,46 @@ class PolygonInteractionManager {
|
|
|
19207
20762
|
}
|
|
19208
20763
|
this.map.on("mousemove", this.onPolygonMouseMove, this);
|
|
19209
20764
|
this.map.on("mouseup", this.onPolygonMouseUp, this);
|
|
20765
|
+
this.map.on("pointermove", this.onPolygonMouseMove, this);
|
|
20766
|
+
this.map.on("pointerup", this.onPolygonMouseUp, this);
|
|
20767
|
+
this.currentDragPolygon = polygon2;
|
|
20768
|
+
});
|
|
20769
|
+
polygon2.on("pointerdown", (e) => {
|
|
20770
|
+
if (this.transformModeActive) {
|
|
20771
|
+
return;
|
|
20772
|
+
}
|
|
20773
|
+
if (!this.modeManager.isInOffMode()) {
|
|
20774
|
+
L$1.DomEvent.stopPropagation(e);
|
|
20775
|
+
this.map.fire("pointerdown", e);
|
|
20776
|
+
return;
|
|
20777
|
+
}
|
|
20778
|
+
if (!this.modeManager.canPerformAction("polygonDrag")) {
|
|
20779
|
+
return;
|
|
20780
|
+
}
|
|
20781
|
+
const orig = e && e.originalEvent ? e.originalEvent : e;
|
|
20782
|
+
L$1.DomEvent.stopPropagation(orig);
|
|
20783
|
+
L$1.DomEvent.preventDefault(orig);
|
|
20784
|
+
const isModifierPressed = this.detectDragSubtractModifierKey(orig);
|
|
20785
|
+
this.currentModifierDragMode = isModifierPressed;
|
|
20786
|
+
this.isModifierKeyHeld = isModifierPressed;
|
|
20787
|
+
polygon2._polydrawDragData.isDragging = true;
|
|
20788
|
+
polygon2._polydrawDragData.startPosition = e.latlng;
|
|
20789
|
+
polygon2._polydrawDragData.startLatLngs = polygon2.getLatLngs();
|
|
20790
|
+
polygon2.setStyle({ fillOpacity: this.config.dragPolygons.opacity });
|
|
20791
|
+
if (this.map.dragging) {
|
|
20792
|
+
this.map.dragging.disable();
|
|
20793
|
+
}
|
|
20794
|
+
this.setSubtractVisualMode(polygon2, isModifierPressed);
|
|
20795
|
+
this.setMarkerVisibility(polygon2, false);
|
|
20796
|
+
try {
|
|
20797
|
+
const container = this.map.getContainer();
|
|
20798
|
+
container.style.cursor = this.config.dragPolygons.dragCursor || "move";
|
|
20799
|
+
} catch (error) {
|
|
20800
|
+
}
|
|
20801
|
+
this.map.on("mousemove", this.onPolygonMouseMove, this);
|
|
20802
|
+
this.map.on("mouseup", this.onPolygonMouseUp, this);
|
|
20803
|
+
this.map.on("pointermove", this.onPolygonMouseMove, this);
|
|
20804
|
+
this.map.on("pointerup", this.onPolygonMouseUp, this);
|
|
19210
20805
|
this.currentDragPolygon = polygon2;
|
|
19211
20806
|
});
|
|
19212
20807
|
polygon2.on("mouseover", () => {
|
|
@@ -19235,7 +20830,7 @@ class PolygonInteractionManager {
|
|
|
19235
20830
|
const shouldBeDraggable = this.modeManager.canPerformAction("markerDrag");
|
|
19236
20831
|
this.getFeatureGroups().forEach((featureGroup) => {
|
|
19237
20832
|
featureGroup.eachLayer((layer) => {
|
|
19238
|
-
if (layer instanceof L.Marker) {
|
|
20833
|
+
if (layer instanceof L$1.Marker) {
|
|
19239
20834
|
const marker = layer;
|
|
19240
20835
|
try {
|
|
19241
20836
|
marker.options.draggable = shouldBeDraggable;
|
|
@@ -19258,7 +20853,7 @@ class PolygonInteractionManager {
|
|
|
19258
20853
|
updateAllMarkersForEdgeDeletion(showFeedback) {
|
|
19259
20854
|
this.getFeatureGroups().forEach((featureGroup) => {
|
|
19260
20855
|
featureGroup.eachLayer((layer) => {
|
|
19261
|
-
if (layer instanceof L.Marker) {
|
|
20856
|
+
if (layer instanceof L$1.Marker) {
|
|
19262
20857
|
this.updateMarkerForEdgeDeletion(layer, showFeedback);
|
|
19263
20858
|
}
|
|
19264
20859
|
});
|
|
@@ -19315,7 +20910,7 @@ class PolygonInteractionManager {
|
|
|
19315
20910
|
const polydrawPolygon = parentPolygon;
|
|
19316
20911
|
const optimizationLevel = polydrawPolygon._polydrawOptimizationLevel || 0;
|
|
19317
20912
|
this.removeFeatureGroup(parentFeatureGroup);
|
|
19318
|
-
this.
|
|
20913
|
+
this.emitPolygonUpdated({
|
|
19319
20914
|
operation: "addVertex",
|
|
19320
20915
|
polygon: newPolygon,
|
|
19321
20916
|
optimizationLevel
|
|
@@ -19325,7 +20920,7 @@ class PolygonInteractionManager {
|
|
|
19325
20920
|
} catch (error) {
|
|
19326
20921
|
}
|
|
19327
20922
|
}
|
|
19328
|
-
L.DomEvent.stopPropagation(e);
|
|
20923
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19329
20924
|
}
|
|
19330
20925
|
highlightEdgeOnHover(edgePolyline, isHovering) {
|
|
19331
20926
|
if (isHovering) {
|
|
@@ -19415,7 +21010,7 @@ class PolygonInteractionManager {
|
|
|
19415
21010
|
this.removeFeatureGroup(currentFeatureGroup);
|
|
19416
21011
|
}
|
|
19417
21012
|
const newPolygon = this.turfHelper.getMultiPolygon([coords]);
|
|
19418
|
-
this.
|
|
21013
|
+
this.emitPolygonUpdated({
|
|
19419
21014
|
operation: "removeVertex",
|
|
19420
21015
|
polygon: newPolygon
|
|
19421
21016
|
});
|
|
@@ -19431,7 +21026,7 @@ class PolygonInteractionManager {
|
|
|
19431
21026
|
let testarray = [];
|
|
19432
21027
|
let hole = [];
|
|
19433
21028
|
const layers = featureGroup.getLayers();
|
|
19434
|
-
const polygonLayer = layers.find((l) => l instanceof L.Polygon);
|
|
21029
|
+
const polygonLayer = layers.find((l) => l instanceof L$1.Polygon);
|
|
19435
21030
|
if (!polygonLayer) {
|
|
19436
21031
|
if (!isTestEnvironment()) {
|
|
19437
21032
|
console.warn("No polygon found in feature group for marker drag.");
|
|
@@ -19440,7 +21035,7 @@ class PolygonInteractionManager {
|
|
|
19440
21035
|
}
|
|
19441
21036
|
const posarrays = polygonLayer.getLatLngs();
|
|
19442
21037
|
let length2 = 0;
|
|
19443
|
-
const
|
|
21038
|
+
const markers = layers.filter((layer) => layer instanceof L$1.Marker);
|
|
19444
21039
|
if (posarrays.length > 1) {
|
|
19445
21040
|
for (let index = 0; index < posarrays.length; index++) {
|
|
19446
21041
|
testarray = [];
|
|
@@ -19449,16 +21044,16 @@ class PolygonInteractionManager {
|
|
|
19449
21044
|
if (posarrays[0].length > 1) {
|
|
19450
21045
|
for (let i = 0; i < posarrays[0].length; i++) {
|
|
19451
21046
|
for (let j = 0; j < posarrays[0][i].length; j++) {
|
|
19452
|
-
if (
|
|
19453
|
-
testarray.push(
|
|
21047
|
+
if (markers[j]) {
|
|
21048
|
+
testarray.push(markers[j].getLatLng());
|
|
19454
21049
|
}
|
|
19455
21050
|
}
|
|
19456
21051
|
hole.push(testarray);
|
|
19457
21052
|
}
|
|
19458
21053
|
} else {
|
|
19459
21054
|
for (let j = 0; j < posarrays[0][0].length; j++) {
|
|
19460
|
-
if (
|
|
19461
|
-
testarray.push(
|
|
21055
|
+
if (markers[j]) {
|
|
21056
|
+
testarray.push(markers[j].getLatLng());
|
|
19462
21057
|
}
|
|
19463
21058
|
}
|
|
19464
21059
|
hole.push(testarray);
|
|
@@ -19467,8 +21062,8 @@ class PolygonInteractionManager {
|
|
|
19467
21062
|
} else {
|
|
19468
21063
|
length2 += posarrays[index - 1].length;
|
|
19469
21064
|
for (let j = length2; j < posarrays[index][0].length + length2; j++) {
|
|
19470
|
-
if (
|
|
19471
|
-
testarray.push(
|
|
21065
|
+
if (markers[j]) {
|
|
21066
|
+
testarray.push(markers[j].getLatLng());
|
|
19472
21067
|
}
|
|
19473
21068
|
}
|
|
19474
21069
|
hole.push(testarray);
|
|
@@ -19483,22 +21078,22 @@ class PolygonInteractionManager {
|
|
|
19483
21078
|
if (index === 0) {
|
|
19484
21079
|
if (posarrays[0][index].length > 1) {
|
|
19485
21080
|
for (let j = 0; j < posarrays[0][index].length; j++) {
|
|
19486
|
-
if (
|
|
19487
|
-
testarray.push(
|
|
21081
|
+
if (markers[j]) {
|
|
21082
|
+
testarray.push(markers[j].getLatLng());
|
|
19488
21083
|
}
|
|
19489
21084
|
}
|
|
19490
21085
|
} else {
|
|
19491
21086
|
for (let j = 0; j < posarrays[0][0].length; j++) {
|
|
19492
|
-
if (
|
|
19493
|
-
testarray.push(
|
|
21087
|
+
if (markers[j]) {
|
|
21088
|
+
testarray.push(markers[j].getLatLng());
|
|
19494
21089
|
}
|
|
19495
21090
|
}
|
|
19496
21091
|
}
|
|
19497
21092
|
} else {
|
|
19498
21093
|
length22 += posarrays[0][index - 1].length;
|
|
19499
21094
|
for (let j = length22; j < posarrays[0][index].length + length22; j++) {
|
|
19500
|
-
if (
|
|
19501
|
-
testarray.push(
|
|
21095
|
+
if (markers[j]) {
|
|
21096
|
+
testarray.push(markers[j].getLatLng());
|
|
19502
21097
|
}
|
|
19503
21098
|
}
|
|
19504
21099
|
}
|
|
@@ -19521,7 +21116,7 @@ class PolygonInteractionManager {
|
|
|
19521
21116
|
if (this.turfHelper.hasKinks(feature2)) {
|
|
19522
21117
|
const unkink = this.turfHelper.getKinks(feature2);
|
|
19523
21118
|
for (const polygon2 of unkink) {
|
|
19524
|
-
this.
|
|
21119
|
+
this.emitPolygonUpdated({
|
|
19525
21120
|
operation: "markerDrag",
|
|
19526
21121
|
polygon: this.turfHelper.getTurfPolygon(polygon2),
|
|
19527
21122
|
allowMerge: true,
|
|
@@ -19531,7 +21126,7 @@ class PolygonInteractionManager {
|
|
|
19531
21126
|
});
|
|
19532
21127
|
}
|
|
19533
21128
|
} else {
|
|
19534
|
-
this.
|
|
21129
|
+
this.emitPolygonUpdated({
|
|
19535
21130
|
operation: "markerDrag",
|
|
19536
21131
|
polygon: feature2,
|
|
19537
21132
|
allowMerge: true,
|
|
@@ -19548,7 +21143,7 @@ class PolygonInteractionManager {
|
|
|
19548
21143
|
if (this.turfHelper.hasKinks(feature2)) {
|
|
19549
21144
|
const unkink = this.turfHelper.getKinks(feature2);
|
|
19550
21145
|
for (const polygon2 of unkink) {
|
|
19551
|
-
this.
|
|
21146
|
+
this.emitPolygonUpdated({
|
|
19552
21147
|
operation: "markerDrag",
|
|
19553
21148
|
polygon: this.turfHelper.getTurfPolygon(polygon2),
|
|
19554
21149
|
allowMerge: false
|
|
@@ -19556,7 +21151,7 @@ class PolygonInteractionManager {
|
|
|
19556
21151
|
});
|
|
19557
21152
|
}
|
|
19558
21153
|
} else {
|
|
19559
|
-
this.
|
|
21154
|
+
this.emitPolygonUpdated({
|
|
19560
21155
|
operation: "markerDrag",
|
|
19561
21156
|
polygon: feature2,
|
|
19562
21157
|
allowMerge: false
|
|
@@ -19573,7 +21168,9 @@ class PolygonInteractionManager {
|
|
|
19573
21168
|
(ring) => this.offsetPolygonCoordinates(ring, offsetLat, offsetLng)
|
|
19574
21169
|
);
|
|
19575
21170
|
}
|
|
19576
|
-
return latLngs.map(
|
|
21171
|
+
return latLngs.map(
|
|
21172
|
+
(p) => leafletAdapter.createLatLng(p.lat + offsetLat, p.lng + offsetLng)
|
|
21173
|
+
);
|
|
19577
21174
|
}
|
|
19578
21175
|
updateMarkersAndHoleLinesDuringDrag(polygon2, offsetLat, offsetLng) {
|
|
19579
21176
|
try {
|
|
@@ -19593,22 +21190,22 @@ class PolygonInteractionManager {
|
|
|
19593
21190
|
if (!featureGroup) {
|
|
19594
21191
|
return;
|
|
19595
21192
|
}
|
|
19596
|
-
const dragSessionKey = "_polydrawDragSession_" + Date.now() + "_" +
|
|
21193
|
+
const dragSessionKey = "_polydrawDragSession_" + Date.now() + "_" + leafletAdapter.util.stamp(polygon2);
|
|
19597
21194
|
if (!polygon2._polydrawCurrentDragSession) {
|
|
19598
21195
|
polygon2._polydrawCurrentDragSession = dragSessionKey;
|
|
19599
21196
|
polygon2._polydrawOriginalMarkerPositions = /* @__PURE__ */ new Map();
|
|
19600
21197
|
polygon2._polydrawOriginalHoleLinePositions = /* @__PURE__ */ new Map();
|
|
19601
21198
|
featureGroup.eachLayer((layer) => {
|
|
19602
|
-
if (layer instanceof L.Marker) {
|
|
21199
|
+
if (layer instanceof L$1.Marker) {
|
|
19603
21200
|
polygon2._polydrawOriginalMarkerPositions.set(layer, layer.getLatLng());
|
|
19604
|
-
} else if (layer instanceof L.Polyline && !(layer instanceof L.Polygon)) {
|
|
21201
|
+
} else if (layer instanceof L$1.Polyline && !(layer instanceof L$1.Polygon)) {
|
|
19605
21202
|
const latLngs = layer.getLatLngs();
|
|
19606
21203
|
polygon2._polydrawOriginalHoleLinePositions.set(layer, latLngs);
|
|
19607
21204
|
}
|
|
19608
21205
|
});
|
|
19609
21206
|
}
|
|
19610
21207
|
featureGroup.eachLayer((layer) => {
|
|
19611
|
-
if (layer instanceof L.Marker) {
|
|
21208
|
+
if (layer instanceof L$1.Marker) {
|
|
19612
21209
|
const originalPos = polygon2._polydrawOriginalMarkerPositions.get(layer);
|
|
19613
21210
|
if (originalPos) {
|
|
19614
21211
|
const newLatLng = {
|
|
@@ -19617,17 +21214,19 @@ class PolygonInteractionManager {
|
|
|
19617
21214
|
};
|
|
19618
21215
|
layer.setLatLng(newLatLng);
|
|
19619
21216
|
}
|
|
19620
|
-
} else if (layer instanceof L.Polyline && !(layer instanceof L.Polygon)) {
|
|
21217
|
+
} else if (layer instanceof L$1.Polyline && !(layer instanceof L$1.Polygon)) {
|
|
19621
21218
|
const originalPositions = polygon2._polydrawOriginalHoleLinePositions.get(layer);
|
|
19622
21219
|
if (originalPositions) {
|
|
19623
21220
|
let newLatLngs;
|
|
19624
21221
|
if (Array.isArray(originalPositions[0])) {
|
|
19625
21222
|
newLatLngs = originalPositions.map(
|
|
19626
|
-
(ring) => ring.map(
|
|
21223
|
+
(ring) => ring.map(
|
|
21224
|
+
(latlng) => leafletAdapter.createLatLng(latlng.lat + offsetLat, latlng.lng + offsetLng)
|
|
21225
|
+
)
|
|
19627
21226
|
);
|
|
19628
21227
|
} else {
|
|
19629
21228
|
newLatLngs = originalPositions.map(
|
|
19630
|
-
(latlng) =>
|
|
21229
|
+
(latlng) => leafletAdapter.createLatLng(latlng.lat + offsetLat, latlng.lng + offsetLng)
|
|
19631
21230
|
);
|
|
19632
21231
|
}
|
|
19633
21232
|
layer.setLatLngs(newLatLngs);
|
|
@@ -19661,7 +21260,7 @@ class PolygonInteractionManager {
|
|
|
19661
21260
|
}
|
|
19662
21261
|
this.removeFeatureGroup(featureGroup);
|
|
19663
21262
|
const feature2 = this.turfHelper.getTurfPolygon(newGeoJSON);
|
|
19664
|
-
this.
|
|
21263
|
+
this.emitPolygonUpdated({
|
|
19665
21264
|
operation: "polygonDrag",
|
|
19666
21265
|
polygon: feature2,
|
|
19667
21266
|
allowMerge: true
|
|
@@ -19720,7 +21319,7 @@ class PolygonInteractionManager {
|
|
|
19720
21319
|
const fg = featureGroup;
|
|
19721
21320
|
const hideMarkersOnDrag = this.config.dragPolygons.modifierSubtract.hideMarkersOnDrag;
|
|
19722
21321
|
fg.eachLayer((layer) => {
|
|
19723
|
-
if (layer instanceof L.Marker) {
|
|
21322
|
+
if (layer instanceof L$1.Marker) {
|
|
19724
21323
|
const marker = layer;
|
|
19725
21324
|
const element = marker.getElement();
|
|
19726
21325
|
if (element) {
|
|
@@ -19813,7 +21412,7 @@ class PolygonInteractionManager {
|
|
|
19813
21412
|
const coords = this.turfHelper.getCoords(difference3);
|
|
19814
21413
|
for (const coordSet of coords) {
|
|
19815
21414
|
const individualPolygon = this.turfHelper.getMultiPolygon([coordSet]);
|
|
19816
|
-
this.
|
|
21415
|
+
this.emitPolygonUpdated({
|
|
19817
21416
|
operation: "modifierSubtract",
|
|
19818
21417
|
polygon: this.turfHelper.getTurfPolygon(individualPolygon),
|
|
19819
21418
|
allowMerge: false
|
|
@@ -19825,7 +21424,7 @@ class PolygonInteractionManager {
|
|
|
19825
21424
|
if (!isTestEnvironment()) {
|
|
19826
21425
|
console.warn("Failed to perform difference operation:", differenceError);
|
|
19827
21426
|
}
|
|
19828
|
-
this.
|
|
21427
|
+
this.emitPolygonUpdated({
|
|
19829
21428
|
operation: "modifierSubtractFallback",
|
|
19830
21429
|
polygon: existingPolygon,
|
|
19831
21430
|
allowMerge: false
|
|
@@ -19933,25 +21532,25 @@ class PolygonInteractionManager {
|
|
|
19933
21532
|
);
|
|
19934
21533
|
return nearestPointIdx;
|
|
19935
21534
|
}
|
|
19936
|
-
ensureMarkerSeparation(polygonLength,
|
|
21535
|
+
ensureMarkerSeparation(polygonLength, markers) {
|
|
19937
21536
|
const enabledMarkers = [];
|
|
19938
|
-
if (
|
|
19939
|
-
enabledMarkers.push({ type: "menu", index:
|
|
21537
|
+
if (markers.menu.enabled) {
|
|
21538
|
+
enabledMarkers.push({ type: "menu", index: markers.menu.index });
|
|
19940
21539
|
}
|
|
19941
|
-
if (
|
|
19942
|
-
enabledMarkers.push({ type: "delete", index:
|
|
21540
|
+
if (markers.delete.enabled) {
|
|
21541
|
+
enabledMarkers.push({ type: "delete", index: markers.delete.index });
|
|
19943
21542
|
}
|
|
19944
|
-
if (
|
|
19945
|
-
enabledMarkers.push({ type: "info", index:
|
|
21543
|
+
if (markers.info.enabled) {
|
|
21544
|
+
enabledMarkers.push({ type: "info", index: markers.info.index });
|
|
19946
21545
|
}
|
|
19947
21546
|
if (enabledMarkers.length < 2) {
|
|
19948
21547
|
return {
|
|
19949
|
-
menu:
|
|
19950
|
-
delete:
|
|
19951
|
-
info:
|
|
21548
|
+
menu: markers.menu.index,
|
|
21549
|
+
delete: markers.delete.index,
|
|
21550
|
+
info: markers.info.index
|
|
19952
21551
|
};
|
|
19953
21552
|
}
|
|
19954
|
-
const resolvedIndices = { ...
|
|
21553
|
+
const resolvedIndices = { ...markers };
|
|
19955
21554
|
const usedIndices = /* @__PURE__ */ new Set();
|
|
19956
21555
|
const processingOrder = ["info", "delete", "menu"];
|
|
19957
21556
|
for (const markerType of processingOrder) {
|
|
@@ -20006,7 +21605,7 @@ class PolygonInteractionManager {
|
|
|
20006
21605
|
const featureGroup = this.getFeatureGroups().find((fg) => fg.hasLayer(polygon2));
|
|
20007
21606
|
if (!featureGroup) return;
|
|
20008
21607
|
featureGroup.eachLayer((layer) => {
|
|
20009
|
-
if (layer instanceof L.Marker) {
|
|
21608
|
+
if (layer instanceof L$1.Marker) {
|
|
20010
21609
|
const marker = layer;
|
|
20011
21610
|
const element = marker.getElement();
|
|
20012
21611
|
if (element) {
|
|
@@ -20023,128 +21622,134 @@ class PolygonInteractionManager {
|
|
|
20023
21622
|
});
|
|
20024
21623
|
}
|
|
20025
21624
|
generateMenuMarkerPopup(latLngs, featureGroup) {
|
|
20026
|
-
const
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20048
|
-
|
|
20049
|
-
|
|
20050
|
-
|
|
20051
|
-
|
|
20052
|
-
outerWrapper.
|
|
20053
|
-
wrapper.appendChild(markerContent);
|
|
20054
|
-
markerContent.appendChild(markerContentWrapper);
|
|
20055
|
-
markerContentWrapper.appendChild(simplify3);
|
|
20056
|
-
markerContentWrapper.appendChild(separator.cloneNode());
|
|
20057
|
-
markerContentWrapper.appendChild(doubleElbows);
|
|
20058
|
-
markerContentWrapper.appendChild(separator.cloneNode());
|
|
20059
|
-
markerContentWrapper.appendChild(bbox2);
|
|
20060
|
-
markerContentWrapper.appendChild(separator.cloneNode());
|
|
20061
|
-
markerContentWrapper.appendChild(bezier2);
|
|
21625
|
+
const buttons = [];
|
|
21626
|
+
const menuOps = this.config.menuOperations;
|
|
21627
|
+
if (menuOps.simplify.enabled) {
|
|
21628
|
+
buttons.push(PopupFactory.createMenuButton("simplify", "Simplify", ["simplify"]));
|
|
21629
|
+
}
|
|
21630
|
+
if (menuOps.doubleElbows.enabled) {
|
|
21631
|
+
buttons.push(
|
|
21632
|
+
PopupFactory.createMenuButton("doubleElbows", "DoubleElbows", ["double-elbows"])
|
|
21633
|
+
);
|
|
21634
|
+
}
|
|
21635
|
+
if (menuOps.bbox.enabled) {
|
|
21636
|
+
buttons.push(PopupFactory.createMenuButton("bbox", "Bounding box", ["bbox"]));
|
|
21637
|
+
}
|
|
21638
|
+
if (menuOps.bezier.enabled) {
|
|
21639
|
+
buttons.push(
|
|
21640
|
+
PopupFactory.createMenuButton("bezier", "Curve", ["bezier"], {
|
|
21641
|
+
alphaBanner: true
|
|
21642
|
+
})
|
|
21643
|
+
);
|
|
21644
|
+
}
|
|
21645
|
+
if (menuOps.scale.enabled) {
|
|
21646
|
+
buttons.push(PopupFactory.createMenuButton("scale", "Scale", ["transform-scale"]));
|
|
21647
|
+
}
|
|
21648
|
+
if (menuOps.rotate.enabled) {
|
|
21649
|
+
buttons.push(PopupFactory.createMenuButton("rotate", "Rotate", ["transform-rotate"]));
|
|
21650
|
+
}
|
|
21651
|
+
const outerWrapper = PopupFactory.buildMenuPopup(buttons);
|
|
20062
21652
|
const closePopupIfOpen = () => {
|
|
20063
21653
|
if (this._openMenuPopup) {
|
|
20064
21654
|
this.map.closePopup(this._openMenuPopup);
|
|
20065
21655
|
this._openMenuPopup = null;
|
|
20066
21656
|
}
|
|
20067
21657
|
};
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
action
|
|
20073
|
-
|
|
20074
|
-
|
|
20075
|
-
|
|
20076
|
-
|
|
20077
|
-
|
|
20078
|
-
simplify3.onclick = () => {
|
|
20079
|
-
this.eventManager.emit("polydraw:menu:action", {
|
|
20080
|
-
action: "simplify",
|
|
20081
|
-
latLngs,
|
|
20082
|
-
featureGroup
|
|
21658
|
+
const attachMenuActionHandler = (button, action) => {
|
|
21659
|
+
button.addEventListener("touchend", (e) => {
|
|
21660
|
+
e.preventDefault();
|
|
21661
|
+
e.stopPropagation();
|
|
21662
|
+
this.eventManager.emit("polydraw:menu:action", {
|
|
21663
|
+
action,
|
|
21664
|
+
latLngs,
|
|
21665
|
+
featureGroup
|
|
21666
|
+
});
|
|
21667
|
+
closePopupIfOpen();
|
|
20083
21668
|
});
|
|
20084
|
-
|
|
21669
|
+
button.onclick = () => {
|
|
21670
|
+
this.eventManager.emit("polydraw:menu:action", {
|
|
21671
|
+
action,
|
|
21672
|
+
latLngs,
|
|
21673
|
+
featureGroup
|
|
21674
|
+
});
|
|
21675
|
+
closePopupIfOpen();
|
|
21676
|
+
};
|
|
20085
21677
|
};
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
|
|
20089
|
-
|
|
20090
|
-
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
|
|
20094
|
-
|
|
20095
|
-
|
|
20096
|
-
|
|
20097
|
-
|
|
20098
|
-
|
|
20099
|
-
|
|
20100
|
-
|
|
20101
|
-
|
|
20102
|
-
|
|
21678
|
+
const startTransform = (mode) => {
|
|
21679
|
+
const existing = this.transformControllers.get(featureGroup);
|
|
21680
|
+
if (existing) {
|
|
21681
|
+
existing.cancel();
|
|
21682
|
+
existing.destroy();
|
|
21683
|
+
this.transformControllers.delete(featureGroup);
|
|
21684
|
+
}
|
|
21685
|
+
try {
|
|
21686
|
+
const controller = new PolygonTransformController(this.map, featureGroup, mode, () => {
|
|
21687
|
+
try {
|
|
21688
|
+
const polygonLayer = featureGroup.getLayers().find((l) => l instanceof L$1.Polygon);
|
|
21689
|
+
if (!polygonLayer) return;
|
|
21690
|
+
const newGeoJSON = polygonLayer.toGeoJSON();
|
|
21691
|
+
this.removeFeatureGroup(featureGroup);
|
|
21692
|
+
this.emitPolygonUpdated({
|
|
21693
|
+
operation: "transform",
|
|
21694
|
+
polygon: this.turfHelper.getTurfPolygon(newGeoJSON),
|
|
21695
|
+
allowMerge: true
|
|
21696
|
+
});
|
|
21697
|
+
} finally {
|
|
21698
|
+
controller.destroy();
|
|
21699
|
+
this.transformControllers.delete(featureGroup);
|
|
21700
|
+
this.transformModeActive = false;
|
|
21701
|
+
}
|
|
21702
|
+
});
|
|
21703
|
+
this.transformControllers.set(featureGroup, controller);
|
|
21704
|
+
const polyLayer = featureGroup.getLayers().find((l) => l instanceof L$1.Polygon);
|
|
21705
|
+
if (polyLayer) this.setMarkerVisibility(polyLayer, false);
|
|
21706
|
+
this.transformModeActive = true;
|
|
21707
|
+
} catch {
|
|
21708
|
+
}
|
|
20103
21709
|
};
|
|
20104
|
-
|
|
20105
|
-
|
|
20106
|
-
|
|
20107
|
-
|
|
20108
|
-
|
|
20109
|
-
|
|
20110
|
-
featureGroup
|
|
20111
|
-
});
|
|
20112
|
-
closePopupIfOpen();
|
|
20113
|
-
});
|
|
20114
|
-
doubleElbows.onclick = () => {
|
|
20115
|
-
this.eventManager.emit("polydraw:menu:action", {
|
|
20116
|
-
action: "doubleElbows",
|
|
20117
|
-
latLngs,
|
|
20118
|
-
featureGroup
|
|
21710
|
+
const attachTransformHandler = (button, mode) => {
|
|
21711
|
+
button.addEventListener("touchend", (e) => {
|
|
21712
|
+
e.preventDefault();
|
|
21713
|
+
e.stopPropagation();
|
|
21714
|
+
startTransform(mode);
|
|
21715
|
+
closePopupIfOpen();
|
|
20119
21716
|
});
|
|
20120
|
-
|
|
21717
|
+
button.onclick = () => {
|
|
21718
|
+
startTransform(mode);
|
|
21719
|
+
closePopupIfOpen();
|
|
21720
|
+
};
|
|
20121
21721
|
};
|
|
20122
|
-
|
|
20123
|
-
|
|
20124
|
-
|
|
20125
|
-
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
21722
|
+
buttons.forEach((button) => {
|
|
21723
|
+
const actionId = button.getAttribute("data-action-id");
|
|
21724
|
+
switch (actionId) {
|
|
21725
|
+
case "simplify":
|
|
21726
|
+
attachMenuActionHandler(button, "simplify");
|
|
21727
|
+
break;
|
|
21728
|
+
case "doubleElbows":
|
|
21729
|
+
attachMenuActionHandler(button, "doubleElbows");
|
|
21730
|
+
break;
|
|
21731
|
+
case "bbox":
|
|
21732
|
+
attachMenuActionHandler(button, "bbox");
|
|
21733
|
+
break;
|
|
21734
|
+
case "bezier":
|
|
21735
|
+
attachMenuActionHandler(button, "bezier");
|
|
21736
|
+
break;
|
|
21737
|
+
case "scale":
|
|
21738
|
+
attachTransformHandler(button, "scale");
|
|
21739
|
+
break;
|
|
21740
|
+
case "rotate":
|
|
21741
|
+
attachTransformHandler(button, "rotate");
|
|
21742
|
+
break;
|
|
21743
|
+
}
|
|
20131
21744
|
});
|
|
20132
|
-
|
|
20133
|
-
this.eventManager.emit("polydraw:menu:action", {
|
|
20134
|
-
action: "bezier",
|
|
20135
|
-
latLngs,
|
|
20136
|
-
featureGroup
|
|
20137
|
-
});
|
|
20138
|
-
closePopupIfOpen();
|
|
20139
|
-
};
|
|
20140
|
-
L.DomEvent.disableClickPropagation(outerWrapper);
|
|
21745
|
+
L$1.DomEvent.disableClickPropagation(outerWrapper);
|
|
20141
21746
|
outerWrapper.style.pointerEvents = "auto";
|
|
20142
21747
|
outerWrapper.querySelectorAll(".marker-menu-button").forEach((btn) => {
|
|
20143
21748
|
btn.style.pointerEvents = "auto";
|
|
20144
21749
|
btn.addEventListener("click", (e) => e.stopPropagation());
|
|
20145
21750
|
});
|
|
20146
21751
|
const isMobile = window.innerWidth <= 600;
|
|
20147
|
-
const popup =
|
|
21752
|
+
const popup = leafletAdapter.createPopup({
|
|
20148
21753
|
closeButton: true,
|
|
20149
21754
|
autoClose: true,
|
|
20150
21755
|
className: `menu-popup${isMobile ? " mobile-popup" : ""}`
|
|
@@ -20154,7 +21759,7 @@ class PolygonInteractionManager {
|
|
|
20154
21759
|
}
|
|
20155
21760
|
getPolygonGeoJSONFromFeatureGroup(featureGroup) {
|
|
20156
21761
|
try {
|
|
20157
|
-
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
21762
|
+
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
20158
21763
|
if (!polygonLayer) {
|
|
20159
21764
|
throw new Error("No polygon found in feature group");
|
|
20160
21765
|
}
|
|
@@ -20256,14 +21861,14 @@ class PolygonInteractionManager {
|
|
|
20256
21861
|
markerContent.appendChild(infoContentWrapper);
|
|
20257
21862
|
outerWrapper.appendChild(wrapper);
|
|
20258
21863
|
wrapper.appendChild(markerContent);
|
|
20259
|
-
L.DomEvent.disableClickPropagation(outerWrapper);
|
|
21864
|
+
L$1.DomEvent.disableClickPropagation(outerWrapper);
|
|
20260
21865
|
outerWrapper.style.pointerEvents = "auto";
|
|
20261
21866
|
outerWrapper.querySelectorAll("button").forEach((btn) => {
|
|
20262
21867
|
btn.style.pointerEvents = "auto";
|
|
20263
21868
|
btn.addEventListener("click", (e) => e.stopPropagation());
|
|
20264
21869
|
});
|
|
20265
21870
|
const isMobile = window.innerWidth <= 600;
|
|
20266
|
-
const popup =
|
|
21871
|
+
const popup = leafletAdapter.createPopup({
|
|
20267
21872
|
closeButton: true,
|
|
20268
21873
|
autoClose: true,
|
|
20269
21874
|
className: `info-popup${isMobile ? " mobile-popup" : ""}`
|
|
@@ -20502,7 +22107,7 @@ class PolygonMutationManager {
|
|
|
20502
22107
|
if (!latlngs || !latlngs.geometry || !latlngs.geometry.coordinates) {
|
|
20503
22108
|
return { success: false, error: "Invalid polygon data" };
|
|
20504
22109
|
}
|
|
20505
|
-
const featureGroup = new L.FeatureGroup();
|
|
22110
|
+
const featureGroup = new L$1.FeatureGroup();
|
|
20506
22111
|
const latLngs = simplify3 ? this.turfHelper.getSimplified(latlngs, dynamicTolerance) : latlngs;
|
|
20507
22112
|
let polygon2;
|
|
20508
22113
|
try {
|
|
@@ -20542,7 +22147,7 @@ class PolygonMutationManager {
|
|
|
20542
22147
|
if (ringIndex === 0) {
|
|
20543
22148
|
this.interactionManager.addMarkers(latLngLiterals, featureGroup);
|
|
20544
22149
|
} else {
|
|
20545
|
-
const holePolyline =
|
|
22150
|
+
const holePolyline = leafletAdapter.createPolyline(latLngLiterals, {
|
|
20546
22151
|
color: this.config.colors.hole.border,
|
|
20547
22152
|
weight: this.config.holeOptions.weight || 2,
|
|
20548
22153
|
opacity: this.config.holeOptions.opacity || 1,
|
|
@@ -20812,7 +22417,7 @@ class PolygonMutationManager {
|
|
|
20812
22417
|
* Create a polygon from GeoJSON feature
|
|
20813
22418
|
*/
|
|
20814
22419
|
getPolygon(latlngs) {
|
|
20815
|
-
const polygon2 = L.GeoJSON.geometryToLayer(latlngs);
|
|
22420
|
+
const polygon2 = L$1.GeoJSON.geometryToLayer(latlngs);
|
|
20816
22421
|
const polygonStyle = {
|
|
20817
22422
|
...this.config.polygonOptions,
|
|
20818
22423
|
color: this.config.colors.polygon.border,
|
|
@@ -20823,7 +22428,7 @@ class PolygonMutationManager {
|
|
|
20823
22428
|
fillOpacity: this.config.polygonOptions.fillOpacity || 0.2
|
|
20824
22429
|
};
|
|
20825
22430
|
polygon2.setStyle(polygonStyle);
|
|
20826
|
-
polygon2._polydrawUniqueId =
|
|
22431
|
+
polygon2._polydrawUniqueId = leafletAdapter.util.stamp(polygon2) + "_" + Date.now();
|
|
20827
22432
|
delete polygon2._polydrawDragData;
|
|
20828
22433
|
delete polygon2._polydrawOriginalLatLngs;
|
|
20829
22434
|
delete polygon2._polydrawCurrentDragSession;
|
|
@@ -20859,7 +22464,7 @@ class PolygonMutationManager {
|
|
|
20859
22464
|
try {
|
|
20860
22465
|
let polygon2 = null;
|
|
20861
22466
|
featureGroup.eachLayer((layer) => {
|
|
20862
|
-
if (layer instanceof L.Polygon) {
|
|
22467
|
+
if (layer instanceof L$1.Polygon) {
|
|
20863
22468
|
polygon2 = layer;
|
|
20864
22469
|
}
|
|
20865
22470
|
});
|
|
@@ -21021,19 +22626,19 @@ class PolygonMutationManager {
|
|
|
21021
22626
|
getMarkerIndex(latlngs, position) {
|
|
21022
22627
|
return 0;
|
|
21023
22628
|
}
|
|
21024
|
-
ensureMarkerSeparation(polygonLength,
|
|
22629
|
+
ensureMarkerSeparation(polygonLength, markers) {
|
|
21025
22630
|
var _a2, _b2, _c;
|
|
21026
22631
|
return {
|
|
21027
|
-
menu: ((_a2 =
|
|
21028
|
-
delete: ((_b2 =
|
|
21029
|
-
info: ((_c =
|
|
22632
|
+
menu: ((_a2 = markers.menu) == null ? void 0 : _a2.index) ?? 0,
|
|
22633
|
+
delete: ((_b2 = markers.delete) == null ? void 0 : _b2.index) ?? 1,
|
|
22634
|
+
info: ((_c = markers.info) == null ? void 0 : _c.index) ?? 2
|
|
21030
22635
|
};
|
|
21031
22636
|
}
|
|
21032
22637
|
findAlternativeMarkerPosition(polygonLength, originalIndex, usedIndices) {
|
|
21033
22638
|
return (originalIndex + 1) % polygonLength;
|
|
21034
22639
|
}
|
|
21035
22640
|
createDivIcon(processedClasses) {
|
|
21036
|
-
return
|
|
22641
|
+
return leafletAdapter.createDivIcon({ className: processedClasses.join(" ") });
|
|
21037
22642
|
}
|
|
21038
22643
|
getLatLngInfoString(latlng) {
|
|
21039
22644
|
return "Latitude: " + latlng.lat + " Longitude: " + latlng.lng;
|
|
@@ -21149,7 +22754,419 @@ function injectDynamicStyles(config) {
|
|
|
21149
22754
|
`;
|
|
21150
22755
|
document.head.appendChild(style);
|
|
21151
22756
|
}
|
|
21152
|
-
class
|
|
22757
|
+
class EventAdapter {
|
|
22758
|
+
/**
|
|
22759
|
+
* Normalizes events to handle differences between v1 and v2
|
|
22760
|
+
* @param event - The event to normalize
|
|
22761
|
+
* @returns The normalized event
|
|
22762
|
+
*/
|
|
22763
|
+
static normalizeEvent(event) {
|
|
22764
|
+
const version = LeafletVersionDetector.getVersion();
|
|
22765
|
+
if (version === LeafletVersion.V2) {
|
|
22766
|
+
if (event.layer && !event.propagatedFrom) {
|
|
22767
|
+
event.propagatedFrom = event.layer;
|
|
22768
|
+
}
|
|
22769
|
+
if (event.type === "mousedown" || event.type === "touchstart") {
|
|
22770
|
+
event._isPointerEvent = true;
|
|
22771
|
+
}
|
|
22772
|
+
}
|
|
22773
|
+
return event;
|
|
22774
|
+
}
|
|
22775
|
+
/**
|
|
22776
|
+
* Gets the appropriate event name for the current Leaflet version
|
|
22777
|
+
* @param eventName - The base event name
|
|
22778
|
+
* @returns The version-appropriate event name
|
|
22779
|
+
*/
|
|
22780
|
+
static getEventName(eventName) {
|
|
22781
|
+
const version = LeafletVersionDetector.getVersion();
|
|
22782
|
+
if (version === LeafletVersion.V2) {
|
|
22783
|
+
switch (eventName) {
|
|
22784
|
+
case "mousedown":
|
|
22785
|
+
return "pointerdown";
|
|
22786
|
+
case "mouseup":
|
|
22787
|
+
return "pointerup";
|
|
22788
|
+
case "mousemove":
|
|
22789
|
+
return "pointermove";
|
|
22790
|
+
case "touchstart":
|
|
22791
|
+
return "pointerdown";
|
|
22792
|
+
case "touchend":
|
|
22793
|
+
return "pointerup";
|
|
22794
|
+
case "touchmove":
|
|
22795
|
+
return "pointermove";
|
|
22796
|
+
default:
|
|
22797
|
+
return eventName;
|
|
22798
|
+
}
|
|
22799
|
+
}
|
|
22800
|
+
return eventName;
|
|
22801
|
+
}
|
|
22802
|
+
/**
|
|
22803
|
+
* Checks if pointer events are supported/preferred
|
|
22804
|
+
* @returns true if pointer events should be used
|
|
22805
|
+
*/
|
|
22806
|
+
static shouldUsePointerEvents() {
|
|
22807
|
+
const version = LeafletVersionDetector.getVersion();
|
|
22808
|
+
return version === LeafletVersion.V2 && "PointerEvent" in window;
|
|
22809
|
+
}
|
|
22810
|
+
/**
|
|
22811
|
+
* Extracts coordinates from various event types (mouse, touch, pointer)
|
|
22812
|
+
* @param event - The event to extract coordinates from
|
|
22813
|
+
* @param map - The map instance for coordinate conversion
|
|
22814
|
+
* @returns The LatLng coordinates or null if not available
|
|
22815
|
+
*/
|
|
22816
|
+
static extractCoordinates(event, map) {
|
|
22817
|
+
if (event.latlng) {
|
|
22818
|
+
return event.latlng;
|
|
22819
|
+
}
|
|
22820
|
+
if (event.touches && event.touches.length > 0) {
|
|
22821
|
+
const rect = map.getContainer().getBoundingClientRect();
|
|
22822
|
+
return map.containerPointToLatLng([
|
|
22823
|
+
event.touches[0].clientX - rect.x,
|
|
22824
|
+
event.touches[0].clientY - rect.y
|
|
22825
|
+
]);
|
|
22826
|
+
}
|
|
22827
|
+
if (event.pointerType && event.clientX !== void 0) {
|
|
22828
|
+
const rect = map.getContainer().getBoundingClientRect();
|
|
22829
|
+
return map.containerPointToLatLng([event.clientX - rect.x, event.clientY - rect.y]);
|
|
22830
|
+
}
|
|
22831
|
+
if (event.clientX !== void 0) {
|
|
22832
|
+
const rect = map.getContainer().getBoundingClientRect();
|
|
22833
|
+
return map.containerPointToLatLng([event.clientX - rect.x, event.clientY - rect.y]);
|
|
22834
|
+
}
|
|
22835
|
+
return null;
|
|
22836
|
+
}
|
|
22837
|
+
/**
|
|
22838
|
+
* Checks if an event should be prevented from default behavior
|
|
22839
|
+
* @param event - The event to check
|
|
22840
|
+
* @returns true if preventDefault should be called
|
|
22841
|
+
*/
|
|
22842
|
+
static shouldPreventDefault(event) {
|
|
22843
|
+
if (event.type && event.type.startsWith("touch")) {
|
|
22844
|
+
return true;
|
|
22845
|
+
}
|
|
22846
|
+
if (event.pointerType && event.isPrimary === false) {
|
|
22847
|
+
return false;
|
|
22848
|
+
}
|
|
22849
|
+
if ("cancelable" in event && event.cancelable) {
|
|
22850
|
+
return true;
|
|
22851
|
+
}
|
|
22852
|
+
return false;
|
|
22853
|
+
}
|
|
22854
|
+
/**
|
|
22855
|
+
* Gets the appropriate event listener names for the current version
|
|
22856
|
+
* @returns Object with event names for different actions
|
|
22857
|
+
*/
|
|
22858
|
+
static getEventNames() {
|
|
22859
|
+
const version = LeafletVersionDetector.getVersion();
|
|
22860
|
+
if (version === LeafletVersion.V2 && this.shouldUsePointerEvents()) {
|
|
22861
|
+
return {
|
|
22862
|
+
start: ["pointerdown"],
|
|
22863
|
+
move: ["pointermove"],
|
|
22864
|
+
end: ["pointerup"]
|
|
22865
|
+
};
|
|
22866
|
+
} else {
|
|
22867
|
+
return {
|
|
22868
|
+
start: ["mousedown", "touchstart"],
|
|
22869
|
+
move: ["mousemove", "touchmove"],
|
|
22870
|
+
end: ["mouseup", "touchend"]
|
|
22871
|
+
};
|
|
22872
|
+
}
|
|
22873
|
+
}
|
|
22874
|
+
}
|
|
22875
|
+
class GeometryUtils {
|
|
22876
|
+
/**
|
|
22877
|
+
* Calculate angle between three points
|
|
22878
|
+
*/
|
|
22879
|
+
static calculateAngle(p1, p2, p3) {
|
|
22880
|
+
const v1 = { x: p1.lng - p2.lng, y: p1.lat - p2.lat };
|
|
22881
|
+
const v2 = { x: p3.lng - p2.lng, y: p3.lat - p2.lat };
|
|
22882
|
+
const dot = v1.x * v2.x + v1.y * v2.y;
|
|
22883
|
+
const mag1 = Math.sqrt(v1.x * v1.x + v1.y * v1.y);
|
|
22884
|
+
const mag2 = Math.sqrt(v2.x * v2.x + v2.y * v2.y);
|
|
22885
|
+
if (mag1 === 0 || mag2 === 0) return 0;
|
|
22886
|
+
const cosAngle = dot / (mag1 * mag2);
|
|
22887
|
+
return Math.acos(Math.max(-1, Math.min(1, cosAngle)));
|
|
22888
|
+
}
|
|
22889
|
+
/**
|
|
22890
|
+
* Calculate distance from point to line between two other points
|
|
22891
|
+
*/
|
|
22892
|
+
static calculateDistanceFromLine(p1, point2, p2) {
|
|
22893
|
+
const A = point2.lng - p1.lng;
|
|
22894
|
+
const B2 = point2.lat - p1.lat;
|
|
22895
|
+
const C = p2.lng - p1.lng;
|
|
22896
|
+
const D2 = p2.lat - p1.lat;
|
|
22897
|
+
const dot = A * C + B2 * D2;
|
|
22898
|
+
const lenSq = C * C + D2 * D2;
|
|
22899
|
+
if (lenSq === 0) return Math.sqrt(A * A + B2 * B2);
|
|
22900
|
+
const param = dot / lenSq;
|
|
22901
|
+
let xx, yy;
|
|
22902
|
+
if (param < 0) {
|
|
22903
|
+
xx = p1.lng;
|
|
22904
|
+
yy = p1.lat;
|
|
22905
|
+
} else if (param > 1) {
|
|
22906
|
+
xx = p2.lng;
|
|
22907
|
+
yy = p2.lat;
|
|
22908
|
+
} else {
|
|
22909
|
+
xx = p1.lng + param * C;
|
|
22910
|
+
yy = p1.lat + param * D2;
|
|
22911
|
+
}
|
|
22912
|
+
const dx = point2.lng - xx;
|
|
22913
|
+
const dy = point2.lat - yy;
|
|
22914
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
22915
|
+
}
|
|
22916
|
+
/**
|
|
22917
|
+
* Calculate centroid of polygon
|
|
22918
|
+
* @deprecated Use PolygonUtil.getCenter() instead for consistency
|
|
22919
|
+
*/
|
|
22920
|
+
static calculateCentroid(latlngs) {
|
|
22921
|
+
return PolygonUtil.getCenter(latlngs);
|
|
22922
|
+
}
|
|
22923
|
+
/**
|
|
22924
|
+
* Calculate distance between two points
|
|
22925
|
+
*/
|
|
22926
|
+
static calculateDistance(p1, p2) {
|
|
22927
|
+
const dx = p1.lng - p2.lng;
|
|
22928
|
+
const dy = p1.lat - p2.lat;
|
|
22929
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
22930
|
+
}
|
|
22931
|
+
/**
|
|
22932
|
+
* Apply offset to polygon coordinates
|
|
22933
|
+
* Note: Uses 'any' type for recursive coordinate structures that can be:
|
|
22934
|
+
* - L.LatLngLiteral (single coordinate)
|
|
22935
|
+
* - L.LatLngLiteral[] (array of coordinates)
|
|
22936
|
+
* - L.LatLngLiteral[][] (polygon with holes)
|
|
22937
|
+
* - L.LatLngLiteral[][][] (multipolygon)
|
|
22938
|
+
* This is a legitimate use of 'any' for dynamic recursive data structures.
|
|
22939
|
+
*/
|
|
22940
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22941
|
+
static offsetPolygonCoordinates(latLngs, offsetLat, offsetLng) {
|
|
22942
|
+
if (!latLngs) return latLngs;
|
|
22943
|
+
if (Array.isArray(latLngs[0])) {
|
|
22944
|
+
return latLngs.map(
|
|
22945
|
+
(ring) => GeometryUtils.offsetPolygonCoordinates(ring, offsetLat, offsetLng)
|
|
22946
|
+
);
|
|
22947
|
+
} else if (latLngs.lat !== void 0 && latLngs.lng !== void 0) {
|
|
22948
|
+
return {
|
|
22949
|
+
lat: latLngs.lat + offsetLat,
|
|
22950
|
+
lng: latLngs.lng + offsetLng
|
|
22951
|
+
};
|
|
22952
|
+
} else {
|
|
22953
|
+
return latLngs.map(
|
|
22954
|
+
(coord) => GeometryUtils.offsetPolygonCoordinates(coord, offsetLat, offsetLng)
|
|
22955
|
+
);
|
|
22956
|
+
}
|
|
22957
|
+
}
|
|
22958
|
+
}
|
|
22959
|
+
class CoordinateUtils {
|
|
22960
|
+
/**
|
|
22961
|
+
* Convert coordinate arrays to proper format for polygon creation
|
|
22962
|
+
*/
|
|
22963
|
+
static convertToCoords(latlngs, turfHelper) {
|
|
22964
|
+
const coords = [];
|
|
22965
|
+
if (latlngs.length > 1 && latlngs.length < 3) {
|
|
22966
|
+
const coordinates = [];
|
|
22967
|
+
const within = turfHelper.isWithin(
|
|
22968
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[latlngs.length - 1]),
|
|
22969
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[0])
|
|
22970
|
+
);
|
|
22971
|
+
if (within) {
|
|
22972
|
+
latlngs.forEach((polygon2) => {
|
|
22973
|
+
coordinates.push(L$1.GeoJSON.latLngsToCoords(polygon2));
|
|
22974
|
+
});
|
|
22975
|
+
} else {
|
|
22976
|
+
latlngs.forEach((polygon2) => {
|
|
22977
|
+
coords.push([L$1.GeoJSON.latLngsToCoords(polygon2)]);
|
|
22978
|
+
});
|
|
22979
|
+
}
|
|
22980
|
+
if (coordinates.length >= 1) {
|
|
22981
|
+
coords.push(coordinates);
|
|
22982
|
+
}
|
|
22983
|
+
} else if (latlngs.length > 2) {
|
|
22984
|
+
const coordinates = [];
|
|
22985
|
+
for (let index = 1; index < latlngs.length - 1; index++) {
|
|
22986
|
+
const within = turfHelper.isWithin(
|
|
22987
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[index]),
|
|
22988
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[0])
|
|
22989
|
+
);
|
|
22990
|
+
if (within) {
|
|
22991
|
+
latlngs.forEach((polygon2) => {
|
|
22992
|
+
coordinates.push(L$1.GeoJSON.latLngsToCoords(polygon2));
|
|
22993
|
+
});
|
|
22994
|
+
coords.push(coordinates);
|
|
22995
|
+
} else {
|
|
22996
|
+
latlngs.forEach((polygon2) => {
|
|
22997
|
+
coords.push([L$1.GeoJSON.latLngsToCoords(polygon2)]);
|
|
22998
|
+
});
|
|
22999
|
+
}
|
|
23000
|
+
}
|
|
23001
|
+
} else {
|
|
23002
|
+
coords.push([L$1.GeoJSON.latLngsToCoords(latlngs[0])]);
|
|
23003
|
+
}
|
|
23004
|
+
return coords;
|
|
23005
|
+
}
|
|
23006
|
+
/**
|
|
23007
|
+
* Apply offset to polygon coordinates
|
|
23008
|
+
*/
|
|
23009
|
+
static offsetPolygonCoordinates(latLngs, offsetLat, offsetLng) {
|
|
23010
|
+
return GeometryUtils.offsetPolygonCoordinates(latLngs, offsetLat, offsetLng);
|
|
23011
|
+
}
|
|
23012
|
+
/**
|
|
23013
|
+
* Get latitude/longitude information string
|
|
23014
|
+
*/
|
|
23015
|
+
static getLatLngInfoString(latlng) {
|
|
23016
|
+
return "Latitude: " + latlng.lat + " Longitude: " + latlng.lng;
|
|
23017
|
+
}
|
|
23018
|
+
/**
|
|
23019
|
+
* Convert any coordinate format to L.LatLng
|
|
23020
|
+
* Supports multiple input formats with smart auto-detection
|
|
23021
|
+
*/
|
|
23022
|
+
static convertToLatLng(coordinate) {
|
|
23023
|
+
if (typeof coordinate === "object" && coordinate !== null) {
|
|
23024
|
+
if ("lat" in coordinate && "lng" in coordinate) {
|
|
23025
|
+
return leafletAdapter.createLatLng(
|
|
23026
|
+
coordinate.lat,
|
|
23027
|
+
coordinate.lng
|
|
23028
|
+
);
|
|
23029
|
+
}
|
|
23030
|
+
if ("latitude" in coordinate && "longitude" in coordinate) {
|
|
23031
|
+
return leafletAdapter.createLatLng(
|
|
23032
|
+
coordinate.latitude,
|
|
23033
|
+
coordinate.longitude
|
|
23034
|
+
);
|
|
23035
|
+
}
|
|
23036
|
+
if ("longitude" in coordinate && "latitude" in coordinate) {
|
|
23037
|
+
return leafletAdapter.createLatLng(
|
|
23038
|
+
coordinate.latitude,
|
|
23039
|
+
coordinate.longitude
|
|
23040
|
+
);
|
|
23041
|
+
}
|
|
23042
|
+
if ("lng" in coordinate && "lat" in coordinate) {
|
|
23043
|
+
return leafletAdapter.createLatLng(
|
|
23044
|
+
coordinate.lat,
|
|
23045
|
+
coordinate.lng
|
|
23046
|
+
);
|
|
23047
|
+
}
|
|
23048
|
+
}
|
|
23049
|
+
if (Array.isArray(coordinate) && coordinate.length >= 2) {
|
|
23050
|
+
const [first, second] = coordinate;
|
|
23051
|
+
if (typeof first === "number" && typeof second === "number") {
|
|
23052
|
+
if (first > 90 || second > 90) {
|
|
23053
|
+
return leafletAdapter.createLatLng(second, first);
|
|
23054
|
+
}
|
|
23055
|
+
if (first > 180 || second > 180) {
|
|
23056
|
+
return leafletAdapter.createLatLng(second, first);
|
|
23057
|
+
}
|
|
23058
|
+
return leafletAdapter.createLatLng(first, second);
|
|
23059
|
+
}
|
|
23060
|
+
}
|
|
23061
|
+
if (typeof coordinate === "string") {
|
|
23062
|
+
const coord = coordinate.trim();
|
|
23063
|
+
if (coord.includes(",") && !coord.includes("°") && !coord.includes("'") && !coord.includes('"')) {
|
|
23064
|
+
const parts = coord.split(",").map((p) => parseFloat(p.trim()));
|
|
23065
|
+
if (parts.length >= 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
|
23066
|
+
return this.convertToLatLng(parts);
|
|
23067
|
+
}
|
|
23068
|
+
}
|
|
23069
|
+
const dmsMatch = coord.match(
|
|
23070
|
+
/(\d+)°(\d+)'(?:(\d+(?:\.\d+)?)")?([NS])\s*,?\s*(\d+)°(\d+)'(?:(\d+(?:\.\d+)?)")?([EW])/i
|
|
23071
|
+
);
|
|
23072
|
+
if (dmsMatch) {
|
|
23073
|
+
const [, latDeg, latMin, latSec, latDir, lngDeg, lngMin, lngSec, lngDir] = dmsMatch;
|
|
23074
|
+
const lat = parseFloat(latDeg) + parseFloat(latMin) / 60 + parseFloat(latSec || "0") / 3600;
|
|
23075
|
+
const lng = parseFloat(lngDeg) + parseFloat(lngMin) / 60 + parseFloat(lngSec || "0") / 3600;
|
|
23076
|
+
const finalLat = latDir.toUpperCase() === "S" ? -lat : lat;
|
|
23077
|
+
const finalLng = lngDir.toUpperCase() === "W" ? -lng : lng;
|
|
23078
|
+
return leafletAdapter.createLatLng(finalLat, finalLng);
|
|
23079
|
+
}
|
|
23080
|
+
const ddmMatch = coord.match(
|
|
23081
|
+
/(\d+)°(\d+(?:\.\d+)?)'([NS])\s*,?\s*(\d+)°(\d+(?:\.\d+)?)'([EW])/i
|
|
23082
|
+
);
|
|
23083
|
+
if (ddmMatch) {
|
|
23084
|
+
const [, latDeg, latMin, latDir, lngDeg, lngMin, lngDir] = ddmMatch;
|
|
23085
|
+
const lat = parseFloat(latDeg) + parseFloat(latMin) / 60;
|
|
23086
|
+
const lng = parseFloat(lngDeg) + parseFloat(lngMin) / 60;
|
|
23087
|
+
const finalLat = latDir.toUpperCase() === "S" ? -lat : lat;
|
|
23088
|
+
const finalLng = lngDir.toUpperCase() === "W" ? -lng : lng;
|
|
23089
|
+
return leafletAdapter.createLatLng(finalLat, finalLng);
|
|
23090
|
+
}
|
|
23091
|
+
const ddMatch = coord.match(/(\d+(?:\.\d+)?)°?\s*([NS])\s*,\s*(\d+(?:\.\d+)?)°?\s*([EW])/i);
|
|
23092
|
+
if (ddMatch) {
|
|
23093
|
+
const [, lat, latDir, lng, lngDir] = ddMatch;
|
|
23094
|
+
const finalLat = latDir.toUpperCase() === "S" ? -parseFloat(lat) : parseFloat(lat);
|
|
23095
|
+
const finalLng = lngDir.toUpperCase() === "W" ? -parseFloat(lng) : parseFloat(lng);
|
|
23096
|
+
return leafletAdapter.createLatLng(finalLat, finalLng);
|
|
23097
|
+
}
|
|
23098
|
+
const neMatch = coord.match(/N\s*(\d+(?:\.\d+)?)\s+E\s*(\d+(?:\.\d+)?)/i);
|
|
23099
|
+
if (neMatch) {
|
|
23100
|
+
const [, lat, lng] = neMatch;
|
|
23101
|
+
return leafletAdapter.createLatLng(parseFloat(lat), parseFloat(lng));
|
|
23102
|
+
}
|
|
23103
|
+
const utmMatch = coord.match(/(?:UTM\s+)?(\d+)([NS])\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)/i);
|
|
23104
|
+
if (utmMatch) {
|
|
23105
|
+
throw new Error(
|
|
23106
|
+
`UTM coordinates detected: ${coord}. UTM conversion requires specialized libraries like proj4js. Please convert to decimal degrees first.`
|
|
23107
|
+
);
|
|
23108
|
+
}
|
|
23109
|
+
const mgrsMatch = coord.match(/(\d+)([A-Z])\s+([A-Z]{2})\s+(\d+)\s+(\d+)/i);
|
|
23110
|
+
if (mgrsMatch) {
|
|
23111
|
+
throw new Error(
|
|
23112
|
+
`MGRS coordinates detected: ${coord}. MGRS conversion requires specialized libraries. Please convert to decimal degrees first.`
|
|
23113
|
+
);
|
|
23114
|
+
}
|
|
23115
|
+
const plusCodeMatch = coord.match(
|
|
23116
|
+
/^[23456789CFGHJMPQRVWX]{2,3}[23456789CFGHJMPQRVWX]{3,7}\+[23456789CFGHJMPQRVWX]{2,3}$/i
|
|
23117
|
+
);
|
|
23118
|
+
if (plusCodeMatch) {
|
|
23119
|
+
throw new Error(
|
|
23120
|
+
`Plus Code detected: ${coord}. Plus Code conversion requires specialized libraries. Please convert to decimal degrees first.`
|
|
23121
|
+
);
|
|
23122
|
+
}
|
|
23123
|
+
}
|
|
23124
|
+
throw new Error(`Unable to convert coordinate: ${JSON.stringify(coordinate)}`);
|
|
23125
|
+
}
|
|
23126
|
+
/**
|
|
23127
|
+
* Convert any coordinate array format to L.LatLng[][][]
|
|
23128
|
+
* Used by addPredefinedPolygon for flexible input handling
|
|
23129
|
+
*/
|
|
23130
|
+
static convertToLatLngArray(geoborders) {
|
|
23131
|
+
return geoborders.map(
|
|
23132
|
+
(group) => group.map((polygon2) => polygon2.map((coord) => this.convertToLatLng(coord)))
|
|
23133
|
+
);
|
|
23134
|
+
}
|
|
23135
|
+
// ========================================================================
|
|
23136
|
+
// POTENTIALLY UNUSED METHODS - TO BE REVIEWED FOR DELETION
|
|
23137
|
+
// ========================================================================
|
|
23138
|
+
// /**
|
|
23139
|
+
// * Simple within check (placeholder for more complex logic)
|
|
23140
|
+
// * This is a simplified version - in a real implementation this would use proper geometric algorithms
|
|
23141
|
+
// */
|
|
23142
|
+
// private static isWithin(inner: number[][], outer: number[][]): boolean {
|
|
23143
|
+
// // Simplified check - just compare first points
|
|
23144
|
+
// if (!inner || !outer || inner.length === 0 || outer.length === 0) {
|
|
23145
|
+
// return false;
|
|
23146
|
+
// }
|
|
23147
|
+
// // This is a placeholder implementation
|
|
23148
|
+
// // In the real implementation, this would use proper point-in-polygon algorithms
|
|
23149
|
+
// return false;
|
|
23150
|
+
// }
|
|
23151
|
+
}
|
|
23152
|
+
function deepMerge(target, ...sources) {
|
|
23153
|
+
if (!sources.length) return target;
|
|
23154
|
+
for (const source of sources) {
|
|
23155
|
+
if (!source) continue;
|
|
23156
|
+
for (const key in source) {
|
|
23157
|
+
const sourceValue = source[key];
|
|
23158
|
+
const targetValue = target[key];
|
|
23159
|
+
if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue)) {
|
|
23160
|
+
const base = targetValue && typeof targetValue === "object" && !Array.isArray(targetValue) ? targetValue : {};
|
|
23161
|
+
target[key] = deepMerge(base, sourceValue);
|
|
23162
|
+
} else if (sourceValue !== void 0) {
|
|
23163
|
+
target[key] = sourceValue;
|
|
23164
|
+
}
|
|
23165
|
+
}
|
|
23166
|
+
}
|
|
23167
|
+
return target;
|
|
23168
|
+
}
|
|
23169
|
+
class Polydraw extends L$1.Control {
|
|
21153
23170
|
constructor(options) {
|
|
21154
23171
|
super(options);
|
|
21155
23172
|
__publicField(this, "map");
|
|
@@ -21172,20 +23189,25 @@ class Polydraw extends L.Control {
|
|
|
21172
23189
|
__publicField(this, "_boundTouchMove");
|
|
21173
23190
|
__publicField(this, "_boundTouchEnd");
|
|
21174
23191
|
__publicField(this, "_boundTouchStart");
|
|
23192
|
+
__publicField(this, "_boundPointerDown");
|
|
23193
|
+
__publicField(this, "_boundPointerMove");
|
|
23194
|
+
__publicField(this, "_boundPointerUp");
|
|
23195
|
+
__publicField(this, "_lastTapTime", 0);
|
|
23196
|
+
__publicField(this, "_tapTimeout", null);
|
|
21175
23197
|
/**
|
|
21176
23198
|
* Updates map interactions based on the current drawing mode.
|
|
21177
23199
|
*/
|
|
21178
23200
|
__publicField(this, "_handleActivateToggle", () => {
|
|
21179
23201
|
const container = this.getContainer();
|
|
21180
23202
|
if (!container) return;
|
|
21181
|
-
const
|
|
21182
|
-
if (
|
|
21183
|
-
|
|
23203
|
+
const activateButton = container.querySelector(".icon-activate");
|
|
23204
|
+
if (leafletAdapter.domUtil.hasClass(activateButton, "active")) {
|
|
23205
|
+
leafletAdapter.domUtil.removeClass(activateButton, "active");
|
|
21184
23206
|
if (this.subContainer) {
|
|
21185
23207
|
this.subContainer.style.maxHeight = "0px";
|
|
21186
23208
|
}
|
|
21187
23209
|
} else {
|
|
21188
|
-
|
|
23210
|
+
leafletAdapter.domUtil.addClass(activateButton, "active");
|
|
21189
23211
|
if (this.subContainer) {
|
|
21190
23212
|
this.subContainer.style.maxHeight = "250px";
|
|
21191
23213
|
}
|
|
@@ -21239,6 +23261,18 @@ class Polydraw extends L.Control {
|
|
|
21239
23261
|
this.setDrawMode(DrawMode.PointToPoint);
|
|
21240
23262
|
this.polygonInformation.saveCurrentState();
|
|
21241
23263
|
});
|
|
23264
|
+
__publicField(this, "_handlePointToPointSubtractClick", (e) => {
|
|
23265
|
+
if (e) {
|
|
23266
|
+
e.preventDefault();
|
|
23267
|
+
e.stopPropagation();
|
|
23268
|
+
}
|
|
23269
|
+
if (this.modeManager.getCurrentMode() === DrawMode.PointToPointSubtract) {
|
|
23270
|
+
this.setDrawMode(DrawMode.Off);
|
|
23271
|
+
return;
|
|
23272
|
+
}
|
|
23273
|
+
this.setDrawMode(DrawMode.PointToPointSubtract);
|
|
23274
|
+
this.polygonInformation.saveCurrentState();
|
|
23275
|
+
});
|
|
21242
23276
|
/**
|
|
21243
23277
|
* Handle marker hover when modifier key is held - event handler version
|
|
21244
23278
|
*/
|
|
@@ -21262,11 +23296,11 @@ class Polydraw extends L.Control {
|
|
|
21262
23296
|
element.classList.remove("edge-deletion-hover");
|
|
21263
23297
|
}
|
|
21264
23298
|
});
|
|
21265
|
-
|
|
23299
|
+
const baseDefaults = structuredClone(defaultConfig);
|
|
23300
|
+
this.config = deepMerge(baseDefaults, (options == null ? void 0 : options.config) ?? {});
|
|
21266
23301
|
if (options == null ? void 0 : options.configPath) {
|
|
21267
23302
|
this.loadExternalConfig(options.configPath, options == null ? void 0 : options.config);
|
|
21268
23303
|
} else {
|
|
21269
|
-
this.config = { ...defaultConfig, ...(options == null ? void 0 : options.config) || {} };
|
|
21270
23304
|
this.initializeComponents();
|
|
21271
23305
|
}
|
|
21272
23306
|
}
|
|
@@ -21278,7 +23312,7 @@ class Polydraw extends L.Control {
|
|
|
21278
23312
|
*/
|
|
21279
23313
|
onAdd(_map) {
|
|
21280
23314
|
const extendedMap = _map;
|
|
21281
|
-
const browser = L.Browser;
|
|
23315
|
+
const browser = L$1.Browser;
|
|
21282
23316
|
extendedMap._onResize = () => {
|
|
21283
23317
|
};
|
|
21284
23318
|
if (browser.touch && browser.mobile) {
|
|
@@ -21286,10 +23320,11 @@ class Polydraw extends L.Control {
|
|
|
21286
23320
|
}
|
|
21287
23321
|
this.map = _map;
|
|
21288
23322
|
this.setupKeyboardHandlers();
|
|
21289
|
-
const container =
|
|
23323
|
+
const container = leafletAdapter.domUtil.create("div", "leaflet-control leaflet-bar");
|
|
21290
23324
|
this.initializeUI(container);
|
|
21291
23325
|
this.createTracer();
|
|
21292
23326
|
this.initializeManagers();
|
|
23327
|
+
this.setDrawMode(this.config.defaultMode);
|
|
21293
23328
|
this.setupEventListeners();
|
|
21294
23329
|
return container;
|
|
21295
23330
|
}
|
|
@@ -21323,10 +23358,11 @@ class Polydraw extends L.Control {
|
|
|
21323
23358
|
}
|
|
21324
23359
|
/**
|
|
21325
23360
|
* Adds a predefined polygon to the map.
|
|
21326
|
-
* @param
|
|
23361
|
+
* @param geoborders - Flexible coordinate format: objects ({lat, lng}), arrays ([lat, lng] or [lng, lat]), strings ("lat,lng" or "N59 E10")
|
|
21327
23362
|
* @param options - Optional parameters, including visual optimization level.
|
|
21328
23363
|
*/
|
|
21329
|
-
async addPredefinedPolygon(
|
|
23364
|
+
async addPredefinedPolygon(geoborders, options) {
|
|
23365
|
+
const geographicBorders = CoordinateUtils.convertToLatLngArray(geoborders);
|
|
21330
23366
|
if (!geographicBorders || geographicBorders.length === 0) {
|
|
21331
23367
|
throw new Error("Cannot add empty polygon array");
|
|
21332
23368
|
}
|
|
@@ -21362,6 +23398,29 @@ class Polydraw extends L.Control {
|
|
|
21362
23398
|
}
|
|
21363
23399
|
}
|
|
21364
23400
|
}
|
|
23401
|
+
/**
|
|
23402
|
+
* Adds predefined polygons from GeoJSON to the map.
|
|
23403
|
+
* @param geojsonFeatures - An array of GeoJSON Polygon or MultiPolygon features.
|
|
23404
|
+
* @param options - Optional parameters, including visual optimization level.
|
|
23405
|
+
*/
|
|
23406
|
+
async addPredefinedGeoJSONs(geojsonFeatures, options) {
|
|
23407
|
+
for (const geojsonFeature of geojsonFeatures) {
|
|
23408
|
+
const { type, coordinates } = geojsonFeature.geometry;
|
|
23409
|
+
if (type === "MultiPolygon") {
|
|
23410
|
+
for (const polygonCoords of coordinates) {
|
|
23411
|
+
const latLngs = polygonCoords.map(
|
|
23412
|
+
(ring) => ring.map((point2) => L$1.latLng(point2[1], point2[0]))
|
|
23413
|
+
);
|
|
23414
|
+
await this.addPredefinedPolygon([latLngs], options);
|
|
23415
|
+
}
|
|
23416
|
+
} else if (type === "Polygon") {
|
|
23417
|
+
const latLngs = coordinates.map(
|
|
23418
|
+
(ring) => ring.map((point2) => L$1.latLng(point2[1], point2[0]))
|
|
23419
|
+
);
|
|
23420
|
+
await this.addPredefinedPolygon([latLngs], options);
|
|
23421
|
+
}
|
|
23422
|
+
}
|
|
23423
|
+
}
|
|
21365
23424
|
/**
|
|
21366
23425
|
* Sets the current drawing mode.
|
|
21367
23426
|
* @param mode - The drawing mode to set.
|
|
@@ -21369,12 +23428,12 @@ class Polydraw extends L.Control {
|
|
|
21369
23428
|
setDrawMode(mode) {
|
|
21370
23429
|
const previousMode = this.drawMode;
|
|
21371
23430
|
this._updateDrawModeState(mode);
|
|
21372
|
-
if (previousMode === DrawMode.PointToPoint && mode !== DrawMode.PointToPoint) {
|
|
23431
|
+
if ((previousMode === DrawMode.PointToPoint || previousMode === DrawMode.PointToPointSubtract) && mode !== DrawMode.PointToPoint && mode !== DrawMode.PointToPointSubtract) {
|
|
21373
23432
|
this.polygonDrawManager.clearP2pMarkers();
|
|
21374
23433
|
this.stopDraw();
|
|
21375
23434
|
} else if (mode === DrawMode.Off) {
|
|
21376
23435
|
this.stopDraw();
|
|
21377
|
-
} else if (mode !== DrawMode.PointToPoint) {
|
|
23436
|
+
} else if (mode !== DrawMode.PointToPoint && mode !== DrawMode.PointToPointSubtract) {
|
|
21378
23437
|
this.stopDraw();
|
|
21379
23438
|
}
|
|
21380
23439
|
if (this.map) {
|
|
@@ -21428,16 +23487,16 @@ class Polydraw extends L.Control {
|
|
|
21428
23487
|
*/
|
|
21429
23488
|
initializeUI(container) {
|
|
21430
23489
|
injectDynamicStyles(this.config);
|
|
21431
|
-
L.DomEvent.disableClickPropagation(container);
|
|
21432
|
-
L.DomEvent.on(container, "mousedown", L.DomEvent.stopPropagation);
|
|
21433
|
-
L.DomEvent.on(container, "touchstart", L.DomEvent.stopPropagation);
|
|
21434
|
-
L.DomEvent.on(container, "click", L.DomEvent.stopPropagation);
|
|
23490
|
+
L$1.DomEvent.disableClickPropagation(container);
|
|
23491
|
+
L$1.DomEvent.on(container, "mousedown", L$1.DomEvent.stopPropagation);
|
|
23492
|
+
L$1.DomEvent.on(container, "touchstart", L$1.DomEvent.stopPropagation);
|
|
23493
|
+
L$1.DomEvent.on(container, "click", L$1.DomEvent.stopPropagation);
|
|
21435
23494
|
container.style.display = "flex";
|
|
21436
23495
|
container.style.flexDirection = "column-reverse";
|
|
21437
23496
|
container.style.pointerEvents = "auto";
|
|
21438
23497
|
container.style.position = "relative";
|
|
21439
23498
|
container.style.zIndex = "1000";
|
|
21440
|
-
this.subContainer =
|
|
23499
|
+
this.subContainer = leafletAdapter.domUtil.create("div", "sub-buttons", container);
|
|
21441
23500
|
this.subContainer.style.maxHeight = "0px";
|
|
21442
23501
|
this.subContainer.style.overflow = "hidden";
|
|
21443
23502
|
this.subContainer.style.transition = "max-height 0.3s ease";
|
|
@@ -21451,7 +23510,8 @@ class Polydraw extends L.Control {
|
|
|
21451
23510
|
this._handleDrawClick,
|
|
21452
23511
|
this._handleSubtractClick,
|
|
21453
23512
|
this._handleEraseClick,
|
|
21454
|
-
this._handlePointToPointClick
|
|
23513
|
+
this._handlePointToPointClick,
|
|
23514
|
+
this._handlePointToPointSubtractClick
|
|
21455
23515
|
);
|
|
21456
23516
|
this.ensureButtonTouchResponsiveness(container);
|
|
21457
23517
|
const uiUpdateListener = (mode) => {
|
|
@@ -21477,9 +23537,9 @@ class Polydraw extends L.Control {
|
|
|
21477
23537
|
const mapZoomEnabled = this.modeManager.canPerformAction("mapZoom");
|
|
21478
23538
|
const mapDoubleClickEnabled = this.modeManager.canPerformAction("mapDoubleClickZoom");
|
|
21479
23539
|
if (shouldShowCrosshair) {
|
|
21480
|
-
|
|
23540
|
+
leafletAdapter.domUtil.addClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21481
23541
|
} else {
|
|
21482
|
-
|
|
23542
|
+
leafletAdapter.domUtil.removeClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21483
23543
|
}
|
|
21484
23544
|
this.events(false);
|
|
21485
23545
|
this.setLeafletMapEvents(mapDragEnabled, mapDoubleClickEnabled, mapZoomEnabled);
|
|
@@ -21494,10 +23554,14 @@ class Polydraw extends L.Control {
|
|
|
21494
23554
|
this.eventManager.on("polydraw:polygon:created", async (data) => {
|
|
21495
23555
|
this.stopDraw();
|
|
21496
23556
|
if (data.isPointToPoint) {
|
|
21497
|
-
|
|
21498
|
-
|
|
21499
|
-
|
|
21500
|
-
|
|
23557
|
+
if (data.mode === DrawMode.PointToPointSubtract) {
|
|
23558
|
+
await this.polygonMutationManager.subtractPolygon(data.polygon);
|
|
23559
|
+
} else {
|
|
23560
|
+
await this.polygonMutationManager.addPolygon(data.polygon, {
|
|
23561
|
+
simplify: false,
|
|
23562
|
+
noMerge: false
|
|
23563
|
+
});
|
|
23564
|
+
}
|
|
21501
23565
|
} else {
|
|
21502
23566
|
await this.handleFreehandDrawCompletion(data.polygon);
|
|
21503
23567
|
}
|
|
@@ -21505,14 +23569,14 @@ class Polydraw extends L.Control {
|
|
|
21505
23569
|
});
|
|
21506
23570
|
this.eventManager.on("polydraw:draw:cancel", () => {
|
|
21507
23571
|
this.stopDraw();
|
|
21508
|
-
this.setDrawMode(
|
|
23572
|
+
this.setDrawMode(this.config.defaultMode);
|
|
21509
23573
|
});
|
|
21510
23574
|
}
|
|
21511
23575
|
/**
|
|
21512
23576
|
* Initializes and adds the tracer polyline to the map.
|
|
21513
23577
|
*/
|
|
21514
23578
|
createTracer() {
|
|
21515
|
-
this.tracer =
|
|
23579
|
+
this.tracer = leafletAdapter.createPolyline([], {
|
|
21516
23580
|
...this.config.polyLineOptions,
|
|
21517
23581
|
color: this.config.colors.polyline
|
|
21518
23582
|
});
|
|
@@ -21557,18 +23621,18 @@ class Polydraw extends L.Control {
|
|
|
21557
23621
|
);
|
|
21558
23622
|
}
|
|
21559
23623
|
const externalConfig = await response.json();
|
|
21560
|
-
this.config =
|
|
21561
|
-
|
|
21562
|
-
|
|
21563
|
-
|
|
21564
|
-
|
|
23624
|
+
this.config = deepMerge(
|
|
23625
|
+
structuredClone(defaultConfig),
|
|
23626
|
+
externalConfig ?? {},
|
|
23627
|
+
inlineConfig ?? {}
|
|
23628
|
+
);
|
|
21565
23629
|
this.initializeComponents();
|
|
21566
23630
|
} catch (error) {
|
|
21567
23631
|
console.warn(
|
|
21568
23632
|
"Failed to load external config, falling back to default + inline config:",
|
|
21569
23633
|
error
|
|
21570
23634
|
);
|
|
21571
|
-
this.config =
|
|
23635
|
+
this.config = deepMerge(structuredClone(defaultConfig), inlineConfig ?? {});
|
|
21572
23636
|
this.initializeComponents();
|
|
21573
23637
|
}
|
|
21574
23638
|
}
|
|
@@ -21592,9 +23656,9 @@ class Polydraw extends L.Control {
|
|
|
21592
23656
|
_updateUIAfterDrawModeChange(mode) {
|
|
21593
23657
|
const shouldShowCrosshair = this.modeManager.shouldShowCrosshairCursor();
|
|
21594
23658
|
if (shouldShowCrosshair) {
|
|
21595
|
-
|
|
23659
|
+
leafletAdapter.domUtil.addClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21596
23660
|
} else {
|
|
21597
|
-
|
|
23661
|
+
leafletAdapter.domUtil.removeClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21598
23662
|
}
|
|
21599
23663
|
try {
|
|
21600
23664
|
switch (mode) {
|
|
@@ -21621,6 +23685,12 @@ class Polydraw extends L.Control {
|
|
|
21621
23685
|
dashArray: "5, 5"
|
|
21622
23686
|
});
|
|
21623
23687
|
break;
|
|
23688
|
+
case DrawMode.PointToPointSubtract:
|
|
23689
|
+
this.tracer.setStyle({
|
|
23690
|
+
color: this.config.colors.subtractLine,
|
|
23691
|
+
dashArray: "5, 5"
|
|
23692
|
+
});
|
|
23693
|
+
break;
|
|
21624
23694
|
}
|
|
21625
23695
|
} catch (error) {
|
|
21626
23696
|
}
|
|
@@ -21661,7 +23731,7 @@ class Polydraw extends L.Control {
|
|
|
21661
23731
|
const shouldBeDraggable = this.modeManager.canPerformAction("markerDrag");
|
|
21662
23732
|
this.arrayOfFeatureGroups.forEach((featureGroup) => {
|
|
21663
23733
|
featureGroup.eachLayer((layer) => {
|
|
21664
|
-
if (layer instanceof L.Marker) {
|
|
23734
|
+
if (layer instanceof L$1.Marker) {
|
|
21665
23735
|
const marker = layer;
|
|
21666
23736
|
try {
|
|
21667
23737
|
marker.options.draggable = shouldBeDraggable;
|
|
@@ -21719,12 +23789,19 @@ class Polydraw extends L.Control {
|
|
|
21719
23789
|
* @param onoff - A boolean indicating whether to attach or detach the events.
|
|
21720
23790
|
*/
|
|
21721
23791
|
drawStartedEvents(onoff) {
|
|
23792
|
+
console.log("drawStartedEvents called with onoff:", onoff);
|
|
21722
23793
|
const onoroff = onoff ? "on" : "off";
|
|
21723
23794
|
this.map[onoroff]("mousemove", this.mouseMove, this);
|
|
21724
23795
|
this.map[onoroff]("mouseup", this.mouseUpLeave, this);
|
|
21725
23796
|
if (onoff) {
|
|
21726
23797
|
this._boundTouchMove = (e) => this.mouseMove(e);
|
|
21727
23798
|
this._boundTouchEnd = (e) => this.mouseUpLeave(e);
|
|
23799
|
+
if (LeafletVersionDetector.isV2()) {
|
|
23800
|
+
this._boundPointerMove = (e) => this.mouseMove(e);
|
|
23801
|
+
this._boundPointerUp = (e) => this.mouseUpLeave(e);
|
|
23802
|
+
this.map.getContainer().addEventListener("pointermove", this._boundPointerMove, { passive: false });
|
|
23803
|
+
this.map.getContainer().addEventListener("pointerup", this._boundPointerUp, { passive: false });
|
|
23804
|
+
}
|
|
21728
23805
|
this.map.getContainer().addEventListener("touchmove", this._boundTouchMove, { passive: false });
|
|
21729
23806
|
this.map.getContainer().addEventListener("touchend", this._boundTouchEnd, { passive: false });
|
|
21730
23807
|
} else {
|
|
@@ -21734,6 +23811,12 @@ class Polydraw extends L.Control {
|
|
|
21734
23811
|
if (this._boundTouchEnd) {
|
|
21735
23812
|
this.map.getContainer().removeEventListener("touchend", this._boundTouchEnd);
|
|
21736
23813
|
}
|
|
23814
|
+
if (this._boundPointerMove) {
|
|
23815
|
+
this.map.getContainer().removeEventListener("pointermove", this._boundPointerMove);
|
|
23816
|
+
}
|
|
23817
|
+
if (this._boundPointerUp) {
|
|
23818
|
+
this.map.getContainer().removeEventListener("pointerup", this._boundPointerUp);
|
|
23819
|
+
}
|
|
21737
23820
|
}
|
|
21738
23821
|
}
|
|
21739
23822
|
/**
|
|
@@ -21745,74 +23828,111 @@ class Polydraw extends L.Control {
|
|
|
21745
23828
|
this.map[onoroff]("mousedown", this.mouseDown, this);
|
|
21746
23829
|
this.map[onoroff]("dblclick", this.handleDoubleClick, this);
|
|
21747
23830
|
if (onoff) {
|
|
21748
|
-
this._boundTouchStart = (e) => this.
|
|
23831
|
+
this._boundTouchStart = (e) => this.handleTouchStart(e);
|
|
23832
|
+
if (LeafletVersionDetector.isV2()) {
|
|
23833
|
+
this._boundPointerDown = (e) => this.mouseDown(e);
|
|
23834
|
+
this.map.getContainer().addEventListener("pointerdown", this._boundPointerDown, { passive: false });
|
|
23835
|
+
}
|
|
21749
23836
|
this.map.getContainer().addEventListener("touchstart", this._boundTouchStart, { passive: false });
|
|
21750
23837
|
} else {
|
|
21751
23838
|
if (this._boundTouchStart) {
|
|
21752
23839
|
this.map.getContainer().removeEventListener("touchstart", this._boundTouchStart);
|
|
21753
23840
|
}
|
|
23841
|
+
if (this._boundPointerDown) {
|
|
23842
|
+
this.map.getContainer().removeEventListener("pointerdown", this._boundPointerDown);
|
|
23843
|
+
}
|
|
23844
|
+
}
|
|
23845
|
+
}
|
|
23846
|
+
/**
|
|
23847
|
+
* Handle touch start events with double-tap detection
|
|
23848
|
+
* @param event - The touch event
|
|
23849
|
+
*/
|
|
23850
|
+
handleTouchStart(event) {
|
|
23851
|
+
const currentTime = Date.now();
|
|
23852
|
+
const timeDiff = currentTime - this._lastTapTime;
|
|
23853
|
+
if (this._tapTimeout) {
|
|
23854
|
+
clearTimeout(this._tapTimeout);
|
|
23855
|
+
this._tapTimeout = null;
|
|
23856
|
+
}
|
|
23857
|
+
if (timeDiff < 300 && timeDiff > 0) {
|
|
23858
|
+
this.handleDoubleTap(event);
|
|
23859
|
+
this._lastTapTime = 0;
|
|
23860
|
+
} else {
|
|
23861
|
+
this._lastTapTime = currentTime;
|
|
23862
|
+
this._tapTimeout = window.setTimeout(() => {
|
|
23863
|
+
this.mouseDown(event);
|
|
23864
|
+
this._tapTimeout = null;
|
|
23865
|
+
}, 300);
|
|
23866
|
+
}
|
|
23867
|
+
}
|
|
23868
|
+
/**
|
|
23869
|
+
* Handle double-tap for touch devices
|
|
23870
|
+
* @param event - The touch event
|
|
23871
|
+
*/
|
|
23872
|
+
handleDoubleTap(event) {
|
|
23873
|
+
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint && this.modeManager.getCurrentMode() !== DrawMode.PointToPointSubtract) {
|
|
23874
|
+
return;
|
|
21754
23875
|
}
|
|
23876
|
+
this.polygonDrawManager.handleDoubleTap(event);
|
|
21755
23877
|
}
|
|
21756
23878
|
/**
|
|
21757
23879
|
* Handles the mouse down event to start a drawing operation.
|
|
21758
|
-
* @param event - The mouse or
|
|
23880
|
+
* @param event - The mouse, touch, or pointer event.
|
|
21759
23881
|
*/
|
|
21760
23882
|
mouseDown(event) {
|
|
21761
|
-
|
|
21762
|
-
|
|
23883
|
+
console.log("mouseDown called", event.type, event);
|
|
23884
|
+
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
23885
|
+
if (EventAdapter.shouldPreventDefault(normalizedEvent)) {
|
|
23886
|
+
normalizedEvent.preventDefault();
|
|
21763
23887
|
}
|
|
21764
23888
|
if (this.modeManager.isInOffMode()) {
|
|
23889
|
+
console.log("In off mode, ignoring");
|
|
21765
23890
|
return;
|
|
21766
23891
|
}
|
|
21767
|
-
|
|
21768
|
-
|
|
21769
|
-
clickLatLng = event.latlng;
|
|
21770
|
-
} else if ("touches" in event && event.touches && event.touches.length > 0) {
|
|
21771
|
-
const rect = this.map.getContainer().getBoundingClientRect();
|
|
21772
|
-
clickLatLng = this.map.containerPointToLatLng([
|
|
21773
|
-
event.touches[0].clientX - rect.x,
|
|
21774
|
-
event.touches[0].clientY - rect.y
|
|
21775
|
-
]);
|
|
21776
|
-
}
|
|
23892
|
+
const clickLatLng = EventAdapter.extractCoordinates(normalizedEvent, this.map);
|
|
23893
|
+
console.log("Extracted coordinates:", clickLatLng);
|
|
21777
23894
|
if (!clickLatLng) {
|
|
23895
|
+
console.log("No coordinates extracted");
|
|
21778
23896
|
return;
|
|
21779
23897
|
}
|
|
21780
|
-
if (this.modeManager.getCurrentMode() === DrawMode.PointToPoint) {
|
|
23898
|
+
if (this.modeManager.getCurrentMode() === DrawMode.PointToPoint || this.modeManager.getCurrentMode() === DrawMode.PointToPointSubtract) {
|
|
23899
|
+
console.log("Point-to-Point mode, calling handlePointToPointClick");
|
|
21781
23900
|
this.polygonDrawManager.handlePointToPointClick(clickLatLng);
|
|
21782
23901
|
return;
|
|
21783
23902
|
}
|
|
23903
|
+
console.log("Normal drawing mode, setting tracer and starting draw");
|
|
21784
23904
|
this.tracer.setLatLngs([clickLatLng]);
|
|
21785
23905
|
this.startDraw();
|
|
21786
23906
|
}
|
|
21787
23907
|
/**
|
|
21788
23908
|
* Handles the mouse move event to draw the tracer polyline.
|
|
21789
|
-
* @param event - The mouse or
|
|
23909
|
+
* @param event - The mouse, touch, or pointer event.
|
|
21790
23910
|
*/
|
|
21791
23911
|
mouseMove(event) {
|
|
21792
|
-
|
|
21793
|
-
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
event.touches[0].clientX - rect.x,
|
|
21801
|
-
event.touches[0].clientY - rect.y
|
|
21802
|
-
]);
|
|
23912
|
+
console.log("mouseMove called", event.type);
|
|
23913
|
+
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
23914
|
+
if (EventAdapter.shouldPreventDefault(normalizedEvent)) {
|
|
23915
|
+
normalizedEvent.preventDefault();
|
|
23916
|
+
}
|
|
23917
|
+
const latlng = EventAdapter.extractCoordinates(normalizedEvent, this.map);
|
|
23918
|
+
if (latlng) {
|
|
23919
|
+
console.log("Adding latlng to tracer:", latlng);
|
|
21803
23920
|
this.tracer.addLatLng(latlng);
|
|
21804
23921
|
}
|
|
21805
23922
|
}
|
|
21806
23923
|
/**
|
|
21807
23924
|
* Handles the mouse up event to complete a drawing operation.
|
|
21808
|
-
* @param event - The mouse or
|
|
23925
|
+
* @param event - The mouse, touch, or pointer event.
|
|
21809
23926
|
*/
|
|
21810
23927
|
async mouseUpLeave(event) {
|
|
21811
|
-
|
|
21812
|
-
|
|
23928
|
+
console.log("mouseUpLeave called", event.type);
|
|
23929
|
+
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
23930
|
+
if (EventAdapter.shouldPreventDefault(normalizedEvent)) {
|
|
23931
|
+
normalizedEvent.preventDefault();
|
|
21813
23932
|
}
|
|
21814
23933
|
this.polygonInformation.deletePolygonInformationStorage();
|
|
21815
23934
|
const tracerGeoJSON = this.tracer.toGeoJSON();
|
|
23935
|
+
console.log("Tracer GeoJSON:", tracerGeoJSON);
|
|
21816
23936
|
if (!tracerGeoJSON || !tracerGeoJSON.geometry || !tracerGeoJSON.geometry.coordinates || tracerGeoJSON.geometry.coordinates.length < 3) {
|
|
21817
23937
|
this.stopDraw();
|
|
21818
23938
|
return;
|
|
@@ -21891,6 +24011,7 @@ class Polydraw extends L.Control {
|
|
|
21891
24011
|
* Starts a drawing operation by attaching the necessary event listeners.
|
|
21892
24012
|
*/
|
|
21893
24013
|
startDraw() {
|
|
24014
|
+
console.log("startDraw called, attaching draw events");
|
|
21894
24015
|
this.drawStartedEvents(true);
|
|
21895
24016
|
}
|
|
21896
24017
|
/**
|
|
@@ -21914,7 +24035,7 @@ class Polydraw extends L.Control {
|
|
|
21914
24035
|
*/
|
|
21915
24036
|
handleKeyDown(e) {
|
|
21916
24037
|
if (e.key === "Escape") {
|
|
21917
|
-
if (this.modeManager.getCurrentMode() === DrawMode.PointToPoint) {
|
|
24038
|
+
if (this.modeManager.getCurrentMode() === DrawMode.PointToPoint || this.modeManager.getCurrentMode() === DrawMode.PointToPointSubtract) {
|
|
21918
24039
|
this.polygonDrawManager.cancelPointToPointDrawing();
|
|
21919
24040
|
}
|
|
21920
24041
|
}
|
|
@@ -21943,7 +24064,7 @@ class Polydraw extends L.Control {
|
|
|
21943
24064
|
updateAllMarkersForEdgeDeletion(showFeedback) {
|
|
21944
24065
|
this.arrayOfFeatureGroups.forEach((featureGroup) => {
|
|
21945
24066
|
featureGroup.eachLayer((layer) => {
|
|
21946
|
-
if (layer instanceof L.Marker) {
|
|
24067
|
+
if (layer instanceof L$1.Marker) {
|
|
21947
24068
|
this.updateMarkerForEdgeDeletion(layer, showFeedback);
|
|
21948
24069
|
}
|
|
21949
24070
|
});
|
|
@@ -21970,7 +24091,7 @@ class Polydraw extends L.Control {
|
|
|
21970
24091
|
* @param e - The mouse event.
|
|
21971
24092
|
*/
|
|
21972
24093
|
handleDoubleClick(e) {
|
|
21973
|
-
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint) {
|
|
24094
|
+
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint && this.modeManager.getCurrentMode() !== DrawMode.PointToPointSubtract) {
|
|
21974
24095
|
return;
|
|
21975
24096
|
}
|
|
21976
24097
|
this.polygonDrawManager.handleDoubleClick(e);
|
|
@@ -22018,18 +24139,42 @@ class Polydraw extends L.Control {
|
|
|
22018
24139
|
const activateButton = container.querySelector(".icon-activate");
|
|
22019
24140
|
if (!activateButton) return;
|
|
22020
24141
|
const hasPolygons = this.arrayOfFeatureGroups.length > 0;
|
|
22021
|
-
const isPanelClosed = !
|
|
22022
|
-
|
|
22023
|
-
|
|
24142
|
+
const isPanelClosed = !leafletAdapter.domUtil.hasClass(activateButton, "active");
|
|
24143
|
+
const iconMarkup = leafletAdapter.domUtil.hasClass(activateButton, "active") ? activateButton.dataset.collapsedIcon : activateButton.dataset.activeIcon;
|
|
24144
|
+
if (iconMarkup) {
|
|
24145
|
+
this.applyActivateButtonIcon(activateButton, iconMarkup);
|
|
24146
|
+
}
|
|
24147
|
+
const hasIndicator = hasPolygons && isPanelClosed;
|
|
24148
|
+
if (hasIndicator) {
|
|
24149
|
+
leafletAdapter.domUtil.addClass(activateButton, "polydraw-indicator-active");
|
|
22024
24150
|
} else {
|
|
22025
|
-
|
|
22026
|
-
}
|
|
24151
|
+
leafletAdapter.domUtil.removeClass(activateButton, "polydraw-indicator-active");
|
|
24152
|
+
}
|
|
24153
|
+
const baseBackground = this.config.colors.styles.controlButton.backgroundColor;
|
|
24154
|
+
const baseColor = this.config.colors.styles.controlButton.color;
|
|
24155
|
+
const indicatorBackground = this.config.colors.styles.indicatorActive.backgroundColor;
|
|
24156
|
+
activateButton.style.backgroundColor = hasIndicator ? indicatorBackground : baseBackground;
|
|
24157
|
+
activateButton.style.color = baseColor;
|
|
24158
|
+
}
|
|
24159
|
+
applyActivateButtonIcon(button, svgMarkup) {
|
|
24160
|
+
button.innerHTML = svgMarkup;
|
|
24161
|
+
const svgElement = button.querySelector("svg");
|
|
24162
|
+
if (!svgElement) return;
|
|
24163
|
+
svgElement.setAttribute("width", "24");
|
|
24164
|
+
svgElement.setAttribute("height", "24");
|
|
24165
|
+
svgElement.style.pointerEvents = "none";
|
|
24166
|
+
svgElement.querySelectorAll("*").forEach((el) => {
|
|
24167
|
+
el.style.pointerEvents = "none";
|
|
24168
|
+
});
|
|
22027
24169
|
}
|
|
22028
24170
|
}
|
|
22029
|
-
L.control
|
|
22030
|
-
|
|
22031
|
-
|
|
24171
|
+
if (typeof L$1 !== "undefined" && L$1.control) {
|
|
24172
|
+
L$1.control.polydraw = function(options) {
|
|
24173
|
+
return new Polydraw(options);
|
|
24174
|
+
};
|
|
24175
|
+
}
|
|
22032
24176
|
export {
|
|
22033
|
-
Polydraw as default
|
|
24177
|
+
Polydraw as default,
|
|
24178
|
+
leafletAdapter
|
|
22034
24179
|
};
|
|
22035
24180
|
//# sourceMappingURL=polydraw.es.js.map
|