Skip to content

Commit

Permalink
Remove temp layers after editing / removing (#1534) (patch)
Browse files Browse the repository at this point in the history
* Remove temp layers from the map

* Fix tests
  • Loading branch information
Falke-Design authored Nov 24, 2024
1 parent 71b83e5 commit b55fd6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/circle.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/circlemarker.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
9 changes: 5 additions & 4 deletions src/js/Edit/L.PM.Edit.CircleMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -158,6 +158,7 @@ Edit.CircleMarker = Edit.extend({

// cleanup old ones first
if (this._helperLayers) {
this._helperLayers.removeFrom(map);
this._helperLayers.clearLayers();
}

Expand Down
1 change: 1 addition & 0 deletions src/js/Edit/L.PM.Edit.Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Edit.Line = Edit.extend({

// cleanup old ones first
if (this._markerGroup) {
this._markerGroup.removeFrom(map);
this._markerGroup.clearLayers();
}

Expand Down

0 comments on commit b55fd6d

Please sign in to comment.