leaflet-polydraw 0.9.5 → 1.0.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 +45 -1058
- package/dist/polydraw.es.js +1201 -157
- 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/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/coordinate-utils.d.ts +10 -0
- package/dist/types/coordinate-utils.d.ts.map +1 -1
- package/dist/types/enums.d.ts +7 -0
- 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/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.map +1 -1
- package/dist/types/managers/polygon-mutation-manager.d.ts.map +1 -1
- package/dist/types/polydraw.d.ts +22 -5
- package/dist/types/polydraw.d.ts.map +1 -1
- package/package.json +25 -11
package/dist/polydraw.es.js
CHANGED
|
@@ -2,7 +2,7 @@ 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";
|
|
5
|
+
import * as L$1 from "leaflet";
|
|
6
6
|
const mergePolygons = true;
|
|
7
7
|
const kinks$1 = false;
|
|
8
8
|
const modes = { "draw": true, "subtract": true, "deleteAll": true, "p2p": true, "attachElbow": true, "dragElbow": true, "dragPolygons": true, "edgeDeletion": true };
|
|
@@ -37,6 +37,11 @@ const defaultConfig = {
|
|
|
37
37
|
bezier: bezier$1,
|
|
38
38
|
colors
|
|
39
39
|
};
|
|
40
|
+
var LeafletVersion = /* @__PURE__ */ ((LeafletVersion2) => {
|
|
41
|
+
LeafletVersion2["V1"] = "1.x";
|
|
42
|
+
LeafletVersion2["V2"] = "2.x";
|
|
43
|
+
return LeafletVersion2;
|
|
44
|
+
})(LeafletVersion || {});
|
|
40
45
|
var DrawMode = /* @__PURE__ */ ((DrawMode2) => {
|
|
41
46
|
DrawMode2[DrawMode2["Off"] = 0] = "Off";
|
|
42
47
|
DrawMode2[DrawMode2["Add"] = 1] = "Add";
|
|
@@ -15955,7 +15960,7 @@ class PolyDrawUtil {
|
|
|
15955
15960
|
if (isNaN(ll.lat) || isNaN(ll.lng)) ;
|
|
15956
15961
|
tmpLatLng.push(ll);
|
|
15957
15962
|
});
|
|
15958
|
-
const polyLine = new L.Polyline(tmpLatLng);
|
|
15963
|
+
const polyLine = new L$1.Polyline(tmpLatLng);
|
|
15959
15964
|
const bounds = polyLine.getBounds();
|
|
15960
15965
|
if (padding !== 0) {
|
|
15961
15966
|
return bounds.pad(padding);
|
|
@@ -15966,23 +15971,23 @@ class PolyDrawUtil {
|
|
|
15966
15971
|
class Compass {
|
|
15967
15972
|
constructor(minLat = 0, minLng = 0, maxLat = 0, maxLng = 0) {
|
|
15968
15973
|
__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)
|
|
15974
|
+
East: new L$1.LatLng(0, 0),
|
|
15975
|
+
North: new L$1.LatLng(0, 0),
|
|
15976
|
+
NorthEast: new L$1.LatLng(0, 0),
|
|
15977
|
+
NorthWest: new L$1.LatLng(0, 0),
|
|
15978
|
+
South: new L$1.LatLng(0, 0),
|
|
15979
|
+
SouthEast: new L$1.LatLng(0, 0),
|
|
15980
|
+
SouthWest: new L$1.LatLng(0, 0),
|
|
15981
|
+
West: new L$1.LatLng(0, 0)
|
|
15977
15982
|
});
|
|
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);
|
|
15983
|
+
this.direction.North = new L$1.LatLng(maxLat, (minLng + maxLng) / 2);
|
|
15984
|
+
this.direction.NorthEast = new L$1.LatLng(maxLat, maxLng);
|
|
15985
|
+
this.direction.East = new L$1.LatLng((minLat + maxLat) / 2, maxLng);
|
|
15986
|
+
this.direction.SouthEast = new L$1.LatLng(minLat, maxLng);
|
|
15987
|
+
this.direction.South = new L$1.LatLng(minLat, (minLng + maxLng) / 2);
|
|
15988
|
+
this.direction.SouthWest = new L$1.LatLng(minLat, minLng);
|
|
15989
|
+
this.direction.West = new L$1.LatLng((minLat + maxLat) / 2, minLng);
|
|
15990
|
+
this.direction.NorthWest = new L$1.LatLng(maxLat, minLng);
|
|
15986
15991
|
}
|
|
15987
15992
|
getDirection(direction) {
|
|
15988
15993
|
switch (direction) {
|
|
@@ -16766,10 +16771,10 @@ class TurfHelper {
|
|
|
16766
16771
|
for (let i = 0; i < effectiveLen; i++) {
|
|
16767
16772
|
const p1 = points[i];
|
|
16768
16773
|
const p2 = points[(i + 1) % effectiveLen];
|
|
16769
|
-
doubleized.push(new L.LatLng(p1.lat, p1.lng));
|
|
16774
|
+
doubleized.push(new L$1.LatLng(p1.lat, p1.lng));
|
|
16770
16775
|
const midPoint = midpoint(point$1([p1.lng, p1.lat]), point$1([p2.lng, p2.lat]));
|
|
16771
16776
|
doubleized.push(
|
|
16772
|
-
new L.LatLng(midPoint.geometry.coordinates[1], midPoint.geometry.coordinates[0])
|
|
16777
|
+
new L$1.LatLng(midPoint.geometry.coordinates[1], midPoint.geometry.coordinates[0])
|
|
16773
16778
|
);
|
|
16774
16779
|
}
|
|
16775
16780
|
return doubleized;
|
|
@@ -17242,43 +17247,561 @@ class TurfHelper {
|
|
|
17242
17247
|
return feature2;
|
|
17243
17248
|
}
|
|
17244
17249
|
}
|
|
17250
|
+
class LeafletVersionDetector {
|
|
17251
|
+
/**
|
|
17252
|
+
* Detects the Leaflet version being used
|
|
17253
|
+
* @returns The detected Leaflet version
|
|
17254
|
+
*/
|
|
17255
|
+
static getVersion() {
|
|
17256
|
+
if (this._detectedVersion) {
|
|
17257
|
+
return this._detectedVersion;
|
|
17258
|
+
}
|
|
17259
|
+
this._detectedVersion = this.detectVersion();
|
|
17260
|
+
return this._detectedVersion;
|
|
17261
|
+
}
|
|
17262
|
+
/**
|
|
17263
|
+
* Performs the actual version detection
|
|
17264
|
+
* @returns The detected Leaflet version
|
|
17265
|
+
*/
|
|
17266
|
+
static detectVersion() {
|
|
17267
|
+
if (typeof L === "undefined") {
|
|
17268
|
+
return LeafletVersion.V2;
|
|
17269
|
+
}
|
|
17270
|
+
if (L.version) {
|
|
17271
|
+
if (L.version.startsWith("2.")) {
|
|
17272
|
+
return LeafletVersion.V2;
|
|
17273
|
+
}
|
|
17274
|
+
if (L.version.startsWith("1.")) {
|
|
17275
|
+
return LeafletVersion.V1;
|
|
17276
|
+
}
|
|
17277
|
+
}
|
|
17278
|
+
if (typeof L.marker !== "function") {
|
|
17279
|
+
return LeafletVersion.V2;
|
|
17280
|
+
}
|
|
17281
|
+
if (typeof L.marker === "function" && typeof L.polyline === "function" && typeof L.polygon === "function") {
|
|
17282
|
+
return LeafletVersion.V1;
|
|
17283
|
+
}
|
|
17284
|
+
if (L.Marker && typeof L.Marker === "function" && L.Polyline && typeof L.Polyline === "function") {
|
|
17285
|
+
return LeafletVersion.V2;
|
|
17286
|
+
}
|
|
17287
|
+
return LeafletVersion.V1;
|
|
17288
|
+
}
|
|
17289
|
+
/**
|
|
17290
|
+
* Checks if we're running Leaflet v1.x
|
|
17291
|
+
* @returns true if running v1.x
|
|
17292
|
+
*/
|
|
17293
|
+
static isV1() {
|
|
17294
|
+
return this.getVersion() === LeafletVersion.V1;
|
|
17295
|
+
}
|
|
17296
|
+
/**
|
|
17297
|
+
* Checks if we're running Leaflet v2.x
|
|
17298
|
+
* @returns true if running v2.x
|
|
17299
|
+
*/
|
|
17300
|
+
static isV2() {
|
|
17301
|
+
return this.getVersion() === LeafletVersion.V2;
|
|
17302
|
+
}
|
|
17303
|
+
/**
|
|
17304
|
+
* Resets the cached version detection (useful for testing)
|
|
17305
|
+
*/
|
|
17306
|
+
static reset() {
|
|
17307
|
+
this._detectedVersion = null;
|
|
17308
|
+
}
|
|
17309
|
+
/**
|
|
17310
|
+
* Gets detailed version information for debugging
|
|
17311
|
+
* @returns Object with version details
|
|
17312
|
+
*/
|
|
17313
|
+
static getVersionInfo() {
|
|
17314
|
+
const version = this.getVersion();
|
|
17315
|
+
return {
|
|
17316
|
+
version,
|
|
17317
|
+
leafletVersion: typeof L !== "undefined" ? L.version : void 0,
|
|
17318
|
+
hasFactoryMethods: typeof L !== "undefined" && typeof L.marker === "function",
|
|
17319
|
+
hasConstructors: typeof L !== "undefined" && L.Marker && typeof L.Marker === "function",
|
|
17320
|
+
globalLAvailable: typeof L !== "undefined"
|
|
17321
|
+
};
|
|
17322
|
+
}
|
|
17323
|
+
}
|
|
17324
|
+
__publicField(LeafletVersionDetector, "_detectedVersion", null);
|
|
17325
|
+
class LeafletAdapter {
|
|
17326
|
+
constructor() {
|
|
17327
|
+
__publicField(this, "version");
|
|
17328
|
+
/**
|
|
17329
|
+
* DOM utility methods compatibility
|
|
17330
|
+
*/
|
|
17331
|
+
__publicField(this, "domUtil", {
|
|
17332
|
+
create: (tagName, className, container) => {
|
|
17333
|
+
if (typeof L !== "undefined" && L.DomUtil) {
|
|
17334
|
+
return L.DomUtil.create(tagName, className, container);
|
|
17335
|
+
} else {
|
|
17336
|
+
const element = document.createElement(tagName);
|
|
17337
|
+
if (className) {
|
|
17338
|
+
element.className = className;
|
|
17339
|
+
}
|
|
17340
|
+
if (container) {
|
|
17341
|
+
container.appendChild(element);
|
|
17342
|
+
}
|
|
17343
|
+
return element;
|
|
17344
|
+
}
|
|
17345
|
+
},
|
|
17346
|
+
addClass: (el, name) => {
|
|
17347
|
+
if (this.version === LeafletVersion.V1) {
|
|
17348
|
+
L.DomUtil.addClass(el, name);
|
|
17349
|
+
} else {
|
|
17350
|
+
el.classList.add(name);
|
|
17351
|
+
}
|
|
17352
|
+
},
|
|
17353
|
+
removeClass: (el, name) => {
|
|
17354
|
+
if (this.version === LeafletVersion.V1) {
|
|
17355
|
+
L.DomUtil.removeClass(el, name);
|
|
17356
|
+
} else {
|
|
17357
|
+
el.classList.remove(name);
|
|
17358
|
+
}
|
|
17359
|
+
},
|
|
17360
|
+
hasClass: (el, name) => {
|
|
17361
|
+
if (this.version === LeafletVersion.V1) {
|
|
17362
|
+
return L.DomUtil.hasClass(el, name);
|
|
17363
|
+
} else {
|
|
17364
|
+
return el.classList.contains(name);
|
|
17365
|
+
}
|
|
17366
|
+
},
|
|
17367
|
+
setPosition: (el, point2) => {
|
|
17368
|
+
L.DomUtil.setPosition(el, point2);
|
|
17369
|
+
},
|
|
17370
|
+
getPosition: (el) => {
|
|
17371
|
+
return L.DomUtil.getPosition(el);
|
|
17372
|
+
}
|
|
17373
|
+
});
|
|
17374
|
+
/**
|
|
17375
|
+
* DOM event methods compatibility
|
|
17376
|
+
*/
|
|
17377
|
+
__publicField(this, "domEvent", {
|
|
17378
|
+
on: (obj, types, fn, context) => {
|
|
17379
|
+
L.DomEvent.on(obj, types, fn, context);
|
|
17380
|
+
return this;
|
|
17381
|
+
},
|
|
17382
|
+
off: (obj, types, fn, context) => {
|
|
17383
|
+
L.DomEvent.off(obj, types, fn, context);
|
|
17384
|
+
return this;
|
|
17385
|
+
},
|
|
17386
|
+
stopPropagation: (e) => {
|
|
17387
|
+
L.DomEvent.stopPropagation(e);
|
|
17388
|
+
return this;
|
|
17389
|
+
},
|
|
17390
|
+
preventDefault: (e) => {
|
|
17391
|
+
L.DomEvent.preventDefault(e);
|
|
17392
|
+
return this;
|
|
17393
|
+
},
|
|
17394
|
+
stop: (e) => {
|
|
17395
|
+
L.DomEvent.stop(e);
|
|
17396
|
+
return this;
|
|
17397
|
+
},
|
|
17398
|
+
disableClickPropagation: (el) => {
|
|
17399
|
+
L.DomEvent.disableClickPropagation(el);
|
|
17400
|
+
return this;
|
|
17401
|
+
},
|
|
17402
|
+
disableScrollPropagation: (el) => {
|
|
17403
|
+
L.DomEvent.disableScrollPropagation(el);
|
|
17404
|
+
return this;
|
|
17405
|
+
},
|
|
17406
|
+
getMousePosition: (e, container) => {
|
|
17407
|
+
if (this.version === LeafletVersion.V1) {
|
|
17408
|
+
return L.DomEvent.getMousePosition(e, container);
|
|
17409
|
+
} else {
|
|
17410
|
+
return L.DomEvent.getPointerPosition ? L.DomEvent.getPointerPosition(e, container) : L.DomEvent.getMousePosition(e, container);
|
|
17411
|
+
}
|
|
17412
|
+
}
|
|
17413
|
+
});
|
|
17414
|
+
/**
|
|
17415
|
+
* Utility methods compatibility
|
|
17416
|
+
*/
|
|
17417
|
+
__publicField(this, "util", {
|
|
17418
|
+
extend: (dest, ...sources) => {
|
|
17419
|
+
if (this.version === LeafletVersion.V1) {
|
|
17420
|
+
return L.Util.extend(dest, ...sources);
|
|
17421
|
+
} else {
|
|
17422
|
+
return Object.assign(dest, ...sources);
|
|
17423
|
+
}
|
|
17424
|
+
},
|
|
17425
|
+
bind: (fn, obj) => {
|
|
17426
|
+
if (this.version === LeafletVersion.V1) {
|
|
17427
|
+
return L.Util.bind(fn, obj);
|
|
17428
|
+
} else {
|
|
17429
|
+
return fn.bind(obj);
|
|
17430
|
+
}
|
|
17431
|
+
},
|
|
17432
|
+
stamp: (obj) => {
|
|
17433
|
+
return L.Util.stamp(obj);
|
|
17434
|
+
},
|
|
17435
|
+
throttle: (fn, time, context) => {
|
|
17436
|
+
return L.Util.throttle(fn, time, context);
|
|
17437
|
+
},
|
|
17438
|
+
wrapNum: (x, range, includeMax) => {
|
|
17439
|
+
return L.Util.wrapNum(x, range, includeMax);
|
|
17440
|
+
},
|
|
17441
|
+
falseFn: () => {
|
|
17442
|
+
return L.Util.falseFn();
|
|
17443
|
+
},
|
|
17444
|
+
formatNum: (num, digits) => {
|
|
17445
|
+
return L.Util.formatNum(num, digits);
|
|
17446
|
+
},
|
|
17447
|
+
trim: (str) => {
|
|
17448
|
+
if (this.version === LeafletVersion.V1) {
|
|
17449
|
+
return L.Util.trim(str);
|
|
17450
|
+
} else {
|
|
17451
|
+
return str.trim();
|
|
17452
|
+
}
|
|
17453
|
+
},
|
|
17454
|
+
splitWords: (str) => {
|
|
17455
|
+
return L.Util.splitWords(str);
|
|
17456
|
+
},
|
|
17457
|
+
setOptions: (obj, options) => {
|
|
17458
|
+
return L.Util.setOptions(obj, options);
|
|
17459
|
+
},
|
|
17460
|
+
getParamString: (obj, existingUrl, uppercase) => {
|
|
17461
|
+
if (this.version === LeafletVersion.V1) {
|
|
17462
|
+
return L.Util.getParamString(obj, existingUrl, uppercase);
|
|
17463
|
+
} else {
|
|
17464
|
+
const params = new URLSearchParams();
|
|
17465
|
+
for (const key in obj) {
|
|
17466
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
17467
|
+
const paramKey = uppercase ? key.toUpperCase() : key;
|
|
17468
|
+
params.set(paramKey, obj[key]);
|
|
17469
|
+
}
|
|
17470
|
+
}
|
|
17471
|
+
const paramString = params.toString();
|
|
17472
|
+
if (existingUrl) {
|
|
17473
|
+
const separator = existingUrl.indexOf("?") === -1 ? "?" : "&";
|
|
17474
|
+
return existingUrl + separator + paramString;
|
|
17475
|
+
}
|
|
17476
|
+
return paramString ? "?" + paramString : "";
|
|
17477
|
+
}
|
|
17478
|
+
},
|
|
17479
|
+
template: (str, data) => {
|
|
17480
|
+
return L.Util.template(str, data);
|
|
17481
|
+
},
|
|
17482
|
+
isArray: (obj) => {
|
|
17483
|
+
if (this.version === LeafletVersion.V1) {
|
|
17484
|
+
return L.Util.isArray(obj);
|
|
17485
|
+
} else {
|
|
17486
|
+
return Array.isArray(obj);
|
|
17487
|
+
}
|
|
17488
|
+
},
|
|
17489
|
+
indexOf: (array, item) => {
|
|
17490
|
+
return L.Util.indexOf(array, item);
|
|
17491
|
+
},
|
|
17492
|
+
requestAnimFrame: (fn, context, immediate) => {
|
|
17493
|
+
if (this.version === LeafletVersion.V1) {
|
|
17494
|
+
return L.Util.requestAnimFrame(fn, context, immediate);
|
|
17495
|
+
} else {
|
|
17496
|
+
return requestAnimationFrame(context ? fn.bind(context) : fn);
|
|
17497
|
+
}
|
|
17498
|
+
},
|
|
17499
|
+
cancelAnimFrame: (id) => {
|
|
17500
|
+
if (this.version === LeafletVersion.V1) {
|
|
17501
|
+
L.Util.cancelAnimFrame(id);
|
|
17502
|
+
} else {
|
|
17503
|
+
cancelAnimationFrame(id);
|
|
17504
|
+
}
|
|
17505
|
+
}
|
|
17506
|
+
});
|
|
17507
|
+
this.version = LeafletVersionDetector.getVersion();
|
|
17508
|
+
}
|
|
17509
|
+
/**
|
|
17510
|
+
* Creates a tile layer compatible with both Leaflet versions
|
|
17511
|
+
*/
|
|
17512
|
+
createTileLayer(urlTemplate, options) {
|
|
17513
|
+
if (this.version === LeafletVersion.V1) {
|
|
17514
|
+
return L.tileLayer(urlTemplate, options);
|
|
17515
|
+
} else {
|
|
17516
|
+
return new L.TileLayer(urlTemplate, options);
|
|
17517
|
+
}
|
|
17518
|
+
}
|
|
17519
|
+
/**
|
|
17520
|
+
* Creates a map compatible with both Leaflet versions
|
|
17521
|
+
*/
|
|
17522
|
+
createMap(element, options) {
|
|
17523
|
+
if (this.version === LeafletVersion.V1) {
|
|
17524
|
+
return L.map(element, options);
|
|
17525
|
+
} else {
|
|
17526
|
+
return new L.Map(element, options);
|
|
17527
|
+
}
|
|
17528
|
+
}
|
|
17529
|
+
/**
|
|
17530
|
+
* Creates a marker compatible with both Leaflet versions
|
|
17531
|
+
*/
|
|
17532
|
+
createMarker(latlng, options) {
|
|
17533
|
+
if (this.version === LeafletVersion.V1) {
|
|
17534
|
+
return L.marker(latlng, options);
|
|
17535
|
+
} else {
|
|
17536
|
+
return new L.Marker(latlng, options);
|
|
17537
|
+
}
|
|
17538
|
+
}
|
|
17539
|
+
/**
|
|
17540
|
+
* Creates a polyline compatible with both Leaflet versions
|
|
17541
|
+
*/
|
|
17542
|
+
createPolyline(latlngs, options) {
|
|
17543
|
+
if (this.version === LeafletVersion.V1) {
|
|
17544
|
+
return L.polyline(latlngs, options);
|
|
17545
|
+
} else {
|
|
17546
|
+
return new L.Polyline(latlngs, options);
|
|
17547
|
+
}
|
|
17548
|
+
}
|
|
17549
|
+
/**
|
|
17550
|
+
* Creates a polygon compatible with both Leaflet versions
|
|
17551
|
+
*/
|
|
17552
|
+
createPolygon(latlngs, options) {
|
|
17553
|
+
if (this.version === LeafletVersion.V1) {
|
|
17554
|
+
return L.polygon(latlngs, options);
|
|
17555
|
+
} else {
|
|
17556
|
+
return new L.Polygon(latlngs, options);
|
|
17557
|
+
}
|
|
17558
|
+
}
|
|
17559
|
+
/**
|
|
17560
|
+
* Creates a div icon compatible with both Leaflet versions
|
|
17561
|
+
*/
|
|
17562
|
+
createDivIcon(options) {
|
|
17563
|
+
if (this.version === LeafletVersion.V1) {
|
|
17564
|
+
return L.divIcon(options);
|
|
17565
|
+
} else {
|
|
17566
|
+
return new L.DivIcon(options);
|
|
17567
|
+
}
|
|
17568
|
+
}
|
|
17569
|
+
/**
|
|
17570
|
+
* Creates a LatLng object compatible with both Leaflet versions
|
|
17571
|
+
*/
|
|
17572
|
+
createLatLng(lat, lng, alt) {
|
|
17573
|
+
if (this.version === LeafletVersion.V1) {
|
|
17574
|
+
return L.latLng(lat, lng, alt);
|
|
17575
|
+
} else {
|
|
17576
|
+
return new L.LatLng(lat, lng, alt);
|
|
17577
|
+
}
|
|
17578
|
+
}
|
|
17579
|
+
/**
|
|
17580
|
+
* Creates a LatLngBounds object compatible with both Leaflet versions
|
|
17581
|
+
*/
|
|
17582
|
+
createLatLngBounds(corner1, corner2) {
|
|
17583
|
+
if (this.version === LeafletVersion.V1) {
|
|
17584
|
+
return L.latLngBounds(corner1, corner2);
|
|
17585
|
+
} else {
|
|
17586
|
+
return new L.LatLngBounds(corner1, corner2);
|
|
17587
|
+
}
|
|
17588
|
+
}
|
|
17589
|
+
/**
|
|
17590
|
+
* Creates a Point object compatible with both Leaflet versions
|
|
17591
|
+
*/
|
|
17592
|
+
createPoint(x, y, round) {
|
|
17593
|
+
if (this.version === LeafletVersion.V1) {
|
|
17594
|
+
return L.point(x, y, round);
|
|
17595
|
+
} else {
|
|
17596
|
+
return new L.Point(x, y, round);
|
|
17597
|
+
}
|
|
17598
|
+
}
|
|
17599
|
+
/**
|
|
17600
|
+
* Creates a popup compatible with both Leaflet versions
|
|
17601
|
+
*/
|
|
17602
|
+
createPopup(options, source) {
|
|
17603
|
+
if (this.version === LeafletVersion.V1) {
|
|
17604
|
+
return L.popup(options, source);
|
|
17605
|
+
} else {
|
|
17606
|
+
return new L.Popup(options, source);
|
|
17607
|
+
}
|
|
17608
|
+
}
|
|
17609
|
+
/**
|
|
17610
|
+
* Creates a feature group compatible with both Leaflet versions
|
|
17611
|
+
*/
|
|
17612
|
+
createFeatureGroup(layers) {
|
|
17613
|
+
if (this.version === LeafletVersion.V1) {
|
|
17614
|
+
return L.featureGroup(layers);
|
|
17615
|
+
} else {
|
|
17616
|
+
return new L.FeatureGroup(layers);
|
|
17617
|
+
}
|
|
17618
|
+
}
|
|
17619
|
+
/**
|
|
17620
|
+
* Creates a layer group compatible with both Leaflet versions
|
|
17621
|
+
*/
|
|
17622
|
+
createLayerGroup(layers) {
|
|
17623
|
+
if (this.version === LeafletVersion.V1) {
|
|
17624
|
+
return L.layerGroup(layers);
|
|
17625
|
+
} else {
|
|
17626
|
+
return new L.LayerGroup(layers);
|
|
17627
|
+
}
|
|
17628
|
+
}
|
|
17629
|
+
/**
|
|
17630
|
+
* Browser detection compatibility
|
|
17631
|
+
*/
|
|
17632
|
+
getBrowser() {
|
|
17633
|
+
const self = this;
|
|
17634
|
+
return {
|
|
17635
|
+
get ie() {
|
|
17636
|
+
return self.version === LeafletVersion.V1 ? L.Browser.ie : false;
|
|
17637
|
+
},
|
|
17638
|
+
get ielt9() {
|
|
17639
|
+
return self.version === LeafletVersion.V1 ? L.Browser.ielt9 : false;
|
|
17640
|
+
},
|
|
17641
|
+
get edge() {
|
|
17642
|
+
return self.version === LeafletVersion.V1 ? L.Browser.edge : false;
|
|
17643
|
+
},
|
|
17644
|
+
get webkit() {
|
|
17645
|
+
return self.version === LeafletVersion.V1 ? L.Browser.webkit : false;
|
|
17646
|
+
},
|
|
17647
|
+
get android() {
|
|
17648
|
+
return self.version === LeafletVersion.V1 ? L.Browser.android : /Android/.test(navigator.userAgent);
|
|
17649
|
+
},
|
|
17650
|
+
get android23() {
|
|
17651
|
+
return self.version === LeafletVersion.V1 ? L.Browser.android23 : false;
|
|
17652
|
+
},
|
|
17653
|
+
get androidStock() {
|
|
17654
|
+
return self.version === LeafletVersion.V1 ? L.Browser.androidStock : false;
|
|
17655
|
+
},
|
|
17656
|
+
get opera() {
|
|
17657
|
+
return self.version === LeafletVersion.V1 ? L.Browser.opera : false;
|
|
17658
|
+
},
|
|
17659
|
+
get chrome() {
|
|
17660
|
+
return self.version === LeafletVersion.V1 ? L.Browser.chrome : /Chrome/.test(navigator.userAgent);
|
|
17661
|
+
},
|
|
17662
|
+
get gecko() {
|
|
17663
|
+
return self.version === LeafletVersion.V1 ? L.Browser.gecko : false;
|
|
17664
|
+
},
|
|
17665
|
+
get safari() {
|
|
17666
|
+
return self.version === LeafletVersion.V1 ? L.Browser.safari : /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent);
|
|
17667
|
+
},
|
|
17668
|
+
get phantom() {
|
|
17669
|
+
return self.version === LeafletVersion.V1 ? L.Browser.phantom : false;
|
|
17670
|
+
},
|
|
17671
|
+
get opera12() {
|
|
17672
|
+
return self.version === LeafletVersion.V1 ? L.Browser.opera12 : false;
|
|
17673
|
+
},
|
|
17674
|
+
get win() {
|
|
17675
|
+
return self.version === LeafletVersion.V1 ? L.Browser.win : /Win/.test(navigator.platform);
|
|
17676
|
+
},
|
|
17677
|
+
get ie3d() {
|
|
17678
|
+
return self.version === LeafletVersion.V1 ? L.Browser.ie3d : false;
|
|
17679
|
+
},
|
|
17680
|
+
get webkit3d() {
|
|
17681
|
+
return self.version === LeafletVersion.V1 ? L.Browser.webkit3d : false;
|
|
17682
|
+
},
|
|
17683
|
+
get gecko3d() {
|
|
17684
|
+
return self.version === LeafletVersion.V1 ? L.Browser.gecko3d : false;
|
|
17685
|
+
},
|
|
17686
|
+
get any3d() {
|
|
17687
|
+
return self.version === LeafletVersion.V1 ? L.Browser.any3d : true;
|
|
17688
|
+
},
|
|
17689
|
+
get mobile() {
|
|
17690
|
+
return L.Browser.mobile;
|
|
17691
|
+
},
|
|
17692
|
+
get mobileWebkit() {
|
|
17693
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileWebkit : false;
|
|
17694
|
+
},
|
|
17695
|
+
get mobileWebkit3d() {
|
|
17696
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileWebkit3d : false;
|
|
17697
|
+
},
|
|
17698
|
+
get msPointer() {
|
|
17699
|
+
return self.version === LeafletVersion.V1 ? L.Browser.msPointer : false;
|
|
17700
|
+
},
|
|
17701
|
+
get pointer() {
|
|
17702
|
+
return L.Browser.pointer || true;
|
|
17703
|
+
},
|
|
17704
|
+
get touch() {
|
|
17705
|
+
return L.Browser.touch;
|
|
17706
|
+
},
|
|
17707
|
+
get touchNative() {
|
|
17708
|
+
return self.version === LeafletVersion.V1 ? L.Browser.touchNative : false;
|
|
17709
|
+
},
|
|
17710
|
+
get mobileOpera() {
|
|
17711
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileOpera : false;
|
|
17712
|
+
},
|
|
17713
|
+
get mobileGecko() {
|
|
17714
|
+
return self.version === LeafletVersion.V1 ? L.Browser.mobileGecko : false;
|
|
17715
|
+
},
|
|
17716
|
+
get retina() {
|
|
17717
|
+
return L.Browser.retina;
|
|
17718
|
+
},
|
|
17719
|
+
get passiveEvents() {
|
|
17720
|
+
return self.version === LeafletVersion.V1 ? L.Browser.passiveEvents : true;
|
|
17721
|
+
},
|
|
17722
|
+
get canvas() {
|
|
17723
|
+
return self.version === LeafletVersion.V1 ? L.Browser.canvas : true;
|
|
17724
|
+
},
|
|
17725
|
+
get svg() {
|
|
17726
|
+
return self.version === LeafletVersion.V1 ? L.Browser.svg : true;
|
|
17727
|
+
},
|
|
17728
|
+
get vml() {
|
|
17729
|
+
return self.version === LeafletVersion.V1 ? L.Browser.vml : false;
|
|
17730
|
+
},
|
|
17731
|
+
get inlineSvg() {
|
|
17732
|
+
return self.version === LeafletVersion.V1 ? L.Browser.inlineSvg : true;
|
|
17733
|
+
}
|
|
17734
|
+
};
|
|
17735
|
+
}
|
|
17736
|
+
/**
|
|
17737
|
+
* Gets the current Leaflet version being used
|
|
17738
|
+
*/
|
|
17739
|
+
getVersion() {
|
|
17740
|
+
return this.version;
|
|
17741
|
+
}
|
|
17742
|
+
/**
|
|
17743
|
+
* Checks if we're running Leaflet v1.x
|
|
17744
|
+
*/
|
|
17745
|
+
isV1() {
|
|
17746
|
+
return this.version === LeafletVersion.V1;
|
|
17747
|
+
}
|
|
17748
|
+
/**
|
|
17749
|
+
* Checks if we're running Leaflet v2.x
|
|
17750
|
+
*/
|
|
17751
|
+
isV2() {
|
|
17752
|
+
return this.version === LeafletVersion.V2;
|
|
17753
|
+
}
|
|
17754
|
+
}
|
|
17755
|
+
const leafletAdapter = new LeafletAdapter();
|
|
17245
17756
|
function createButtons(container, subContainer, config, onActivateToggle, onDrawClick, onSubtractClick, onEraseClick, onPointToPointClick) {
|
|
17246
|
-
const activate =
|
|
17757
|
+
const activate = leafletAdapter.domUtil.create(
|
|
17758
|
+
"a",
|
|
17759
|
+
"icon-activate",
|
|
17760
|
+
container
|
|
17761
|
+
);
|
|
17247
17762
|
activate.href = "#";
|
|
17248
17763
|
activate.title = "Activate";
|
|
17249
17764
|
activate.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="M5 17V7M5 17C3.89543 17 3 17.8954 3 19C3 20.1046 3.89543 21 5 21C6.10457 21 7 20.1046 7 19M5 17C6.10457 17 7 17.8954 7 19M5 7C6.10457 7 7 6.10457 7 5M5 7C3.89543 7 3 6.10457 3 5C3 3.89543 3.89543 3 5 3C6.10457 3 7 3.89543 7 5M7 5H17M17 5C17 6.10457 17.8954 7 19 7C20.1046 7 21 6.10457 21 5C21 3.89543 20.1046 3 19 3C17.8954 3 17 3.89543 17 5ZM7 19H17M17 19C17 20.1046 17.8954 21 19 21C20.1046 21 21 20.1046 21 19C21 17.8954 20.1046 17 19 17C17.8954 17 17 17.8954 17 19ZM17.9247 6.6737L15.1955 10.3776M15.1955 13.6223L17.9222 17.3223M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>';
|
|
17250
|
-
L.DomEvent.on(activate, "mousedown", L.DomEvent.stopPropagation);
|
|
17251
|
-
L.DomEvent.on(activate, "touchstart", L.DomEvent.stopPropagation);
|
|
17252
|
-
L.DomEvent.on(activate, "click", L.DomEvent.stop).on(activate, "click", onActivateToggle);
|
|
17765
|
+
L$1.DomEvent.on(activate, "mousedown", L$1.DomEvent.stopPropagation);
|
|
17766
|
+
L$1.DomEvent.on(activate, "touchstart", L$1.DomEvent.stopPropagation);
|
|
17767
|
+
L$1.DomEvent.on(activate, "click", L$1.DomEvent.stop).on(activate, "click", onActivateToggle);
|
|
17253
17768
|
if (config.modes.draw) {
|
|
17254
|
-
const draw =
|
|
17769
|
+
const draw = leafletAdapter.domUtil.create("a", "icon-draw", subContainer);
|
|
17255
17770
|
draw.href = "#";
|
|
17256
17771
|
draw.title = "Draw";
|
|
17257
17772
|
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);
|
|
17773
|
+
L$1.DomEvent.on(draw, "mousedown", L$1.DomEvent.stopPropagation);
|
|
17774
|
+
L$1.DomEvent.on(draw, "touchstart", L$1.DomEvent.stopPropagation);
|
|
17775
|
+
L$1.DomEvent.on(draw, "click", L$1.DomEvent.stop).on(draw, "click", onDrawClick);
|
|
17261
17776
|
}
|
|
17262
17777
|
if (config.modes.subtract) {
|
|
17263
|
-
const subtract =
|
|
17778
|
+
const subtract = leafletAdapter.domUtil.create(
|
|
17779
|
+
"a",
|
|
17780
|
+
"icon-subtract",
|
|
17781
|
+
subContainer
|
|
17782
|
+
);
|
|
17264
17783
|
subtract.href = "#";
|
|
17265
17784
|
subtract.title = "Subtract";
|
|
17266
17785
|
subtract.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 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>';
|
|
17267
|
-
L.DomEvent.on(subtract, "mousedown", L.DomEvent.stopPropagation);
|
|
17268
|
-
L.DomEvent.on(subtract, "touchstart", L.DomEvent.stopPropagation);
|
|
17269
|
-
L.DomEvent.on(subtract, "click", L.DomEvent.stop).on(subtract, "click", onSubtractClick);
|
|
17786
|
+
L$1.DomEvent.on(subtract, "mousedown", L$1.DomEvent.stopPropagation);
|
|
17787
|
+
L$1.DomEvent.on(subtract, "touchstart", L$1.DomEvent.stopPropagation);
|
|
17788
|
+
L$1.DomEvent.on(subtract, "click", L$1.DomEvent.stop).on(subtract, "click", onSubtractClick);
|
|
17270
17789
|
}
|
|
17271
|
-
if (config.modes.p2p
|
|
17272
|
-
const p2p =
|
|
17790
|
+
if (config.modes.p2p) {
|
|
17791
|
+
const p2p = leafletAdapter.domUtil.create("a", "icon-p2p", subContainer);
|
|
17273
17792
|
p2p.href = "#";
|
|
17274
17793
|
p2p.title = "Point to Point";
|
|
17275
17794
|
p2p.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="M5 17V7M5 17C3.89543 17 3 17.8954 3 19C3 20.1046 3.89543 21 5 21C6.10457 21 7 20.1046 7 19M5 17C6.10457 17 7 17.8954 7 19M5 7C6.10457 7 7 6.10457 7 5M5 7C3.89543 7 3 6.10457 3 5C3 3.89543 3.89543 3 5 3C6.10457 3 7 3.89543 7 5M7 5H17M17 5C17 6.10457 17.8954 7 19 7C20.1046 7 21 6.10457 21 5C21 3.89543 20.1046 3 19 3C17.8954 3 17 3.89543 17 5ZM7 19H17M17 19C17 20.1046 17.8954 21 19 21C20.1046 21 21 20.1046 21 19C21 17.8954 20.1046 17 19 17C17.8954 17 17 17.8954 17 19ZM17.9247 6.6737L15.1955 10.3776M15.1955 13.6223L17.9222 17.3223M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>';
|
|
17276
|
-
L.DomEvent.on(p2p, "mousedown", L.DomEvent.stopPropagation);
|
|
17277
|
-
L.DomEvent.on(p2p, "touchstart", L.DomEvent.stopPropagation);
|
|
17278
|
-
L.DomEvent.on(p2p, "click", L.DomEvent.stop).on(p2p, "click", onPointToPointClick);
|
|
17795
|
+
L$1.DomEvent.on(p2p, "mousedown", L$1.DomEvent.stopPropagation);
|
|
17796
|
+
L$1.DomEvent.on(p2p, "touchstart", L$1.DomEvent.stopPropagation);
|
|
17797
|
+
L$1.DomEvent.on(p2p, "click", L$1.DomEvent.stop).on(p2p, "click", onPointToPointClick);
|
|
17279
17798
|
}
|
|
17280
17799
|
if (config.modes.deleteAll) {
|
|
17281
|
-
const erase =
|
|
17800
|
+
const erase = leafletAdapter.domUtil.create(
|
|
17801
|
+
"a",
|
|
17802
|
+
"icon-erase",
|
|
17803
|
+
subContainer
|
|
17804
|
+
);
|
|
17282
17805
|
erase.href = "#";
|
|
17283
17806
|
erase.title = "Erase All";
|
|
17284
17807
|
erase.innerHTML = `<?xml version="1.0" encoding="utf-8"?>
|
|
@@ -17297,9 +17820,9 @@ function createButtons(container, subContainer, config, onActivateToggle, onDraw
|
|
|
17297
17820
|
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
17821
|
c0.5,0,1,0.4,1,1V34.2z"/>
|
|
17299
17822
|
</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);
|
|
17823
|
+
L$1.DomEvent.on(erase, "mousedown", L$1.DomEvent.stopPropagation);
|
|
17824
|
+
L$1.DomEvent.on(erase, "touchstart", L$1.DomEvent.stopPropagation);
|
|
17825
|
+
L$1.DomEvent.on(erase, "click", L$1.DomEvent.stop).on(erase, "click", onEraseClick);
|
|
17303
17826
|
}
|
|
17304
17827
|
}
|
|
17305
17828
|
class PolygonUtil {
|
|
@@ -17367,13 +17890,13 @@ class PolygonUtil {
|
|
|
17367
17890
|
return bounds.getEast();
|
|
17368
17891
|
}
|
|
17369
17892
|
static getSqmArea(polygon2) {
|
|
17370
|
-
const poly = new L.Polygon(polygon2);
|
|
17893
|
+
const poly = new L$1.Polygon(polygon2);
|
|
17371
17894
|
const geoJsonPoly = poly.toGeoJSON();
|
|
17372
17895
|
const area2 = this.turfHelper.getPolygonArea(geoJsonPoly);
|
|
17373
17896
|
return area2;
|
|
17374
17897
|
}
|
|
17375
17898
|
static getPerimeter(polygon2) {
|
|
17376
|
-
const poly = new L.Polygon(polygon2);
|
|
17899
|
+
const poly = new L$1.Polygon(polygon2);
|
|
17377
17900
|
const geoJsonPoly = poly.toGeoJSON();
|
|
17378
17901
|
const perimeter = this.turfHelper.getPolygonPerimeter(geoJsonPoly);
|
|
17379
17902
|
return perimeter * 1e3;
|
|
@@ -17399,7 +17922,7 @@ class PolygonUtil {
|
|
|
17399
17922
|
if (isNaN(ll.lat) || isNaN(ll.lng)) ;
|
|
17400
17923
|
tmpLatLng.push(ll);
|
|
17401
17924
|
});
|
|
17402
|
-
const polyLine = new L.Polyline(tmpLatLng);
|
|
17925
|
+
const polyLine = new L$1.Polyline(tmpLatLng);
|
|
17403
17926
|
const bounds = polyLine.getBounds();
|
|
17404
17927
|
return bounds;
|
|
17405
17928
|
}
|
|
@@ -17952,15 +18475,15 @@ class PolygonDrawManager {
|
|
|
17952
18475
|
try {
|
|
17953
18476
|
const isFirstMarker = this.p2pMarkers.length === 0;
|
|
17954
18477
|
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:
|
|
18478
|
+
const pointMarker = new L$1.Marker(clickLatLng, {
|
|
18479
|
+
icon: leafletAdapter.createDivIcon({
|
|
17957
18480
|
className: markerClassName,
|
|
17958
18481
|
iconSize: isFirstMarker ? [20, 20] : [16, 16]
|
|
17959
18482
|
}),
|
|
17960
18483
|
draggable: this.config.modes.dragElbow
|
|
17961
18484
|
}).addTo(this.map);
|
|
17962
18485
|
pointMarker.on("mousedown", (e) => {
|
|
17963
|
-
L.DomEvent.stopPropagation(e);
|
|
18486
|
+
L$1.DomEvent.stopPropagation(e);
|
|
17964
18487
|
});
|
|
17965
18488
|
pointMarker.on("drag", () => {
|
|
17966
18489
|
this.updateP2PTracer();
|
|
@@ -17968,7 +18491,7 @@ class PolygonDrawManager {
|
|
|
17968
18491
|
pointMarker.on("click", (e) => {
|
|
17969
18492
|
if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
|
|
17970
18493
|
this.deleteP2PMarker(pointMarker);
|
|
17971
|
-
L.DomEvent.stopPropagation(e);
|
|
18494
|
+
L$1.DomEvent.stopPropagation(e);
|
|
17972
18495
|
}
|
|
17973
18496
|
});
|
|
17974
18497
|
pointMarker.on("mouseover", () => this.onMarkerHoverForEdgeDeletion(pointMarker, true));
|
|
@@ -17997,11 +18520,11 @@ class PolygonDrawManager {
|
|
|
17997
18520
|
pointMarker.on("click", (e) => {
|
|
17998
18521
|
if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
|
|
17999
18522
|
this.deleteP2PMarker(pointMarker);
|
|
18000
|
-
L.DomEvent.stopPropagation(e);
|
|
18523
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18001
18524
|
return;
|
|
18002
18525
|
}
|
|
18003
18526
|
if (this.p2pMarkers.length >= 3) {
|
|
18004
|
-
L.DomEvent.stopPropagation(e);
|
|
18527
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18005
18528
|
this.completePointToPointPolygon();
|
|
18006
18529
|
}
|
|
18007
18530
|
});
|
|
@@ -18022,6 +18545,17 @@ class PolygonDrawManager {
|
|
|
18022
18545
|
this.completePointToPointPolygon();
|
|
18023
18546
|
}
|
|
18024
18547
|
}
|
|
18548
|
+
/**
|
|
18549
|
+
* Handle double-tap to complete point-to-point polygon (touch devices)
|
|
18550
|
+
*/
|
|
18551
|
+
handleDoubleTap(_e) {
|
|
18552
|
+
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint) {
|
|
18553
|
+
return;
|
|
18554
|
+
}
|
|
18555
|
+
if (this.p2pMarkers.length >= 3) {
|
|
18556
|
+
this.completePointToPointPolygon();
|
|
18557
|
+
}
|
|
18558
|
+
}
|
|
18025
18559
|
/**
|
|
18026
18560
|
* Complete point-to-point polygon drawing
|
|
18027
18561
|
*/
|
|
@@ -18090,12 +18624,21 @@ class PolygonDrawManager {
|
|
|
18090
18624
|
if (!firstPoint) return false;
|
|
18091
18625
|
const zoom = this.map.getZoom();
|
|
18092
18626
|
const baseTolerance = 5e-4;
|
|
18093
|
-
|
|
18627
|
+
let tolerance = baseTolerance / Math.pow(2, Math.max(0, zoom - 10));
|
|
18628
|
+
if (this.isTouchDevice()) {
|
|
18629
|
+
tolerance *= 5;
|
|
18630
|
+
}
|
|
18094
18631
|
const latDiff = Math.abs(clickLatLng.lat - firstPoint.lat);
|
|
18095
18632
|
const lngDiff = Math.abs(clickLatLng.lng - firstPoint.lng);
|
|
18096
18633
|
const isClicking = latDiff < tolerance && lngDiff < tolerance;
|
|
18097
18634
|
return isClicking;
|
|
18098
18635
|
}
|
|
18636
|
+
/**
|
|
18637
|
+
* Check if the current device supports touch
|
|
18638
|
+
*/
|
|
18639
|
+
isTouchDevice() {
|
|
18640
|
+
return isTouchDevice();
|
|
18641
|
+
}
|
|
18099
18642
|
/**
|
|
18100
18643
|
* Update the tracer polyline based on P2P markers
|
|
18101
18644
|
*/
|
|
@@ -18162,7 +18705,7 @@ class PolygonDrawManager {
|
|
|
18162
18705
|
if (element) {
|
|
18163
18706
|
element.classList.add("leaflet-polydraw-p2p-first-marker");
|
|
18164
18707
|
firstMarker.setIcon(
|
|
18165
|
-
|
|
18708
|
+
leafletAdapter.createDivIcon({
|
|
18166
18709
|
className: "leaflet-polydraw-p2p-marker leaflet-polydraw-p2p-first-marker",
|
|
18167
18710
|
iconSize: [20, 20]
|
|
18168
18711
|
})
|
|
@@ -18194,11 +18737,11 @@ class PolygonDrawManager {
|
|
|
18194
18737
|
firstMarker.on("click", (e) => {
|
|
18195
18738
|
if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
|
|
18196
18739
|
this.deleteP2PMarker(firstMarker);
|
|
18197
|
-
L.DomEvent.stopPropagation(e);
|
|
18740
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18198
18741
|
return;
|
|
18199
18742
|
}
|
|
18200
18743
|
if (this.p2pMarkers.length >= 3) {
|
|
18201
|
-
L.DomEvent.stopPropagation(e);
|
|
18744
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18202
18745
|
this.completePointToPointPolygon();
|
|
18203
18746
|
}
|
|
18204
18747
|
});
|
|
@@ -18561,7 +19104,7 @@ class IconFactory {
|
|
|
18561
19104
|
*/
|
|
18562
19105
|
static createDivIcon(classNames) {
|
|
18563
19106
|
const classes = classNames.join(" ");
|
|
18564
|
-
return
|
|
19107
|
+
return leafletAdapter.createDivIcon({ className: classes });
|
|
18565
19108
|
}
|
|
18566
19109
|
}
|
|
18567
19110
|
class PolygonInteractionManager {
|
|
@@ -18611,6 +19154,8 @@ class PolygonInteractionManager {
|
|
|
18611
19154
|
dragData.isDragging = false;
|
|
18612
19155
|
this.map.off("mousemove", this.onPolygonMouseMove, this);
|
|
18613
19156
|
this.map.off("mouseup", this.onPolygonMouseUp, this);
|
|
19157
|
+
this.map.off("pointermove", this.onPolygonMouseMove, this);
|
|
19158
|
+
this.map.off("pointerup", this.onPolygonMouseUp, this);
|
|
18614
19159
|
if (this.map.dragging) {
|
|
18615
19160
|
this.map.dragging.enable();
|
|
18616
19161
|
}
|
|
@@ -18694,7 +19239,7 @@ class PolygonInteractionManager {
|
|
|
18694
19239
|
}
|
|
18695
19240
|
const processedClasses = Array.isArray(iconClasses) ? iconClasses : [iconClasses];
|
|
18696
19241
|
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, {
|
|
19242
|
+
const marker = new L$1.Marker(latlng, {
|
|
18698
19243
|
icon: this.createDivIcon(processedClasses),
|
|
18699
19244
|
draggable: this.config.modes.dragElbow,
|
|
18700
19245
|
title: this.config.markers.coordsTitle ? this.getLatLngInfoString(latlng) : "",
|
|
@@ -18710,7 +19255,7 @@ class PolygonInteractionManager {
|
|
|
18710
19255
|
var _a2, _b2;
|
|
18711
19256
|
if (this.isDraggingMarker) {
|
|
18712
19257
|
(_b2 = (_a2 = e.originalEvent) == null ? void 0 : _a2.stopPropagation) == null ? void 0 : _b2.call(_a2);
|
|
18713
|
-
L.DomEvent.stopPropagation(e);
|
|
19258
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18714
19259
|
}
|
|
18715
19260
|
});
|
|
18716
19261
|
marker.on("dragstart", () => {
|
|
@@ -18723,7 +19268,7 @@ class PolygonInteractionManager {
|
|
|
18723
19268
|
this.markerDragEnd(fg);
|
|
18724
19269
|
}
|
|
18725
19270
|
this._activeMarker = null;
|
|
18726
|
-
L.DomEvent.stopPropagation(e);
|
|
19271
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18727
19272
|
setTimeout(() => {
|
|
18728
19273
|
this.isDraggingMarker = false;
|
|
18729
19274
|
}, 10);
|
|
@@ -18836,7 +19381,7 @@ class PolygonInteractionManager {
|
|
|
18836
19381
|
}
|
|
18837
19382
|
marker.on("mousedown", (e) => {
|
|
18838
19383
|
if (!this.modeManager.isInOffMode()) {
|
|
18839
|
-
L.DomEvent.stopPropagation(e);
|
|
19384
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18840
19385
|
this.map.fire("mousedown", e);
|
|
18841
19386
|
}
|
|
18842
19387
|
this._activeMarker = marker;
|
|
@@ -18844,7 +19389,7 @@ class PolygonInteractionManager {
|
|
|
18844
19389
|
marker.on("click", (e) => {
|
|
18845
19390
|
if (this.modeManager.isInOffMode()) {
|
|
18846
19391
|
if (this.isEdgeDeletionModifierKeyPressed(e.originalEvent)) {
|
|
18847
|
-
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
19392
|
+
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
18848
19393
|
if (polygonLayer) {
|
|
18849
19394
|
this.elbowClicked(e, polygonLayer, marker.getLatLng());
|
|
18850
19395
|
}
|
|
@@ -18901,7 +19446,7 @@ class PolygonInteractionManager {
|
|
|
18901
19446
|
}
|
|
18902
19447
|
const processedClasses = Array.isArray(iconClasses) ? iconClasses : [iconClasses];
|
|
18903
19448
|
const isSpecialMarker = i === menuMarkerIdx && holeMenuEnabled || i === deleteMarkerIdx && holeDeleteEnabled || i === infoMarkerIdx && holeInfoEnabled;
|
|
18904
|
-
const marker = new L.Marker(latlng, {
|
|
19449
|
+
const marker = new L$1.Marker(latlng, {
|
|
18905
19450
|
icon: this.createDivIcon(processedClasses),
|
|
18906
19451
|
draggable: this.config.modes.dragElbow,
|
|
18907
19452
|
title: this.config.markers.coordsTitle ? this.getLatLngInfoString(latlng) : "",
|
|
@@ -18917,7 +19462,7 @@ class PolygonInteractionManager {
|
|
|
18917
19462
|
var _a3, _b3;
|
|
18918
19463
|
if (this.isDraggingMarker) {
|
|
18919
19464
|
(_b3 = (_a3 = e.originalEvent) == null ? void 0 : _a3.stopPropagation) == null ? void 0 : _b3.call(_a3);
|
|
18920
|
-
L.DomEvent.stopPropagation(e);
|
|
19465
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18921
19466
|
}
|
|
18922
19467
|
});
|
|
18923
19468
|
marker.on("dragstart", () => {
|
|
@@ -18930,7 +19475,7 @@ class PolygonInteractionManager {
|
|
|
18930
19475
|
this.markerDragEnd(fg);
|
|
18931
19476
|
}
|
|
18932
19477
|
this._activeMarker = null;
|
|
18933
|
-
L.DomEvent.stopPropagation(e);
|
|
19478
|
+
L$1.DomEvent.stopPropagation(e);
|
|
18934
19479
|
setTimeout(() => {
|
|
18935
19480
|
this.isDraggingMarker = false;
|
|
18936
19481
|
}, 10);
|
|
@@ -19035,7 +19580,7 @@ class PolygonInteractionManager {
|
|
|
19035
19580
|
}
|
|
19036
19581
|
marker.on("mousedown", (e) => {
|
|
19037
19582
|
if (!this.modeManager.isInOffMode()) {
|
|
19038
|
-
L.DomEvent.stopPropagation(e);
|
|
19583
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19039
19584
|
this.map.fire("mousedown", e);
|
|
19040
19585
|
}
|
|
19041
19586
|
this._activeMarker = marker;
|
|
@@ -19043,14 +19588,14 @@ class PolygonInteractionManager {
|
|
|
19043
19588
|
marker.on("click", (e) => {
|
|
19044
19589
|
if (this.modeManager.isInOffMode()) {
|
|
19045
19590
|
if (this.isEdgeDeletionModifierKeyPressed(e.originalEvent)) {
|
|
19046
|
-
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
19591
|
+
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
19047
19592
|
if (polygonLayer) {
|
|
19048
19593
|
this.elbowClicked(e, polygonLayer, marker.getLatLng());
|
|
19049
19594
|
}
|
|
19050
19595
|
} else {
|
|
19051
19596
|
if (i === deleteMarkerIdx && holeDeleteEnabled) {
|
|
19052
19597
|
this.map.closePopup();
|
|
19053
|
-
const parentPolygon = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
19598
|
+
const parentPolygon = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
19054
19599
|
if (parentPolygon) {
|
|
19055
19600
|
const rawLatLngs = parentPolygon.getLatLngs();
|
|
19056
19601
|
let rings = [];
|
|
@@ -19138,12 +19683,15 @@ class PolygonInteractionManager {
|
|
|
19138
19683
|
if (edgeStart.lat === edgeEnd.lat && edgeStart.lng === edgeEnd.lng) {
|
|
19139
19684
|
continue;
|
|
19140
19685
|
}
|
|
19141
|
-
const edgePolyline =
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
|
|
19686
|
+
const edgePolyline = leafletAdapter.createPolyline(
|
|
19687
|
+
[edgeStart, edgeEnd],
|
|
19688
|
+
{
|
|
19689
|
+
color: "transparent",
|
|
19690
|
+
weight: 10,
|
|
19691
|
+
opacity: 0,
|
|
19692
|
+
interactive: true
|
|
19693
|
+
}
|
|
19694
|
+
);
|
|
19147
19695
|
edgePolyline._polydrawEdgeInfo = {
|
|
19148
19696
|
ringIndex,
|
|
19149
19697
|
edgeIndex: i,
|
|
@@ -19179,15 +19727,15 @@ class PolygonInteractionManager {
|
|
|
19179
19727
|
};
|
|
19180
19728
|
polygon2.on("mousedown", (e) => {
|
|
19181
19729
|
if (!this.modeManager.isInOffMode()) {
|
|
19182
|
-
L.DomEvent.stopPropagation(e);
|
|
19730
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19183
19731
|
this.map.fire("mousedown", e);
|
|
19184
19732
|
return;
|
|
19185
19733
|
}
|
|
19186
19734
|
if (!this.modeManager.canPerformAction("polygonDrag")) {
|
|
19187
19735
|
return;
|
|
19188
19736
|
}
|
|
19189
|
-
L.DomEvent.stopPropagation(e.originalEvent);
|
|
19190
|
-
L.DomEvent.preventDefault(e.originalEvent);
|
|
19737
|
+
L$1.DomEvent.stopPropagation(e.originalEvent);
|
|
19738
|
+
L$1.DomEvent.preventDefault(e.originalEvent);
|
|
19191
19739
|
const isModifierPressed = this.detectDragSubtractModifierKey(e.originalEvent);
|
|
19192
19740
|
this.currentModifierDragMode = isModifierPressed;
|
|
19193
19741
|
this.isModifierKeyHeld = isModifierPressed;
|
|
@@ -19207,6 +19755,43 @@ class PolygonInteractionManager {
|
|
|
19207
19755
|
}
|
|
19208
19756
|
this.map.on("mousemove", this.onPolygonMouseMove, this);
|
|
19209
19757
|
this.map.on("mouseup", this.onPolygonMouseUp, this);
|
|
19758
|
+
this.map.on("pointermove", this.onPolygonMouseMove, this);
|
|
19759
|
+
this.map.on("pointerup", this.onPolygonMouseUp, this);
|
|
19760
|
+
this.currentDragPolygon = polygon2;
|
|
19761
|
+
});
|
|
19762
|
+
polygon2.on("pointerdown", (e) => {
|
|
19763
|
+
if (!this.modeManager.isInOffMode()) {
|
|
19764
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19765
|
+
this.map.fire("pointerdown", e);
|
|
19766
|
+
return;
|
|
19767
|
+
}
|
|
19768
|
+
if (!this.modeManager.canPerformAction("polygonDrag")) {
|
|
19769
|
+
return;
|
|
19770
|
+
}
|
|
19771
|
+
const orig = e && e.originalEvent ? e.originalEvent : e;
|
|
19772
|
+
L$1.DomEvent.stopPropagation(orig);
|
|
19773
|
+
L$1.DomEvent.preventDefault(orig);
|
|
19774
|
+
const isModifierPressed = this.detectDragSubtractModifierKey(orig);
|
|
19775
|
+
this.currentModifierDragMode = isModifierPressed;
|
|
19776
|
+
this.isModifierKeyHeld = isModifierPressed;
|
|
19777
|
+
polygon2._polydrawDragData.isDragging = true;
|
|
19778
|
+
polygon2._polydrawDragData.startPosition = e.latlng;
|
|
19779
|
+
polygon2._polydrawDragData.startLatLngs = polygon2.getLatLngs();
|
|
19780
|
+
polygon2.setStyle({ fillOpacity: this.config.dragPolygons.opacity });
|
|
19781
|
+
if (this.map.dragging) {
|
|
19782
|
+
this.map.dragging.disable();
|
|
19783
|
+
}
|
|
19784
|
+
this.setSubtractVisualMode(polygon2, isModifierPressed);
|
|
19785
|
+
this.setMarkerVisibility(polygon2, false);
|
|
19786
|
+
try {
|
|
19787
|
+
const container = this.map.getContainer();
|
|
19788
|
+
container.style.cursor = this.config.dragPolygons.dragCursor || "move";
|
|
19789
|
+
} catch (error) {
|
|
19790
|
+
}
|
|
19791
|
+
this.map.on("mousemove", this.onPolygonMouseMove, this);
|
|
19792
|
+
this.map.on("mouseup", this.onPolygonMouseUp, this);
|
|
19793
|
+
this.map.on("pointermove", this.onPolygonMouseMove, this);
|
|
19794
|
+
this.map.on("pointerup", this.onPolygonMouseUp, this);
|
|
19210
19795
|
this.currentDragPolygon = polygon2;
|
|
19211
19796
|
});
|
|
19212
19797
|
polygon2.on("mouseover", () => {
|
|
@@ -19235,7 +19820,7 @@ class PolygonInteractionManager {
|
|
|
19235
19820
|
const shouldBeDraggable = this.modeManager.canPerformAction("markerDrag");
|
|
19236
19821
|
this.getFeatureGroups().forEach((featureGroup) => {
|
|
19237
19822
|
featureGroup.eachLayer((layer) => {
|
|
19238
|
-
if (layer instanceof L.Marker) {
|
|
19823
|
+
if (layer instanceof L$1.Marker) {
|
|
19239
19824
|
const marker = layer;
|
|
19240
19825
|
try {
|
|
19241
19826
|
marker.options.draggable = shouldBeDraggable;
|
|
@@ -19258,7 +19843,7 @@ class PolygonInteractionManager {
|
|
|
19258
19843
|
updateAllMarkersForEdgeDeletion(showFeedback) {
|
|
19259
19844
|
this.getFeatureGroups().forEach((featureGroup) => {
|
|
19260
19845
|
featureGroup.eachLayer((layer) => {
|
|
19261
|
-
if (layer instanceof L.Marker) {
|
|
19846
|
+
if (layer instanceof L$1.Marker) {
|
|
19262
19847
|
this.updateMarkerForEdgeDeletion(layer, showFeedback);
|
|
19263
19848
|
}
|
|
19264
19849
|
});
|
|
@@ -19325,7 +19910,7 @@ class PolygonInteractionManager {
|
|
|
19325
19910
|
} catch (error) {
|
|
19326
19911
|
}
|
|
19327
19912
|
}
|
|
19328
|
-
L.DomEvent.stopPropagation(e);
|
|
19913
|
+
L$1.DomEvent.stopPropagation(e);
|
|
19329
19914
|
}
|
|
19330
19915
|
highlightEdgeOnHover(edgePolyline, isHovering) {
|
|
19331
19916
|
if (isHovering) {
|
|
@@ -19431,7 +20016,7 @@ class PolygonInteractionManager {
|
|
|
19431
20016
|
let testarray = [];
|
|
19432
20017
|
let hole = [];
|
|
19433
20018
|
const layers = featureGroup.getLayers();
|
|
19434
|
-
const polygonLayer = layers.find((l) => l instanceof L.Polygon);
|
|
20019
|
+
const polygonLayer = layers.find((l) => l instanceof L$1.Polygon);
|
|
19435
20020
|
if (!polygonLayer) {
|
|
19436
20021
|
if (!isTestEnvironment()) {
|
|
19437
20022
|
console.warn("No polygon found in feature group for marker drag.");
|
|
@@ -19440,7 +20025,7 @@ class PolygonInteractionManager {
|
|
|
19440
20025
|
}
|
|
19441
20026
|
const posarrays = polygonLayer.getLatLngs();
|
|
19442
20027
|
let length2 = 0;
|
|
19443
|
-
const markers2 = layers.filter((layer) => layer instanceof L.Marker);
|
|
20028
|
+
const markers2 = layers.filter((layer) => layer instanceof L$1.Marker);
|
|
19444
20029
|
if (posarrays.length > 1) {
|
|
19445
20030
|
for (let index = 0; index < posarrays.length; index++) {
|
|
19446
20031
|
testarray = [];
|
|
@@ -19573,7 +20158,9 @@ class PolygonInteractionManager {
|
|
|
19573
20158
|
(ring) => this.offsetPolygonCoordinates(ring, offsetLat, offsetLng)
|
|
19574
20159
|
);
|
|
19575
20160
|
}
|
|
19576
|
-
return latLngs.map(
|
|
20161
|
+
return latLngs.map(
|
|
20162
|
+
(p) => leafletAdapter.createLatLng(p.lat + offsetLat, p.lng + offsetLng)
|
|
20163
|
+
);
|
|
19577
20164
|
}
|
|
19578
20165
|
updateMarkersAndHoleLinesDuringDrag(polygon2, offsetLat, offsetLng) {
|
|
19579
20166
|
try {
|
|
@@ -19593,22 +20180,22 @@ class PolygonInteractionManager {
|
|
|
19593
20180
|
if (!featureGroup) {
|
|
19594
20181
|
return;
|
|
19595
20182
|
}
|
|
19596
|
-
const dragSessionKey = "_polydrawDragSession_" + Date.now() + "_" +
|
|
20183
|
+
const dragSessionKey = "_polydrawDragSession_" + Date.now() + "_" + leafletAdapter.util.stamp(polygon2);
|
|
19597
20184
|
if (!polygon2._polydrawCurrentDragSession) {
|
|
19598
20185
|
polygon2._polydrawCurrentDragSession = dragSessionKey;
|
|
19599
20186
|
polygon2._polydrawOriginalMarkerPositions = /* @__PURE__ */ new Map();
|
|
19600
20187
|
polygon2._polydrawOriginalHoleLinePositions = /* @__PURE__ */ new Map();
|
|
19601
20188
|
featureGroup.eachLayer((layer) => {
|
|
19602
|
-
if (layer instanceof L.Marker) {
|
|
20189
|
+
if (layer instanceof L$1.Marker) {
|
|
19603
20190
|
polygon2._polydrawOriginalMarkerPositions.set(layer, layer.getLatLng());
|
|
19604
|
-
} else if (layer instanceof L.Polyline && !(layer instanceof L.Polygon)) {
|
|
20191
|
+
} else if (layer instanceof L$1.Polyline && !(layer instanceof L$1.Polygon)) {
|
|
19605
20192
|
const latLngs = layer.getLatLngs();
|
|
19606
20193
|
polygon2._polydrawOriginalHoleLinePositions.set(layer, latLngs);
|
|
19607
20194
|
}
|
|
19608
20195
|
});
|
|
19609
20196
|
}
|
|
19610
20197
|
featureGroup.eachLayer((layer) => {
|
|
19611
|
-
if (layer instanceof L.Marker) {
|
|
20198
|
+
if (layer instanceof L$1.Marker) {
|
|
19612
20199
|
const originalPos = polygon2._polydrawOriginalMarkerPositions.get(layer);
|
|
19613
20200
|
if (originalPos) {
|
|
19614
20201
|
const newLatLng = {
|
|
@@ -19617,17 +20204,19 @@ class PolygonInteractionManager {
|
|
|
19617
20204
|
};
|
|
19618
20205
|
layer.setLatLng(newLatLng);
|
|
19619
20206
|
}
|
|
19620
|
-
} else if (layer instanceof L.Polyline && !(layer instanceof L.Polygon)) {
|
|
20207
|
+
} else if (layer instanceof L$1.Polyline && !(layer instanceof L$1.Polygon)) {
|
|
19621
20208
|
const originalPositions = polygon2._polydrawOriginalHoleLinePositions.get(layer);
|
|
19622
20209
|
if (originalPositions) {
|
|
19623
20210
|
let newLatLngs;
|
|
19624
20211
|
if (Array.isArray(originalPositions[0])) {
|
|
19625
20212
|
newLatLngs = originalPositions.map(
|
|
19626
|
-
(ring) => ring.map(
|
|
20213
|
+
(ring) => ring.map(
|
|
20214
|
+
(latlng) => leafletAdapter.createLatLng(latlng.lat + offsetLat, latlng.lng + offsetLng)
|
|
20215
|
+
)
|
|
19627
20216
|
);
|
|
19628
20217
|
} else {
|
|
19629
20218
|
newLatLngs = originalPositions.map(
|
|
19630
|
-
(latlng) =>
|
|
20219
|
+
(latlng) => leafletAdapter.createLatLng(latlng.lat + offsetLat, latlng.lng + offsetLng)
|
|
19631
20220
|
);
|
|
19632
20221
|
}
|
|
19633
20222
|
layer.setLatLngs(newLatLngs);
|
|
@@ -19720,7 +20309,7 @@ class PolygonInteractionManager {
|
|
|
19720
20309
|
const fg = featureGroup;
|
|
19721
20310
|
const hideMarkersOnDrag = this.config.dragPolygons.modifierSubtract.hideMarkersOnDrag;
|
|
19722
20311
|
fg.eachLayer((layer) => {
|
|
19723
|
-
if (layer instanceof L.Marker) {
|
|
20312
|
+
if (layer instanceof L$1.Marker) {
|
|
19724
20313
|
const marker = layer;
|
|
19725
20314
|
const element = marker.getElement();
|
|
19726
20315
|
if (element) {
|
|
@@ -20006,7 +20595,7 @@ class PolygonInteractionManager {
|
|
|
20006
20595
|
const featureGroup = this.getFeatureGroups().find((fg) => fg.hasLayer(polygon2));
|
|
20007
20596
|
if (!featureGroup) return;
|
|
20008
20597
|
featureGroup.eachLayer((layer) => {
|
|
20009
|
-
if (layer instanceof L.Marker) {
|
|
20598
|
+
if (layer instanceof L$1.Marker) {
|
|
20010
20599
|
const marker = layer;
|
|
20011
20600
|
const element = marker.getElement();
|
|
20012
20601
|
if (element) {
|
|
@@ -20137,14 +20726,14 @@ class PolygonInteractionManager {
|
|
|
20137
20726
|
});
|
|
20138
20727
|
closePopupIfOpen();
|
|
20139
20728
|
};
|
|
20140
|
-
L.DomEvent.disableClickPropagation(outerWrapper);
|
|
20729
|
+
L$1.DomEvent.disableClickPropagation(outerWrapper);
|
|
20141
20730
|
outerWrapper.style.pointerEvents = "auto";
|
|
20142
20731
|
outerWrapper.querySelectorAll(".marker-menu-button").forEach((btn) => {
|
|
20143
20732
|
btn.style.pointerEvents = "auto";
|
|
20144
20733
|
btn.addEventListener("click", (e) => e.stopPropagation());
|
|
20145
20734
|
});
|
|
20146
20735
|
const isMobile = window.innerWidth <= 600;
|
|
20147
|
-
const popup =
|
|
20736
|
+
const popup = leafletAdapter.createPopup({
|
|
20148
20737
|
closeButton: true,
|
|
20149
20738
|
autoClose: true,
|
|
20150
20739
|
className: `menu-popup${isMobile ? " mobile-popup" : ""}`
|
|
@@ -20154,7 +20743,7 @@ class PolygonInteractionManager {
|
|
|
20154
20743
|
}
|
|
20155
20744
|
getPolygonGeoJSONFromFeatureGroup(featureGroup) {
|
|
20156
20745
|
try {
|
|
20157
|
-
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon);
|
|
20746
|
+
const polygonLayer = featureGroup.getLayers().find((layer) => layer instanceof L$1.Polygon);
|
|
20158
20747
|
if (!polygonLayer) {
|
|
20159
20748
|
throw new Error("No polygon found in feature group");
|
|
20160
20749
|
}
|
|
@@ -20256,14 +20845,14 @@ class PolygonInteractionManager {
|
|
|
20256
20845
|
markerContent.appendChild(infoContentWrapper);
|
|
20257
20846
|
outerWrapper.appendChild(wrapper);
|
|
20258
20847
|
wrapper.appendChild(markerContent);
|
|
20259
|
-
L.DomEvent.disableClickPropagation(outerWrapper);
|
|
20848
|
+
L$1.DomEvent.disableClickPropagation(outerWrapper);
|
|
20260
20849
|
outerWrapper.style.pointerEvents = "auto";
|
|
20261
20850
|
outerWrapper.querySelectorAll("button").forEach((btn) => {
|
|
20262
20851
|
btn.style.pointerEvents = "auto";
|
|
20263
20852
|
btn.addEventListener("click", (e) => e.stopPropagation());
|
|
20264
20853
|
});
|
|
20265
20854
|
const isMobile = window.innerWidth <= 600;
|
|
20266
|
-
const popup =
|
|
20855
|
+
const popup = leafletAdapter.createPopup({
|
|
20267
20856
|
closeButton: true,
|
|
20268
20857
|
autoClose: true,
|
|
20269
20858
|
className: `info-popup${isMobile ? " mobile-popup" : ""}`
|
|
@@ -20502,7 +21091,7 @@ class PolygonMutationManager {
|
|
|
20502
21091
|
if (!latlngs || !latlngs.geometry || !latlngs.geometry.coordinates) {
|
|
20503
21092
|
return { success: false, error: "Invalid polygon data" };
|
|
20504
21093
|
}
|
|
20505
|
-
const featureGroup = new L.FeatureGroup();
|
|
21094
|
+
const featureGroup = new L$1.FeatureGroup();
|
|
20506
21095
|
const latLngs = simplify3 ? this.turfHelper.getSimplified(latlngs, dynamicTolerance) : latlngs;
|
|
20507
21096
|
let polygon2;
|
|
20508
21097
|
try {
|
|
@@ -20542,7 +21131,7 @@ class PolygonMutationManager {
|
|
|
20542
21131
|
if (ringIndex === 0) {
|
|
20543
21132
|
this.interactionManager.addMarkers(latLngLiterals, featureGroup);
|
|
20544
21133
|
} else {
|
|
20545
|
-
const holePolyline =
|
|
21134
|
+
const holePolyline = leafletAdapter.createPolyline(latLngLiterals, {
|
|
20546
21135
|
color: this.config.colors.hole.border,
|
|
20547
21136
|
weight: this.config.holeOptions.weight || 2,
|
|
20548
21137
|
opacity: this.config.holeOptions.opacity || 1,
|
|
@@ -20812,7 +21401,7 @@ class PolygonMutationManager {
|
|
|
20812
21401
|
* Create a polygon from GeoJSON feature
|
|
20813
21402
|
*/
|
|
20814
21403
|
getPolygon(latlngs) {
|
|
20815
|
-
const polygon2 = L.GeoJSON.geometryToLayer(latlngs);
|
|
21404
|
+
const polygon2 = L$1.GeoJSON.geometryToLayer(latlngs);
|
|
20816
21405
|
const polygonStyle = {
|
|
20817
21406
|
...this.config.polygonOptions,
|
|
20818
21407
|
color: this.config.colors.polygon.border,
|
|
@@ -20823,7 +21412,7 @@ class PolygonMutationManager {
|
|
|
20823
21412
|
fillOpacity: this.config.polygonOptions.fillOpacity || 0.2
|
|
20824
21413
|
};
|
|
20825
21414
|
polygon2.setStyle(polygonStyle);
|
|
20826
|
-
polygon2._polydrawUniqueId =
|
|
21415
|
+
polygon2._polydrawUniqueId = leafletAdapter.util.stamp(polygon2) + "_" + Date.now();
|
|
20827
21416
|
delete polygon2._polydrawDragData;
|
|
20828
21417
|
delete polygon2._polydrawOriginalLatLngs;
|
|
20829
21418
|
delete polygon2._polydrawCurrentDragSession;
|
|
@@ -20859,7 +21448,7 @@ class PolygonMutationManager {
|
|
|
20859
21448
|
try {
|
|
20860
21449
|
let polygon2 = null;
|
|
20861
21450
|
featureGroup.eachLayer((layer) => {
|
|
20862
|
-
if (layer instanceof L.Polygon) {
|
|
21451
|
+
if (layer instanceof L$1.Polygon) {
|
|
20863
21452
|
polygon2 = layer;
|
|
20864
21453
|
}
|
|
20865
21454
|
});
|
|
@@ -21033,7 +21622,7 @@ class PolygonMutationManager {
|
|
|
21033
21622
|
return (originalIndex + 1) % polygonLength;
|
|
21034
21623
|
}
|
|
21035
21624
|
createDivIcon(processedClasses) {
|
|
21036
|
-
return
|
|
21625
|
+
return leafletAdapter.createDivIcon({ className: processedClasses.join(" ") });
|
|
21037
21626
|
}
|
|
21038
21627
|
getLatLngInfoString(latlng) {
|
|
21039
21628
|
return "Latitude: " + latlng.lat + " Longitude: " + latlng.lng;
|
|
@@ -21149,7 +21738,402 @@ function injectDynamicStyles(config) {
|
|
|
21149
21738
|
`;
|
|
21150
21739
|
document.head.appendChild(style);
|
|
21151
21740
|
}
|
|
21152
|
-
class
|
|
21741
|
+
class EventAdapter {
|
|
21742
|
+
/**
|
|
21743
|
+
* Normalizes events to handle differences between v1 and v2
|
|
21744
|
+
* @param event - The event to normalize
|
|
21745
|
+
* @returns The normalized event
|
|
21746
|
+
*/
|
|
21747
|
+
static normalizeEvent(event) {
|
|
21748
|
+
const version = LeafletVersionDetector.getVersion();
|
|
21749
|
+
if (version === LeafletVersion.V2) {
|
|
21750
|
+
if (event.layer && !event.propagatedFrom) {
|
|
21751
|
+
event.propagatedFrom = event.layer;
|
|
21752
|
+
}
|
|
21753
|
+
if (event.type === "mousedown" || event.type === "touchstart") {
|
|
21754
|
+
event._isPointerEvent = true;
|
|
21755
|
+
}
|
|
21756
|
+
}
|
|
21757
|
+
return event;
|
|
21758
|
+
}
|
|
21759
|
+
/**
|
|
21760
|
+
* Gets the appropriate event name for the current Leaflet version
|
|
21761
|
+
* @param eventName - The base event name
|
|
21762
|
+
* @returns The version-appropriate event name
|
|
21763
|
+
*/
|
|
21764
|
+
static getEventName(eventName) {
|
|
21765
|
+
const version = LeafletVersionDetector.getVersion();
|
|
21766
|
+
if (version === LeafletVersion.V2) {
|
|
21767
|
+
switch (eventName) {
|
|
21768
|
+
case "mousedown":
|
|
21769
|
+
return "pointerdown";
|
|
21770
|
+
case "mouseup":
|
|
21771
|
+
return "pointerup";
|
|
21772
|
+
case "mousemove":
|
|
21773
|
+
return "pointermove";
|
|
21774
|
+
case "touchstart":
|
|
21775
|
+
return "pointerdown";
|
|
21776
|
+
case "touchend":
|
|
21777
|
+
return "pointerup";
|
|
21778
|
+
case "touchmove":
|
|
21779
|
+
return "pointermove";
|
|
21780
|
+
default:
|
|
21781
|
+
return eventName;
|
|
21782
|
+
}
|
|
21783
|
+
}
|
|
21784
|
+
return eventName;
|
|
21785
|
+
}
|
|
21786
|
+
/**
|
|
21787
|
+
* Checks if pointer events are supported/preferred
|
|
21788
|
+
* @returns true if pointer events should be used
|
|
21789
|
+
*/
|
|
21790
|
+
static shouldUsePointerEvents() {
|
|
21791
|
+
const version = LeafletVersionDetector.getVersion();
|
|
21792
|
+
return version === LeafletVersion.V2 && "PointerEvent" in window;
|
|
21793
|
+
}
|
|
21794
|
+
/**
|
|
21795
|
+
* Extracts coordinates from various event types (mouse, touch, pointer)
|
|
21796
|
+
* @param event - The event to extract coordinates from
|
|
21797
|
+
* @param map - The map instance for coordinate conversion
|
|
21798
|
+
* @returns The LatLng coordinates or null if not available
|
|
21799
|
+
*/
|
|
21800
|
+
static extractCoordinates(event, map) {
|
|
21801
|
+
if (event.latlng) {
|
|
21802
|
+
return event.latlng;
|
|
21803
|
+
}
|
|
21804
|
+
if (event.touches && event.touches.length > 0) {
|
|
21805
|
+
const rect = map.getContainer().getBoundingClientRect();
|
|
21806
|
+
return map.containerPointToLatLng([
|
|
21807
|
+
event.touches[0].clientX - rect.x,
|
|
21808
|
+
event.touches[0].clientY - rect.y
|
|
21809
|
+
]);
|
|
21810
|
+
}
|
|
21811
|
+
if (event.pointerType && event.clientX !== void 0) {
|
|
21812
|
+
const rect = map.getContainer().getBoundingClientRect();
|
|
21813
|
+
return map.containerPointToLatLng([event.clientX - rect.x, event.clientY - rect.y]);
|
|
21814
|
+
}
|
|
21815
|
+
if (event.clientX !== void 0) {
|
|
21816
|
+
const rect = map.getContainer().getBoundingClientRect();
|
|
21817
|
+
return map.containerPointToLatLng([event.clientX - rect.x, event.clientY - rect.y]);
|
|
21818
|
+
}
|
|
21819
|
+
return null;
|
|
21820
|
+
}
|
|
21821
|
+
/**
|
|
21822
|
+
* Checks if an event should be prevented from default behavior
|
|
21823
|
+
* @param event - The event to check
|
|
21824
|
+
* @returns true if preventDefault should be called
|
|
21825
|
+
*/
|
|
21826
|
+
static shouldPreventDefault(event) {
|
|
21827
|
+
if (event.type && event.type.startsWith("touch")) {
|
|
21828
|
+
return true;
|
|
21829
|
+
}
|
|
21830
|
+
if (event.pointerType && event.isPrimary === false) {
|
|
21831
|
+
return false;
|
|
21832
|
+
}
|
|
21833
|
+
if ("cancelable" in event && event.cancelable) {
|
|
21834
|
+
return true;
|
|
21835
|
+
}
|
|
21836
|
+
return false;
|
|
21837
|
+
}
|
|
21838
|
+
/**
|
|
21839
|
+
* Gets the appropriate event listener names for the current version
|
|
21840
|
+
* @returns Object with event names for different actions
|
|
21841
|
+
*/
|
|
21842
|
+
static getEventNames() {
|
|
21843
|
+
const version = LeafletVersionDetector.getVersion();
|
|
21844
|
+
if (version === LeafletVersion.V2 && this.shouldUsePointerEvents()) {
|
|
21845
|
+
return {
|
|
21846
|
+
start: ["pointerdown"],
|
|
21847
|
+
move: ["pointermove"],
|
|
21848
|
+
end: ["pointerup"]
|
|
21849
|
+
};
|
|
21850
|
+
} else {
|
|
21851
|
+
return {
|
|
21852
|
+
start: ["mousedown", "touchstart"],
|
|
21853
|
+
move: ["mousemove", "touchmove"],
|
|
21854
|
+
end: ["mouseup", "touchend"]
|
|
21855
|
+
};
|
|
21856
|
+
}
|
|
21857
|
+
}
|
|
21858
|
+
}
|
|
21859
|
+
class GeometryUtils {
|
|
21860
|
+
/**
|
|
21861
|
+
* Calculate angle between three points
|
|
21862
|
+
*/
|
|
21863
|
+
static calculateAngle(p1, p2, p3) {
|
|
21864
|
+
const v1 = { x: p1.lng - p2.lng, y: p1.lat - p2.lat };
|
|
21865
|
+
const v2 = { x: p3.lng - p2.lng, y: p3.lat - p2.lat };
|
|
21866
|
+
const dot = v1.x * v2.x + v1.y * v2.y;
|
|
21867
|
+
const mag1 = Math.sqrt(v1.x * v1.x + v1.y * v1.y);
|
|
21868
|
+
const mag2 = Math.sqrt(v2.x * v2.x + v2.y * v2.y);
|
|
21869
|
+
if (mag1 === 0 || mag2 === 0) return 0;
|
|
21870
|
+
const cosAngle = dot / (mag1 * mag2);
|
|
21871
|
+
return Math.acos(Math.max(-1, Math.min(1, cosAngle)));
|
|
21872
|
+
}
|
|
21873
|
+
/**
|
|
21874
|
+
* Calculate distance from point to line between two other points
|
|
21875
|
+
*/
|
|
21876
|
+
static calculateDistanceFromLine(p1, point2, p2) {
|
|
21877
|
+
const A = point2.lng - p1.lng;
|
|
21878
|
+
const B2 = point2.lat - p1.lat;
|
|
21879
|
+
const C = p2.lng - p1.lng;
|
|
21880
|
+
const D2 = p2.lat - p1.lat;
|
|
21881
|
+
const dot = A * C + B2 * D2;
|
|
21882
|
+
const lenSq = C * C + D2 * D2;
|
|
21883
|
+
if (lenSq === 0) return Math.sqrt(A * A + B2 * B2);
|
|
21884
|
+
const param = dot / lenSq;
|
|
21885
|
+
let xx, yy;
|
|
21886
|
+
if (param < 0) {
|
|
21887
|
+
xx = p1.lng;
|
|
21888
|
+
yy = p1.lat;
|
|
21889
|
+
} else if (param > 1) {
|
|
21890
|
+
xx = p2.lng;
|
|
21891
|
+
yy = p2.lat;
|
|
21892
|
+
} else {
|
|
21893
|
+
xx = p1.lng + param * C;
|
|
21894
|
+
yy = p1.lat + param * D2;
|
|
21895
|
+
}
|
|
21896
|
+
const dx = point2.lng - xx;
|
|
21897
|
+
const dy = point2.lat - yy;
|
|
21898
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
21899
|
+
}
|
|
21900
|
+
/**
|
|
21901
|
+
* Calculate centroid of polygon
|
|
21902
|
+
* @deprecated Use PolygonUtil.getCenter() instead for consistency
|
|
21903
|
+
*/
|
|
21904
|
+
static calculateCentroid(latlngs) {
|
|
21905
|
+
return PolygonUtil.getCenter(latlngs);
|
|
21906
|
+
}
|
|
21907
|
+
/**
|
|
21908
|
+
* Calculate distance between two points
|
|
21909
|
+
*/
|
|
21910
|
+
static calculateDistance(p1, p2) {
|
|
21911
|
+
const dx = p1.lng - p2.lng;
|
|
21912
|
+
const dy = p1.lat - p2.lat;
|
|
21913
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
21914
|
+
}
|
|
21915
|
+
/**
|
|
21916
|
+
* Apply offset to polygon coordinates
|
|
21917
|
+
* Note: Uses 'any' type for recursive coordinate structures that can be:
|
|
21918
|
+
* - L.LatLngLiteral (single coordinate)
|
|
21919
|
+
* - L.LatLngLiteral[] (array of coordinates)
|
|
21920
|
+
* - L.LatLngLiteral[][] (polygon with holes)
|
|
21921
|
+
* - L.LatLngLiteral[][][] (multipolygon)
|
|
21922
|
+
* This is a legitimate use of 'any' for dynamic recursive data structures.
|
|
21923
|
+
*/
|
|
21924
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21925
|
+
static offsetPolygonCoordinates(latLngs, offsetLat, offsetLng) {
|
|
21926
|
+
if (!latLngs) return latLngs;
|
|
21927
|
+
if (Array.isArray(latLngs[0])) {
|
|
21928
|
+
return latLngs.map(
|
|
21929
|
+
(ring) => GeometryUtils.offsetPolygonCoordinates(ring, offsetLat, offsetLng)
|
|
21930
|
+
);
|
|
21931
|
+
} else if (latLngs.lat !== void 0 && latLngs.lng !== void 0) {
|
|
21932
|
+
return {
|
|
21933
|
+
lat: latLngs.lat + offsetLat,
|
|
21934
|
+
lng: latLngs.lng + offsetLng
|
|
21935
|
+
};
|
|
21936
|
+
} else {
|
|
21937
|
+
return latLngs.map(
|
|
21938
|
+
(coord) => GeometryUtils.offsetPolygonCoordinates(coord, offsetLat, offsetLng)
|
|
21939
|
+
);
|
|
21940
|
+
}
|
|
21941
|
+
}
|
|
21942
|
+
}
|
|
21943
|
+
class CoordinateUtils {
|
|
21944
|
+
/**
|
|
21945
|
+
* Convert coordinate arrays to proper format for polygon creation
|
|
21946
|
+
*/
|
|
21947
|
+
static convertToCoords(latlngs, turfHelper) {
|
|
21948
|
+
const coords = [];
|
|
21949
|
+
if (latlngs.length > 1 && latlngs.length < 3) {
|
|
21950
|
+
const coordinates = [];
|
|
21951
|
+
const within = turfHelper.isWithin(
|
|
21952
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[latlngs.length - 1]),
|
|
21953
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[0])
|
|
21954
|
+
);
|
|
21955
|
+
if (within) {
|
|
21956
|
+
latlngs.forEach((polygon2) => {
|
|
21957
|
+
coordinates.push(L$1.GeoJSON.latLngsToCoords(polygon2));
|
|
21958
|
+
});
|
|
21959
|
+
} else {
|
|
21960
|
+
latlngs.forEach((polygon2) => {
|
|
21961
|
+
coords.push([L$1.GeoJSON.latLngsToCoords(polygon2)]);
|
|
21962
|
+
});
|
|
21963
|
+
}
|
|
21964
|
+
if (coordinates.length >= 1) {
|
|
21965
|
+
coords.push(coordinates);
|
|
21966
|
+
}
|
|
21967
|
+
} else if (latlngs.length > 2) {
|
|
21968
|
+
const coordinates = [];
|
|
21969
|
+
for (let index = 1; index < latlngs.length - 1; index++) {
|
|
21970
|
+
const within = turfHelper.isWithin(
|
|
21971
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[index]),
|
|
21972
|
+
L$1.GeoJSON.latLngsToCoords(latlngs[0])
|
|
21973
|
+
);
|
|
21974
|
+
if (within) {
|
|
21975
|
+
latlngs.forEach((polygon2) => {
|
|
21976
|
+
coordinates.push(L$1.GeoJSON.latLngsToCoords(polygon2));
|
|
21977
|
+
});
|
|
21978
|
+
coords.push(coordinates);
|
|
21979
|
+
} else {
|
|
21980
|
+
latlngs.forEach((polygon2) => {
|
|
21981
|
+
coords.push([L$1.GeoJSON.latLngsToCoords(polygon2)]);
|
|
21982
|
+
});
|
|
21983
|
+
}
|
|
21984
|
+
}
|
|
21985
|
+
} else {
|
|
21986
|
+
coords.push([L$1.GeoJSON.latLngsToCoords(latlngs[0])]);
|
|
21987
|
+
}
|
|
21988
|
+
return coords;
|
|
21989
|
+
}
|
|
21990
|
+
/**
|
|
21991
|
+
* Apply offset to polygon coordinates
|
|
21992
|
+
*/
|
|
21993
|
+
static offsetPolygonCoordinates(latLngs, offsetLat, offsetLng) {
|
|
21994
|
+
return GeometryUtils.offsetPolygonCoordinates(latLngs, offsetLat, offsetLng);
|
|
21995
|
+
}
|
|
21996
|
+
/**
|
|
21997
|
+
* Get latitude/longitude information string
|
|
21998
|
+
*/
|
|
21999
|
+
static getLatLngInfoString(latlng) {
|
|
22000
|
+
return "Latitude: " + latlng.lat + " Longitude: " + latlng.lng;
|
|
22001
|
+
}
|
|
22002
|
+
/**
|
|
22003
|
+
* Convert any coordinate format to L.LatLng
|
|
22004
|
+
* Supports multiple input formats with smart auto-detection
|
|
22005
|
+
*/
|
|
22006
|
+
static convertToLatLng(coordinate) {
|
|
22007
|
+
if (typeof coordinate === "object" && coordinate !== null) {
|
|
22008
|
+
if ("lat" in coordinate && "lng" in coordinate) {
|
|
22009
|
+
return leafletAdapter.createLatLng(
|
|
22010
|
+
coordinate.lat,
|
|
22011
|
+
coordinate.lng
|
|
22012
|
+
);
|
|
22013
|
+
}
|
|
22014
|
+
if ("latitude" in coordinate && "longitude" in coordinate) {
|
|
22015
|
+
return leafletAdapter.createLatLng(
|
|
22016
|
+
coordinate.latitude,
|
|
22017
|
+
coordinate.longitude
|
|
22018
|
+
);
|
|
22019
|
+
}
|
|
22020
|
+
if ("longitude" in coordinate && "latitude" in coordinate) {
|
|
22021
|
+
return leafletAdapter.createLatLng(
|
|
22022
|
+
coordinate.latitude,
|
|
22023
|
+
coordinate.longitude
|
|
22024
|
+
);
|
|
22025
|
+
}
|
|
22026
|
+
if ("lng" in coordinate && "lat" in coordinate) {
|
|
22027
|
+
return leafletAdapter.createLatLng(
|
|
22028
|
+
coordinate.lat,
|
|
22029
|
+
coordinate.lng
|
|
22030
|
+
);
|
|
22031
|
+
}
|
|
22032
|
+
}
|
|
22033
|
+
if (Array.isArray(coordinate) && coordinate.length >= 2) {
|
|
22034
|
+
const [first, second] = coordinate;
|
|
22035
|
+
if (typeof first === "number" && typeof second === "number") {
|
|
22036
|
+
if (first > 90 || second > 90) {
|
|
22037
|
+
return leafletAdapter.createLatLng(second, first);
|
|
22038
|
+
}
|
|
22039
|
+
if (first > 180 || second > 180) {
|
|
22040
|
+
return leafletAdapter.createLatLng(second, first);
|
|
22041
|
+
}
|
|
22042
|
+
return leafletAdapter.createLatLng(first, second);
|
|
22043
|
+
}
|
|
22044
|
+
}
|
|
22045
|
+
if (typeof coordinate === "string") {
|
|
22046
|
+
const coord = coordinate.trim();
|
|
22047
|
+
if (coord.includes(",") && !coord.includes("°") && !coord.includes("'") && !coord.includes('"')) {
|
|
22048
|
+
const parts = coord.split(",").map((p) => parseFloat(p.trim()));
|
|
22049
|
+
if (parts.length >= 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
|
22050
|
+
return this.convertToLatLng(parts);
|
|
22051
|
+
}
|
|
22052
|
+
}
|
|
22053
|
+
const dmsMatch = coord.match(
|
|
22054
|
+
/(\d+)°(\d+)'(?:(\d+(?:\.\d+)?)")?([NS])\s*,?\s*(\d+)°(\d+)'(?:(\d+(?:\.\d+)?)")?([EW])/i
|
|
22055
|
+
);
|
|
22056
|
+
if (dmsMatch) {
|
|
22057
|
+
const [, latDeg, latMin, latSec, latDir, lngDeg, lngMin, lngSec, lngDir] = dmsMatch;
|
|
22058
|
+
const lat = parseFloat(latDeg) + parseFloat(latMin) / 60 + parseFloat(latSec || "0") / 3600;
|
|
22059
|
+
const lng = parseFloat(lngDeg) + parseFloat(lngMin) / 60 + parseFloat(lngSec || "0") / 3600;
|
|
22060
|
+
const finalLat = latDir.toUpperCase() === "S" ? -lat : lat;
|
|
22061
|
+
const finalLng = lngDir.toUpperCase() === "W" ? -lng : lng;
|
|
22062
|
+
return leafletAdapter.createLatLng(finalLat, finalLng);
|
|
22063
|
+
}
|
|
22064
|
+
const ddmMatch = coord.match(
|
|
22065
|
+
/(\d+)°(\d+(?:\.\d+)?)'([NS])\s*,?\s*(\d+)°(\d+(?:\.\d+)?)'([EW])/i
|
|
22066
|
+
);
|
|
22067
|
+
if (ddmMatch) {
|
|
22068
|
+
const [, latDeg, latMin, latDir, lngDeg, lngMin, lngDir] = ddmMatch;
|
|
22069
|
+
const lat = parseFloat(latDeg) + parseFloat(latMin) / 60;
|
|
22070
|
+
const lng = parseFloat(lngDeg) + parseFloat(lngMin) / 60;
|
|
22071
|
+
const finalLat = latDir.toUpperCase() === "S" ? -lat : lat;
|
|
22072
|
+
const finalLng = lngDir.toUpperCase() === "W" ? -lng : lng;
|
|
22073
|
+
return leafletAdapter.createLatLng(finalLat, finalLng);
|
|
22074
|
+
}
|
|
22075
|
+
const ddMatch = coord.match(/(\d+(?:\.\d+)?)°?\s*([NS])\s*,\s*(\d+(?:\.\d+)?)°?\s*([EW])/i);
|
|
22076
|
+
if (ddMatch) {
|
|
22077
|
+
const [, lat, latDir, lng, lngDir] = ddMatch;
|
|
22078
|
+
const finalLat = latDir.toUpperCase() === "S" ? -parseFloat(lat) : parseFloat(lat);
|
|
22079
|
+
const finalLng = lngDir.toUpperCase() === "W" ? -parseFloat(lng) : parseFloat(lng);
|
|
22080
|
+
return leafletAdapter.createLatLng(finalLat, finalLng);
|
|
22081
|
+
}
|
|
22082
|
+
const neMatch = coord.match(/N\s*(\d+(?:\.\d+)?)\s+E\s*(\d+(?:\.\d+)?)/i);
|
|
22083
|
+
if (neMatch) {
|
|
22084
|
+
const [, lat, lng] = neMatch;
|
|
22085
|
+
return leafletAdapter.createLatLng(parseFloat(lat), parseFloat(lng));
|
|
22086
|
+
}
|
|
22087
|
+
const utmMatch = coord.match(/(?:UTM\s+)?(\d+)([NS])\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)/i);
|
|
22088
|
+
if (utmMatch) {
|
|
22089
|
+
throw new Error(
|
|
22090
|
+
`UTM coordinates detected: ${coord}. UTM conversion requires specialized libraries like proj4js. Please convert to decimal degrees first.`
|
|
22091
|
+
);
|
|
22092
|
+
}
|
|
22093
|
+
const mgrsMatch = coord.match(/(\d+)([A-Z])\s+([A-Z]{2})\s+(\d+)\s+(\d+)/i);
|
|
22094
|
+
if (mgrsMatch) {
|
|
22095
|
+
throw new Error(
|
|
22096
|
+
`MGRS coordinates detected: ${coord}. MGRS conversion requires specialized libraries. Please convert to decimal degrees first.`
|
|
22097
|
+
);
|
|
22098
|
+
}
|
|
22099
|
+
const plusCodeMatch = coord.match(
|
|
22100
|
+
/^[23456789CFGHJMPQRVWX]{2,3}[23456789CFGHJMPQRVWX]{3,7}\+[23456789CFGHJMPQRVWX]{2,3}$/i
|
|
22101
|
+
);
|
|
22102
|
+
if (plusCodeMatch) {
|
|
22103
|
+
throw new Error(
|
|
22104
|
+
`Plus Code detected: ${coord}. Plus Code conversion requires specialized libraries. Please convert to decimal degrees first.`
|
|
22105
|
+
);
|
|
22106
|
+
}
|
|
22107
|
+
}
|
|
22108
|
+
throw new Error(`Unable to convert coordinate: ${JSON.stringify(coordinate)}`);
|
|
22109
|
+
}
|
|
22110
|
+
/**
|
|
22111
|
+
* Convert any coordinate array format to L.LatLng[][][]
|
|
22112
|
+
* Used by addPredefinedPolygon for flexible input handling
|
|
22113
|
+
*/
|
|
22114
|
+
static convertToLatLngArray(geoborders) {
|
|
22115
|
+
return geoborders.map(
|
|
22116
|
+
(group) => group.map((polygon2) => polygon2.map((coord) => this.convertToLatLng(coord)))
|
|
22117
|
+
);
|
|
22118
|
+
}
|
|
22119
|
+
// ========================================================================
|
|
22120
|
+
// POTENTIALLY UNUSED METHODS - TO BE REVIEWED FOR DELETION
|
|
22121
|
+
// ========================================================================
|
|
22122
|
+
// /**
|
|
22123
|
+
// * Simple within check (placeholder for more complex logic)
|
|
22124
|
+
// * This is a simplified version - in a real implementation this would use proper geometric algorithms
|
|
22125
|
+
// */
|
|
22126
|
+
// private static isWithin(inner: number[][], outer: number[][]): boolean {
|
|
22127
|
+
// // Simplified check - just compare first points
|
|
22128
|
+
// if (!inner || !outer || inner.length === 0 || outer.length === 0) {
|
|
22129
|
+
// return false;
|
|
22130
|
+
// }
|
|
22131
|
+
// // This is a placeholder implementation
|
|
22132
|
+
// // In the real implementation, this would use proper point-in-polygon algorithms
|
|
22133
|
+
// return false;
|
|
22134
|
+
// }
|
|
22135
|
+
}
|
|
22136
|
+
class Polydraw extends L$1.Control {
|
|
21153
22137
|
constructor(options) {
|
|
21154
22138
|
super(options);
|
|
21155
22139
|
__publicField(this, "map");
|
|
@@ -21172,6 +22156,11 @@ class Polydraw extends L.Control {
|
|
|
21172
22156
|
__publicField(this, "_boundTouchMove");
|
|
21173
22157
|
__publicField(this, "_boundTouchEnd");
|
|
21174
22158
|
__publicField(this, "_boundTouchStart");
|
|
22159
|
+
__publicField(this, "_boundPointerDown");
|
|
22160
|
+
__publicField(this, "_boundPointerMove");
|
|
22161
|
+
__publicField(this, "_boundPointerUp");
|
|
22162
|
+
__publicField(this, "_lastTapTime", 0);
|
|
22163
|
+
__publicField(this, "_tapTimeout", null);
|
|
21175
22164
|
/**
|
|
21176
22165
|
* Updates map interactions based on the current drawing mode.
|
|
21177
22166
|
*/
|
|
@@ -21179,13 +22168,13 @@ class Polydraw extends L.Control {
|
|
|
21179
22168
|
const container = this.getContainer();
|
|
21180
22169
|
if (!container) return;
|
|
21181
22170
|
const activate = container.querySelector(".icon-activate");
|
|
21182
|
-
if (
|
|
21183
|
-
|
|
22171
|
+
if (leafletAdapter.domUtil.hasClass(activate, "active")) {
|
|
22172
|
+
leafletAdapter.domUtil.removeClass(activate, "active");
|
|
21184
22173
|
if (this.subContainer) {
|
|
21185
22174
|
this.subContainer.style.maxHeight = "0px";
|
|
21186
22175
|
}
|
|
21187
22176
|
} else {
|
|
21188
|
-
|
|
22177
|
+
leafletAdapter.domUtil.addClass(activate, "active");
|
|
21189
22178
|
if (this.subContainer) {
|
|
21190
22179
|
this.subContainer.style.maxHeight = "250px";
|
|
21191
22180
|
}
|
|
@@ -21278,7 +22267,7 @@ class Polydraw extends L.Control {
|
|
|
21278
22267
|
*/
|
|
21279
22268
|
onAdd(_map) {
|
|
21280
22269
|
const extendedMap = _map;
|
|
21281
|
-
const browser = L.Browser;
|
|
22270
|
+
const browser = L$1.Browser;
|
|
21282
22271
|
extendedMap._onResize = () => {
|
|
21283
22272
|
};
|
|
21284
22273
|
if (browser.touch && browser.mobile) {
|
|
@@ -21286,7 +22275,7 @@ class Polydraw extends L.Control {
|
|
|
21286
22275
|
}
|
|
21287
22276
|
this.map = _map;
|
|
21288
22277
|
this.setupKeyboardHandlers();
|
|
21289
|
-
const container =
|
|
22278
|
+
const container = leafletAdapter.domUtil.create("div", "leaflet-control leaflet-bar");
|
|
21290
22279
|
this.initializeUI(container);
|
|
21291
22280
|
this.createTracer();
|
|
21292
22281
|
this.initializeManagers();
|
|
@@ -21323,10 +22312,11 @@ class Polydraw extends L.Control {
|
|
|
21323
22312
|
}
|
|
21324
22313
|
/**
|
|
21325
22314
|
* Adds a predefined polygon to the map.
|
|
21326
|
-
* @param
|
|
22315
|
+
* @param geoborders - Flexible coordinate format: objects ({lat, lng}), arrays ([lat, lng] or [lng, lat]), strings ("lat,lng" or "N59 E10")
|
|
21327
22316
|
* @param options - Optional parameters, including visual optimization level.
|
|
21328
22317
|
*/
|
|
21329
|
-
async addPredefinedPolygon(
|
|
22318
|
+
async addPredefinedPolygon(geoborders, options) {
|
|
22319
|
+
const geographicBorders = CoordinateUtils.convertToLatLngArray(geoborders);
|
|
21330
22320
|
if (!geographicBorders || geographicBorders.length === 0) {
|
|
21331
22321
|
throw new Error("Cannot add empty polygon array");
|
|
21332
22322
|
}
|
|
@@ -21428,16 +22418,16 @@ class Polydraw extends L.Control {
|
|
|
21428
22418
|
*/
|
|
21429
22419
|
initializeUI(container) {
|
|
21430
22420
|
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);
|
|
22421
|
+
L$1.DomEvent.disableClickPropagation(container);
|
|
22422
|
+
L$1.DomEvent.on(container, "mousedown", L$1.DomEvent.stopPropagation);
|
|
22423
|
+
L$1.DomEvent.on(container, "touchstart", L$1.DomEvent.stopPropagation);
|
|
22424
|
+
L$1.DomEvent.on(container, "click", L$1.DomEvent.stopPropagation);
|
|
21435
22425
|
container.style.display = "flex";
|
|
21436
22426
|
container.style.flexDirection = "column-reverse";
|
|
21437
22427
|
container.style.pointerEvents = "auto";
|
|
21438
22428
|
container.style.position = "relative";
|
|
21439
22429
|
container.style.zIndex = "1000";
|
|
21440
|
-
this.subContainer =
|
|
22430
|
+
this.subContainer = leafletAdapter.domUtil.create("div", "sub-buttons", container);
|
|
21441
22431
|
this.subContainer.style.maxHeight = "0px";
|
|
21442
22432
|
this.subContainer.style.overflow = "hidden";
|
|
21443
22433
|
this.subContainer.style.transition = "max-height 0.3s ease";
|
|
@@ -21477,9 +22467,9 @@ class Polydraw extends L.Control {
|
|
|
21477
22467
|
const mapZoomEnabled = this.modeManager.canPerformAction("mapZoom");
|
|
21478
22468
|
const mapDoubleClickEnabled = this.modeManager.canPerformAction("mapDoubleClickZoom");
|
|
21479
22469
|
if (shouldShowCrosshair) {
|
|
21480
|
-
|
|
22470
|
+
leafletAdapter.domUtil.addClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21481
22471
|
} else {
|
|
21482
|
-
|
|
22472
|
+
leafletAdapter.domUtil.removeClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21483
22473
|
}
|
|
21484
22474
|
this.events(false);
|
|
21485
22475
|
this.setLeafletMapEvents(mapDragEnabled, mapDoubleClickEnabled, mapZoomEnabled);
|
|
@@ -21512,7 +22502,7 @@ class Polydraw extends L.Control {
|
|
|
21512
22502
|
* Initializes and adds the tracer polyline to the map.
|
|
21513
22503
|
*/
|
|
21514
22504
|
createTracer() {
|
|
21515
|
-
this.tracer =
|
|
22505
|
+
this.tracer = leafletAdapter.createPolyline([], {
|
|
21516
22506
|
...this.config.polyLineOptions,
|
|
21517
22507
|
color: this.config.colors.polyline
|
|
21518
22508
|
});
|
|
@@ -21592,9 +22582,9 @@ class Polydraw extends L.Control {
|
|
|
21592
22582
|
_updateUIAfterDrawModeChange(mode) {
|
|
21593
22583
|
const shouldShowCrosshair = this.modeManager.shouldShowCrosshairCursor();
|
|
21594
22584
|
if (shouldShowCrosshair) {
|
|
21595
|
-
|
|
22585
|
+
leafletAdapter.domUtil.addClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21596
22586
|
} else {
|
|
21597
|
-
|
|
22587
|
+
leafletAdapter.domUtil.removeClass(this.map.getContainer(), "crosshair-cursor-enabled");
|
|
21598
22588
|
}
|
|
21599
22589
|
try {
|
|
21600
22590
|
switch (mode) {
|
|
@@ -21661,7 +22651,7 @@ class Polydraw extends L.Control {
|
|
|
21661
22651
|
const shouldBeDraggable = this.modeManager.canPerformAction("markerDrag");
|
|
21662
22652
|
this.arrayOfFeatureGroups.forEach((featureGroup) => {
|
|
21663
22653
|
featureGroup.eachLayer((layer) => {
|
|
21664
|
-
if (layer instanceof L.Marker) {
|
|
22654
|
+
if (layer instanceof L$1.Marker) {
|
|
21665
22655
|
const marker = layer;
|
|
21666
22656
|
try {
|
|
21667
22657
|
marker.options.draggable = shouldBeDraggable;
|
|
@@ -21719,12 +22709,19 @@ class Polydraw extends L.Control {
|
|
|
21719
22709
|
* @param onoff - A boolean indicating whether to attach or detach the events.
|
|
21720
22710
|
*/
|
|
21721
22711
|
drawStartedEvents(onoff) {
|
|
22712
|
+
console.log("drawStartedEvents called with onoff:", onoff);
|
|
21722
22713
|
const onoroff = onoff ? "on" : "off";
|
|
21723
22714
|
this.map[onoroff]("mousemove", this.mouseMove, this);
|
|
21724
22715
|
this.map[onoroff]("mouseup", this.mouseUpLeave, this);
|
|
21725
22716
|
if (onoff) {
|
|
21726
22717
|
this._boundTouchMove = (e) => this.mouseMove(e);
|
|
21727
22718
|
this._boundTouchEnd = (e) => this.mouseUpLeave(e);
|
|
22719
|
+
if (LeafletVersionDetector.isV2()) {
|
|
22720
|
+
this._boundPointerMove = (e) => this.mouseMove(e);
|
|
22721
|
+
this._boundPointerUp = (e) => this.mouseUpLeave(e);
|
|
22722
|
+
this.map.getContainer().addEventListener("pointermove", this._boundPointerMove, { passive: false });
|
|
22723
|
+
this.map.getContainer().addEventListener("pointerup", this._boundPointerUp, { passive: false });
|
|
22724
|
+
}
|
|
21728
22725
|
this.map.getContainer().addEventListener("touchmove", this._boundTouchMove, { passive: false });
|
|
21729
22726
|
this.map.getContainer().addEventListener("touchend", this._boundTouchEnd, { passive: false });
|
|
21730
22727
|
} else {
|
|
@@ -21734,6 +22731,12 @@ class Polydraw extends L.Control {
|
|
|
21734
22731
|
if (this._boundTouchEnd) {
|
|
21735
22732
|
this.map.getContainer().removeEventListener("touchend", this._boundTouchEnd);
|
|
21736
22733
|
}
|
|
22734
|
+
if (this._boundPointerMove) {
|
|
22735
|
+
this.map.getContainer().removeEventListener("pointermove", this._boundPointerMove);
|
|
22736
|
+
}
|
|
22737
|
+
if (this._boundPointerUp) {
|
|
22738
|
+
this.map.getContainer().removeEventListener("pointerup", this._boundPointerUp);
|
|
22739
|
+
}
|
|
21737
22740
|
}
|
|
21738
22741
|
}
|
|
21739
22742
|
/**
|
|
@@ -21745,74 +22748,111 @@ class Polydraw extends L.Control {
|
|
|
21745
22748
|
this.map[onoroff]("mousedown", this.mouseDown, this);
|
|
21746
22749
|
this.map[onoroff]("dblclick", this.handleDoubleClick, this);
|
|
21747
22750
|
if (onoff) {
|
|
21748
|
-
this._boundTouchStart = (e) => this.
|
|
22751
|
+
this._boundTouchStart = (e) => this.handleTouchStart(e);
|
|
22752
|
+
if (LeafletVersionDetector.isV2()) {
|
|
22753
|
+
this._boundPointerDown = (e) => this.mouseDown(e);
|
|
22754
|
+
this.map.getContainer().addEventListener("pointerdown", this._boundPointerDown, { passive: false });
|
|
22755
|
+
}
|
|
21749
22756
|
this.map.getContainer().addEventListener("touchstart", this._boundTouchStart, { passive: false });
|
|
21750
22757
|
} else {
|
|
21751
22758
|
if (this._boundTouchStart) {
|
|
21752
22759
|
this.map.getContainer().removeEventListener("touchstart", this._boundTouchStart);
|
|
21753
22760
|
}
|
|
22761
|
+
if (this._boundPointerDown) {
|
|
22762
|
+
this.map.getContainer().removeEventListener("pointerdown", this._boundPointerDown);
|
|
22763
|
+
}
|
|
22764
|
+
}
|
|
22765
|
+
}
|
|
22766
|
+
/**
|
|
22767
|
+
* Handle touch start events with double-tap detection
|
|
22768
|
+
* @param event - The touch event
|
|
22769
|
+
*/
|
|
22770
|
+
handleTouchStart(event) {
|
|
22771
|
+
const currentTime = Date.now();
|
|
22772
|
+
const timeDiff = currentTime - this._lastTapTime;
|
|
22773
|
+
if (this._tapTimeout) {
|
|
22774
|
+
clearTimeout(this._tapTimeout);
|
|
22775
|
+
this._tapTimeout = null;
|
|
22776
|
+
}
|
|
22777
|
+
if (timeDiff < 300 && timeDiff > 0) {
|
|
22778
|
+
this.handleDoubleTap(event);
|
|
22779
|
+
this._lastTapTime = 0;
|
|
22780
|
+
} else {
|
|
22781
|
+
this._lastTapTime = currentTime;
|
|
22782
|
+
this._tapTimeout = window.setTimeout(() => {
|
|
22783
|
+
this.mouseDown(event);
|
|
22784
|
+
this._tapTimeout = null;
|
|
22785
|
+
}, 300);
|
|
21754
22786
|
}
|
|
21755
22787
|
}
|
|
22788
|
+
/**
|
|
22789
|
+
* Handle double-tap for touch devices
|
|
22790
|
+
* @param event - The touch event
|
|
22791
|
+
*/
|
|
22792
|
+
handleDoubleTap(event) {
|
|
22793
|
+
if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint) {
|
|
22794
|
+
return;
|
|
22795
|
+
}
|
|
22796
|
+
this.polygonDrawManager.handleDoubleTap(event);
|
|
22797
|
+
}
|
|
21756
22798
|
/**
|
|
21757
22799
|
* Handles the mouse down event to start a drawing operation.
|
|
21758
|
-
* @param event - The mouse or
|
|
22800
|
+
* @param event - The mouse, touch, or pointer event.
|
|
21759
22801
|
*/
|
|
21760
22802
|
mouseDown(event) {
|
|
21761
|
-
|
|
21762
|
-
|
|
22803
|
+
console.log("mouseDown called", event.type, event);
|
|
22804
|
+
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
22805
|
+
if (EventAdapter.shouldPreventDefault(normalizedEvent)) {
|
|
22806
|
+
normalizedEvent.preventDefault();
|
|
21763
22807
|
}
|
|
21764
22808
|
if (this.modeManager.isInOffMode()) {
|
|
22809
|
+
console.log("In off mode, ignoring");
|
|
21765
22810
|
return;
|
|
21766
22811
|
}
|
|
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
|
-
}
|
|
22812
|
+
const clickLatLng = EventAdapter.extractCoordinates(normalizedEvent, this.map);
|
|
22813
|
+
console.log("Extracted coordinates:", clickLatLng);
|
|
21777
22814
|
if (!clickLatLng) {
|
|
22815
|
+
console.log("No coordinates extracted");
|
|
21778
22816
|
return;
|
|
21779
22817
|
}
|
|
21780
22818
|
if (this.modeManager.getCurrentMode() === DrawMode.PointToPoint) {
|
|
22819
|
+
console.log("Point-to-Point mode, calling handlePointToPointClick");
|
|
21781
22820
|
this.polygonDrawManager.handlePointToPointClick(clickLatLng);
|
|
21782
22821
|
return;
|
|
21783
22822
|
}
|
|
22823
|
+
console.log("Normal drawing mode, setting tracer and starting draw");
|
|
21784
22824
|
this.tracer.setLatLngs([clickLatLng]);
|
|
21785
22825
|
this.startDraw();
|
|
21786
22826
|
}
|
|
21787
22827
|
/**
|
|
21788
22828
|
* Handles the mouse move event to draw the tracer polyline.
|
|
21789
|
-
* @param event - The mouse or
|
|
22829
|
+
* @param event - The mouse, touch, or pointer event.
|
|
21790
22830
|
*/
|
|
21791
22831
|
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
|
-
]);
|
|
22832
|
+
console.log("mouseMove called", event.type);
|
|
22833
|
+
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
22834
|
+
if (EventAdapter.shouldPreventDefault(normalizedEvent)) {
|
|
22835
|
+
normalizedEvent.preventDefault();
|
|
22836
|
+
}
|
|
22837
|
+
const latlng = EventAdapter.extractCoordinates(normalizedEvent, this.map);
|
|
22838
|
+
if (latlng) {
|
|
22839
|
+
console.log("Adding latlng to tracer:", latlng);
|
|
21803
22840
|
this.tracer.addLatLng(latlng);
|
|
21804
22841
|
}
|
|
21805
22842
|
}
|
|
21806
22843
|
/**
|
|
21807
22844
|
* Handles the mouse up event to complete a drawing operation.
|
|
21808
|
-
* @param event - The mouse or
|
|
22845
|
+
* @param event - The mouse, touch, or pointer event.
|
|
21809
22846
|
*/
|
|
21810
22847
|
async mouseUpLeave(event) {
|
|
21811
|
-
|
|
21812
|
-
|
|
22848
|
+
console.log("mouseUpLeave called", event.type);
|
|
22849
|
+
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
22850
|
+
if (EventAdapter.shouldPreventDefault(normalizedEvent)) {
|
|
22851
|
+
normalizedEvent.preventDefault();
|
|
21813
22852
|
}
|
|
21814
22853
|
this.polygonInformation.deletePolygonInformationStorage();
|
|
21815
22854
|
const tracerGeoJSON = this.tracer.toGeoJSON();
|
|
22855
|
+
console.log("Tracer GeoJSON:", tracerGeoJSON);
|
|
21816
22856
|
if (!tracerGeoJSON || !tracerGeoJSON.geometry || !tracerGeoJSON.geometry.coordinates || tracerGeoJSON.geometry.coordinates.length < 3) {
|
|
21817
22857
|
this.stopDraw();
|
|
21818
22858
|
return;
|
|
@@ -21891,6 +22931,7 @@ class Polydraw extends L.Control {
|
|
|
21891
22931
|
* Starts a drawing operation by attaching the necessary event listeners.
|
|
21892
22932
|
*/
|
|
21893
22933
|
startDraw() {
|
|
22934
|
+
console.log("startDraw called, attaching draw events");
|
|
21894
22935
|
this.drawStartedEvents(true);
|
|
21895
22936
|
}
|
|
21896
22937
|
/**
|
|
@@ -21943,7 +22984,7 @@ class Polydraw extends L.Control {
|
|
|
21943
22984
|
updateAllMarkersForEdgeDeletion(showFeedback) {
|
|
21944
22985
|
this.arrayOfFeatureGroups.forEach((featureGroup) => {
|
|
21945
22986
|
featureGroup.eachLayer((layer) => {
|
|
21946
|
-
if (layer instanceof L.Marker) {
|
|
22987
|
+
if (layer instanceof L$1.Marker) {
|
|
21947
22988
|
this.updateMarkerForEdgeDeletion(layer, showFeedback);
|
|
21948
22989
|
}
|
|
21949
22990
|
});
|
|
@@ -22018,18 +23059,21 @@ class Polydraw extends L.Control {
|
|
|
22018
23059
|
const activateButton = container.querySelector(".icon-activate");
|
|
22019
23060
|
if (!activateButton) return;
|
|
22020
23061
|
const hasPolygons = this.arrayOfFeatureGroups.length > 0;
|
|
22021
|
-
const isPanelClosed = !
|
|
23062
|
+
const isPanelClosed = !leafletAdapter.domUtil.hasClass(activateButton, "active");
|
|
22022
23063
|
if (hasPolygons && isPanelClosed) {
|
|
22023
|
-
|
|
23064
|
+
leafletAdapter.domUtil.addClass(activateButton, "polydraw-indicator-active");
|
|
22024
23065
|
} else {
|
|
22025
|
-
|
|
23066
|
+
leafletAdapter.domUtil.removeClass(activateButton, "polydraw-indicator-active");
|
|
22026
23067
|
}
|
|
22027
23068
|
}
|
|
22028
23069
|
}
|
|
22029
|
-
L.control
|
|
22030
|
-
|
|
22031
|
-
|
|
23070
|
+
if (typeof L$1 !== "undefined" && L$1.control) {
|
|
23071
|
+
L$1.control.polydraw = function(options) {
|
|
23072
|
+
return new Polydraw(options);
|
|
23073
|
+
};
|
|
23074
|
+
}
|
|
22032
23075
|
export {
|
|
22033
|
-
Polydraw as default
|
|
23076
|
+
Polydraw as default,
|
|
23077
|
+
leafletAdapter
|
|
22034
23078
|
};
|
|
22035
23079
|
//# sourceMappingURL=polydraw.es.js.map
|