From b55fd6d6e3d17366a5a202bae66de6c052ea78ec Mon Sep 17 00:00:00 2001 From: Florian Bischof Date: Sun, 24 Nov 2024 08:31:36 +0100 Subject: [PATCH] Remove temp layers after editing / removing (#1534) (patch) * Remove temp layers from the map * Fix tests --- cypress/e2e/circle.cy.js | 2 +- cypress/e2e/circlemarker.cy.js | 2 +- src/js/Edit/L.PM.Edit.CircleMarker.js | 9 +++++---- src/js/Edit/L.PM.Edit.Line.js | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/circle.cy.js b/cypress/e2e/circle.cy.js index b5dcf996..06e71191 100644 --- a/cypress/e2e/circle.cy.js +++ b/cypress/e2e/circle.cy.js @@ -277,7 +277,7 @@ describe('Draw Circle', () => { const layer = map.pm.getGeomanDrawLayers()[0]; layer.remove(); }); - cy.hasLayers(3); + cy.hasLayers(2); }); it('check if snapping works with max radius of circle', () => { cy.toolbarButton('circle') diff --git a/cypress/e2e/circlemarker.cy.js b/cypress/e2e/circlemarker.cy.js index ed86ece5..81bfee5c 100644 --- a/cypress/e2e/circlemarker.cy.js +++ b/cypress/e2e/circlemarker.cy.js @@ -436,7 +436,7 @@ describe('Draw Circle Marker', () => { const layer = map.pm.getGeomanDrawLayers()[0]; layer.remove(); }); - cy.hasLayers(3); + cy.hasLayers(2); }); it('check if snapping works with max radius of circle', () => { diff --git a/src/js/Edit/L.PM.Edit.CircleMarker.js b/src/js/Edit/L.PM.Edit.CircleMarker.js index 24a94074..fdb323bf 100644 --- a/src/js/Edit/L.PM.Edit.CircleMarker.js +++ b/src/js/Edit/L.PM.Edit.CircleMarker.js @@ -82,11 +82,11 @@ Edit.CircleMarker = Edit.extend({ if (this.layerDragEnabled()) { this.disableLayerDrag(); } - + if (this._helperLayers) { + this._helperLayers.clearLayers(); + this._helperLayers.removeFrom(this._map); + } if (this.options[this._editableOption]) { - if (this._helperLayers) { - this._helperLayers.clearLayers(); - } this._map.off('move', this._syncMarkers, this); this._outerMarker.off('drag', this._handleOuterMarkerSnapping, this); } else { @@ -158,6 +158,7 @@ Edit.CircleMarker = Edit.extend({ // cleanup old ones first if (this._helperLayers) { + this._helperLayers.removeFrom(map); this._helperLayers.clearLayers(); } diff --git a/src/js/Edit/L.PM.Edit.Line.js b/src/js/Edit/L.PM.Edit.Line.js index e69d8a48..1fad5777 100644 --- a/src/js/Edit/L.PM.Edit.Line.js +++ b/src/js/Edit/L.PM.Edit.Line.js @@ -136,6 +136,7 @@ Edit.Line = Edit.extend({ // cleanup old ones first if (this._markerGroup) { + this._markerGroup.removeFrom(map); this._markerGroup.clearLayers(); }