leaflet-polydraw 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/polydraw.es.js +129 -29
- 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/managers/polygon-interaction-manager.d.ts +3 -0
- package/dist/types/managers/polygon-interaction-manager.d.ts.map +1 -1
- package/dist/types/managers/polygon-mutation-manager.d.ts.map +1 -1
- package/dist/types/polydraw.d.ts +7 -0
- package/dist/types/polydraw.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/polydraw.es.js
CHANGED
|
@@ -15609,6 +15609,7 @@ class PolygonInteractionManager {
|
|
|
15609
15609
|
__publicField(this, "_openMenuPopup", null);
|
|
15610
15610
|
__publicField(this, "transformModeActive", false);
|
|
15611
15611
|
__publicField(this, "transformControllers", /* @__PURE__ */ new WeakMap());
|
|
15612
|
+
__publicField(this, "transformAuxiliaryDisplayValues", /* @__PURE__ */ new WeakMap());
|
|
15612
15613
|
__publicField(this, "deleteMarkerSuppressUntil", 0);
|
|
15613
15614
|
__publicField(this, "onModeChange", () => {
|
|
15614
15615
|
if (this.currentCloneGhost || this.isPolygonDragActive()) {
|
|
@@ -16420,6 +16421,7 @@ class PolygonInteractionManager {
|
|
|
16420
16421
|
interactive: true
|
|
16421
16422
|
}
|
|
16422
16423
|
);
|
|
16424
|
+
edgePolyline._polydrawAuxiliaryLayer = true;
|
|
16423
16425
|
edgePolyline._polydrawEdgeInfo = {
|
|
16424
16426
|
ringIndex,
|
|
16425
16427
|
edgeIndex: i,
|
|
@@ -18033,6 +18035,36 @@ class PolygonInteractionManager {
|
|
|
18033
18035
|
}
|
|
18034
18036
|
});
|
|
18035
18037
|
}
|
|
18038
|
+
setTransformAuxiliaryVisibility(featureGroup, visible) {
|
|
18039
|
+
const polygon2 = this.getPolygonLayer(featureGroup);
|
|
18040
|
+
if (polygon2) {
|
|
18041
|
+
this.setMarkerVisibility(polygon2, visible);
|
|
18042
|
+
}
|
|
18043
|
+
featureGroup.eachLayer((layer) => {
|
|
18044
|
+
var _a2;
|
|
18045
|
+
if (!this.isPolydrawAuxiliaryPolyline(layer)) {
|
|
18046
|
+
return;
|
|
18047
|
+
}
|
|
18048
|
+
const element = (_a2 = layer.getElement) == null ? void 0 : _a2.call(layer);
|
|
18049
|
+
if (!element) {
|
|
18050
|
+
return;
|
|
18051
|
+
}
|
|
18052
|
+
if (!visible) {
|
|
18053
|
+
if (!this.transformAuxiliaryDisplayValues.has(layer)) {
|
|
18054
|
+
this.transformAuxiliaryDisplayValues.set(layer, element.style.display);
|
|
18055
|
+
}
|
|
18056
|
+
element.style.display = "none";
|
|
18057
|
+
return;
|
|
18058
|
+
}
|
|
18059
|
+
if (this.transformAuxiliaryDisplayValues.has(layer)) {
|
|
18060
|
+
element.style.display = this.transformAuxiliaryDisplayValues.get(layer) ?? "";
|
|
18061
|
+
this.transformAuxiliaryDisplayValues.delete(layer);
|
|
18062
|
+
}
|
|
18063
|
+
});
|
|
18064
|
+
}
|
|
18065
|
+
isPolydrawAuxiliaryPolyline(layer) {
|
|
18066
|
+
return layer instanceof L.Polyline && !(layer instanceof L.Polygon) && layer._polydrawAuxiliaryLayer === true;
|
|
18067
|
+
}
|
|
18036
18068
|
getBuiltInMenuButtonConfigs() {
|
|
18037
18069
|
const menuOps = this.config.polygonTools;
|
|
18038
18070
|
return [
|
|
@@ -18266,10 +18298,7 @@ class PolygonInteractionManager {
|
|
|
18266
18298
|
(confirmed) => this.handleTransformControllerResult(controller, featureGroup, mode, confirmed)
|
|
18267
18299
|
);
|
|
18268
18300
|
this.transformControllers.set(featureGroup, controller);
|
|
18269
|
-
|
|
18270
|
-
if (polygonLayer) {
|
|
18271
|
-
this.setMarkerVisibility(polygonLayer, false);
|
|
18272
|
-
}
|
|
18301
|
+
this.setTransformAuxiliaryVisibility(featureGroup, false);
|
|
18273
18302
|
this.transformModeActive = true;
|
|
18274
18303
|
} catch {
|
|
18275
18304
|
}
|
|
@@ -18284,7 +18313,7 @@ class PolygonInteractionManager {
|
|
|
18284
18313
|
return;
|
|
18285
18314
|
}
|
|
18286
18315
|
if (!confirmed) {
|
|
18287
|
-
this.
|
|
18316
|
+
this.setTransformAuxiliaryVisibility(featureGroup, true);
|
|
18288
18317
|
return;
|
|
18289
18318
|
}
|
|
18290
18319
|
const { level: optimizationLevel, original: originalOptimizationLevel } = this.getOptimizationMetadataFromFeatureGroup(featureGroup);
|
|
@@ -19126,6 +19155,7 @@ class PolygonMutationManager {
|
|
|
19126
19155
|
fillColor: this.config.styles.hole.fillColor,
|
|
19127
19156
|
fillOpacity: this.config.styles.hole.fillOpacity || 0.5
|
|
19128
19157
|
});
|
|
19158
|
+
holePolyline._polydrawAuxiliaryLayer = true;
|
|
19129
19159
|
featureGroup.addLayer(holePolyline);
|
|
19130
19160
|
this.interactionManager.addHoleMarkers(latLngLiterals, featureGroup);
|
|
19131
19161
|
}
|
|
@@ -21634,12 +21664,17 @@ class Polydraw extends L.Control {
|
|
|
21634
21664
|
__publicField(this, "drawEventsAttached", false);
|
|
21635
21665
|
__publicField(this, "controlEvents", /* @__PURE__ */ new WeakSet());
|
|
21636
21666
|
__publicField(this, "lastControlPointerDown", null);
|
|
21667
|
+
__publicField(this, "_boundMouseMove");
|
|
21668
|
+
__publicField(this, "_boundMouseUp");
|
|
21637
21669
|
__publicField(this, "_boundTouchMove");
|
|
21638
21670
|
__publicField(this, "_boundTouchEnd");
|
|
21671
|
+
__publicField(this, "_boundTouchCancel");
|
|
21639
21672
|
__publicField(this, "_boundTouchStart");
|
|
21640
21673
|
__publicField(this, "_boundPointerDown");
|
|
21641
21674
|
__publicField(this, "_boundPointerMove");
|
|
21642
21675
|
__publicField(this, "_boundPointerUp");
|
|
21676
|
+
__publicField(this, "_boundPointerCancel");
|
|
21677
|
+
__publicField(this, "_boundContextMenu");
|
|
21643
21678
|
__publicField(this, "_lastTapTime", 0);
|
|
21644
21679
|
__publicField(this, "_lastTapLatLng", null);
|
|
21645
21680
|
__publicField(this, "_tapTimeout", null);
|
|
@@ -21653,6 +21688,7 @@ class Polydraw extends L.Control {
|
|
|
21653
21688
|
__publicField(this, "_initRequestId", 0);
|
|
21654
21689
|
__publicField(this, "_historySuppressionDepth", 0);
|
|
21655
21690
|
__publicField(this, "_lastAppliedVisibleMapOrder", []);
|
|
21691
|
+
__publicField(this, "originalMapTouchAction", null);
|
|
21656
21692
|
/**
|
|
21657
21693
|
* Updates map interactions based on the current drawing mode.
|
|
21658
21694
|
*/
|
|
@@ -21869,6 +21905,7 @@ class Polydraw extends L.Control {
|
|
|
21869
21905
|
comprehensiveCleanup() {
|
|
21870
21906
|
this.events(false);
|
|
21871
21907
|
this.drawStartedEvents(false);
|
|
21908
|
+
this.setMapDrawingTouchLock(false);
|
|
21872
21909
|
this.removeKeyboardHandlers();
|
|
21873
21910
|
if (this.tracer) {
|
|
21874
21911
|
try {
|
|
@@ -21907,12 +21944,21 @@ class Polydraw extends L.Control {
|
|
|
21907
21944
|
if (this._boundKeyUpHandler) {
|
|
21908
21945
|
this._boundKeyUpHandler = void 0;
|
|
21909
21946
|
}
|
|
21947
|
+
if (this._boundMouseMove) {
|
|
21948
|
+
this._boundMouseMove = void 0;
|
|
21949
|
+
}
|
|
21950
|
+
if (this._boundMouseUp) {
|
|
21951
|
+
this._boundMouseUp = void 0;
|
|
21952
|
+
}
|
|
21910
21953
|
if (this._boundTouchMove) {
|
|
21911
21954
|
this._boundTouchMove = void 0;
|
|
21912
21955
|
}
|
|
21913
21956
|
if (this._boundTouchEnd) {
|
|
21914
21957
|
this._boundTouchEnd = void 0;
|
|
21915
21958
|
}
|
|
21959
|
+
if (this._boundTouchCancel) {
|
|
21960
|
+
this._boundTouchCancel = void 0;
|
|
21961
|
+
}
|
|
21916
21962
|
if (this._boundTouchStart) {
|
|
21917
21963
|
this._boundTouchStart = void 0;
|
|
21918
21964
|
}
|
|
@@ -21925,6 +21971,12 @@ class Polydraw extends L.Control {
|
|
|
21925
21971
|
if (this._boundPointerUp) {
|
|
21926
21972
|
this._boundPointerUp = void 0;
|
|
21927
21973
|
}
|
|
21974
|
+
if (this._boundPointerCancel) {
|
|
21975
|
+
this._boundPointerCancel = void 0;
|
|
21976
|
+
}
|
|
21977
|
+
if (this._boundContextMenu) {
|
|
21978
|
+
this._boundContextMenu = void 0;
|
|
21979
|
+
}
|
|
21928
21980
|
if (this._tapTimeout) {
|
|
21929
21981
|
clearTimeout(this._tapTimeout);
|
|
21930
21982
|
this._tapTimeout = null;
|
|
@@ -23166,9 +23218,28 @@ class Polydraw extends L.Control {
|
|
|
23166
23218
|
const mapDragEnabled = this.modeManager.canPerformAction("mapDrag");
|
|
23167
23219
|
const mapZoomEnabled = this.modeManager.canPerformAction("mapZoom");
|
|
23168
23220
|
const mapDoubleClickEnabled = this.modeManager.canPerformAction("mapDoubleClickZoom");
|
|
23169
|
-
this.
|
|
23221
|
+
const drawEventsEnabled = this.shouldEnableDrawEvents(this.drawMode);
|
|
23222
|
+
this.events(drawEventsEnabled);
|
|
23223
|
+
this.setMapDrawingTouchLock(drawEventsEnabled);
|
|
23170
23224
|
this.setLeafletMapEvents(mapDragEnabled, mapDoubleClickEnabled, mapZoomEnabled);
|
|
23171
23225
|
}
|
|
23226
|
+
setMapDrawingTouchLock(enabled) {
|
|
23227
|
+
if (!this.map) {
|
|
23228
|
+
return;
|
|
23229
|
+
}
|
|
23230
|
+
const container = this.map.getContainer();
|
|
23231
|
+
if (enabled) {
|
|
23232
|
+
if (this.originalMapTouchAction === null) {
|
|
23233
|
+
this.originalMapTouchAction = container.style.touchAction || "";
|
|
23234
|
+
}
|
|
23235
|
+
container.style.touchAction = "none";
|
|
23236
|
+
return;
|
|
23237
|
+
}
|
|
23238
|
+
if (this.originalMapTouchAction !== null) {
|
|
23239
|
+
container.style.touchAction = this.originalMapTouchAction;
|
|
23240
|
+
this.originalMapTouchAction = null;
|
|
23241
|
+
}
|
|
23242
|
+
}
|
|
23172
23243
|
/**
|
|
23173
23244
|
* Restore the map state from a history snapshot
|
|
23174
23245
|
*/
|
|
@@ -23470,6 +23541,14 @@ class Polydraw extends L.Control {
|
|
|
23470
23541
|
this.map[onoroff]("mouseup", this.mouseUpLeave, this);
|
|
23471
23542
|
}
|
|
23472
23543
|
if (onoff) {
|
|
23544
|
+
if (!this._boundMouseMove) {
|
|
23545
|
+
this._boundMouseMove = (e) => this.mouseMove(e);
|
|
23546
|
+
}
|
|
23547
|
+
if (!this._boundMouseUp) {
|
|
23548
|
+
this._boundMouseUp = (e) => this.mouseUpLeave(e);
|
|
23549
|
+
}
|
|
23550
|
+
document.addEventListener("mousemove", this._boundMouseMove);
|
|
23551
|
+
document.addEventListener("mouseup", this._boundMouseUp);
|
|
23473
23552
|
if (!usePointerEvents) {
|
|
23474
23553
|
if (!this._boundTouchMove) {
|
|
23475
23554
|
this._boundTouchMove = (e) => this.mouseMove(e);
|
|
@@ -23477,8 +23556,12 @@ class Polydraw extends L.Control {
|
|
|
23477
23556
|
if (!this._boundTouchEnd) {
|
|
23478
23557
|
this._boundTouchEnd = (e) => this.mouseUpLeave(e);
|
|
23479
23558
|
}
|
|
23480
|
-
this.
|
|
23481
|
-
|
|
23559
|
+
if (!this._boundTouchCancel) {
|
|
23560
|
+
this._boundTouchCancel = (e) => this.mouseUpLeave(e);
|
|
23561
|
+
}
|
|
23562
|
+
document.addEventListener("touchmove", this._boundTouchMove, { passive: false });
|
|
23563
|
+
document.addEventListener("touchend", this._boundTouchEnd, { passive: false });
|
|
23564
|
+
document.addEventListener("touchcancel", this._boundTouchCancel, { passive: false });
|
|
23482
23565
|
}
|
|
23483
23566
|
if (usePointerEvents) {
|
|
23484
23567
|
if (!this._boundPointerMove) {
|
|
@@ -23487,21 +23570,37 @@ class Polydraw extends L.Control {
|
|
|
23487
23570
|
if (!this._boundPointerUp) {
|
|
23488
23571
|
this._boundPointerUp = (e) => this.mouseUpLeave(e);
|
|
23489
23572
|
}
|
|
23490
|
-
this.
|
|
23491
|
-
|
|
23573
|
+
if (!this._boundPointerCancel) {
|
|
23574
|
+
this._boundPointerCancel = (e) => this.mouseUpLeave(e);
|
|
23575
|
+
}
|
|
23576
|
+
document.addEventListener("pointermove", this._boundPointerMove, { passive: false });
|
|
23577
|
+
document.addEventListener("pointerup", this._boundPointerUp, { passive: false });
|
|
23578
|
+
document.addEventListener("pointercancel", this._boundPointerCancel, { passive: false });
|
|
23492
23579
|
}
|
|
23493
23580
|
} else {
|
|
23581
|
+
if (this._boundMouseMove) {
|
|
23582
|
+
document.removeEventListener("mousemove", this._boundMouseMove);
|
|
23583
|
+
}
|
|
23584
|
+
if (this._boundMouseUp) {
|
|
23585
|
+
document.removeEventListener("mouseup", this._boundMouseUp);
|
|
23586
|
+
}
|
|
23494
23587
|
if (this._boundTouchMove) {
|
|
23495
|
-
|
|
23588
|
+
document.removeEventListener("touchmove", this._boundTouchMove);
|
|
23496
23589
|
}
|
|
23497
23590
|
if (this._boundTouchEnd) {
|
|
23498
|
-
|
|
23591
|
+
document.removeEventListener("touchend", this._boundTouchEnd);
|
|
23592
|
+
}
|
|
23593
|
+
if (this._boundTouchCancel) {
|
|
23594
|
+
document.removeEventListener("touchcancel", this._boundTouchCancel);
|
|
23499
23595
|
}
|
|
23500
23596
|
if (this._boundPointerMove) {
|
|
23501
|
-
|
|
23597
|
+
document.removeEventListener("pointermove", this._boundPointerMove);
|
|
23502
23598
|
}
|
|
23503
23599
|
if (this._boundPointerUp) {
|
|
23504
|
-
|
|
23600
|
+
document.removeEventListener("pointerup", this._boundPointerUp);
|
|
23601
|
+
}
|
|
23602
|
+
if (this._boundPointerCancel) {
|
|
23603
|
+
document.removeEventListener("pointercancel", this._boundPointerCancel);
|
|
23505
23604
|
}
|
|
23506
23605
|
}
|
|
23507
23606
|
}
|
|
@@ -23521,6 +23620,10 @@ class Polydraw extends L.Control {
|
|
|
23521
23620
|
}
|
|
23522
23621
|
this.map[onoroff]("dblclick", this.handleDoubleClick, this);
|
|
23523
23622
|
if (onoff) {
|
|
23623
|
+
if (!this._boundContextMenu) {
|
|
23624
|
+
this._boundContextMenu = (e) => e.preventDefault();
|
|
23625
|
+
}
|
|
23626
|
+
this.map.getContainer().addEventListener("contextmenu", this._boundContextMenu);
|
|
23524
23627
|
if (!usePointerEvents) {
|
|
23525
23628
|
if (!this._boundTouchStart) {
|
|
23526
23629
|
this._boundTouchStart = (e) => this.handleTouchStart(e);
|
|
@@ -23534,6 +23637,9 @@ class Polydraw extends L.Control {
|
|
|
23534
23637
|
this.map.getContainer().addEventListener("pointerdown", this._boundPointerDown, { passive: false });
|
|
23535
23638
|
}
|
|
23536
23639
|
} else {
|
|
23640
|
+
if (this._boundContextMenu) {
|
|
23641
|
+
this.map.getContainer().removeEventListener("contextmenu", this._boundContextMenu);
|
|
23642
|
+
}
|
|
23537
23643
|
if (this._boundTouchStart) {
|
|
23538
23644
|
this.map.getContainer().removeEventListener("touchstart", this._boundTouchStart);
|
|
23539
23645
|
}
|
|
@@ -23547,6 +23653,9 @@ class Polydraw extends L.Control {
|
|
|
23547
23653
|
* @param event - The touch event
|
|
23548
23654
|
*/
|
|
23549
23655
|
handleTouchStart(event) {
|
|
23656
|
+
if (EventAdapter.shouldPreventDefault(event)) {
|
|
23657
|
+
event.preventDefault();
|
|
23658
|
+
}
|
|
23550
23659
|
const currentTime = Date.now();
|
|
23551
23660
|
const timeDiff = currentTime - this._lastTapTime;
|
|
23552
23661
|
const isPointToPointMode = this.modeManager.getCurrentMode() === DrawMode.PointToPoint || this.modeManager.getCurrentMode() === DrawMode.PointToPointSubtract;
|
|
@@ -23571,21 +23680,12 @@ class Polydraw extends L.Control {
|
|
|
23571
23680
|
clearTimeout(this._tapTimeout);
|
|
23572
23681
|
this._tapTimeout = null;
|
|
23573
23682
|
}
|
|
23574
|
-
|
|
23575
|
-
|
|
23576
|
-
|
|
23577
|
-
} else {
|
|
23578
|
-
this._lastTapTime = currentTime;
|
|
23579
|
-
this._lastTapLatLng = EventAdapter.extractCoordinates(event, this.map);
|
|
23580
|
-
if (!this.pointerEventsHandled) {
|
|
23581
|
-
this._tapTimeout = window.setTimeout(() => {
|
|
23582
|
-
this.mouseDown(event);
|
|
23583
|
-
this._tapTimeout = null;
|
|
23584
|
-
}, 300);
|
|
23585
|
-
}
|
|
23586
|
-
}
|
|
23683
|
+
this._lastTapTime = currentTime;
|
|
23684
|
+
this._lastTapLatLng = EventAdapter.extractCoordinates(event, this.map);
|
|
23685
|
+
this.mouseDown(event);
|
|
23587
23686
|
}
|
|
23588
23687
|
isP2PDoubleTapClose(tapLatLng, timeDiff) {
|
|
23688
|
+
if (!this.map) return false;
|
|
23589
23689
|
if (!tapLatLng || !this._lastTapLatLng) return false;
|
|
23590
23690
|
if (timeDiff <= 0 || timeDiff > 300) return false;
|
|
23591
23691
|
const lastTapPoint = this.map.latLngToLayerPoint(this._lastTapLatLng);
|
|
@@ -23751,7 +23851,7 @@ class Polydraw extends L.Control {
|
|
|
23751
23851
|
*/
|
|
23752
23852
|
mouseMove(event) {
|
|
23753
23853
|
var _a2;
|
|
23754
|
-
if (!this.isDrawingInProgress) {
|
|
23854
|
+
if (!this.map || !this.isDrawingInProgress) {
|
|
23755
23855
|
return;
|
|
23756
23856
|
}
|
|
23757
23857
|
const normalizedEvent = EventAdapter.normalizeEvent(event);
|
|
@@ -23769,7 +23869,7 @@ class Polydraw extends L.Control {
|
|
|
23769
23869
|
*/
|
|
23770
23870
|
async mouseUpLeave(event) {
|
|
23771
23871
|
var _a2;
|
|
23772
|
-
if (!this.isDrawingInProgress) {
|
|
23872
|
+
if (!this.map || !this.isDrawingInProgress) {
|
|
23773
23873
|
return;
|
|
23774
23874
|
}
|
|
23775
23875
|
const normalizedEvent = EventAdapter.normalizeEvent(event);
|