Skip to content

Commit

Permalink
1.1.3 - modifying L.Map.removeLayer(layer)
Browse files Browse the repository at this point in the history
  • Loading branch information
slutske22 committed May 8, 2020
1 parent 50e59fd commit a20fd80
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
16 changes: 16 additions & 0 deletions example/with-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,19 @@ function flyToNorway(){
somePopup.closePopup()

}



window.simpleVector0 = simpleVector0
window.map = map

L.control.layers(null, {
"Vector 1": simpleVector0,
"Vector 2": simpleVector1,
"Vector 3": simpleVector2,
"Vector 4": simpleVector3,
"Vector 5": simpleVector4,
"Vector 6": simpleVector5,
"Group 2": group2,
"Group 3": group3
}).addTo(map)
40 changes: 36 additions & 4 deletions src/leaflet-arrowheads.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ L.Polyline.include({
// Reset variables from previous this._update()
if (this._arrowheads){
this._arrowheads.remove()
let arrowheads = []
let allhats = []
}

// -------------------------------------------------------- //
Expand Down Expand Up @@ -372,8 +370,7 @@ L.Polyline.include({
remove: function () {

if (this._arrowheads){
this._arrowheads.removeFrom(this._map || this._mapToAdd);
this._arrowheads = []
this._arrowheads.remove();
}
return this.removeFrom(this._map || this._mapToAdd);
},
Expand Down Expand Up @@ -415,3 +412,38 @@ L.LayerGroup.include({


})


L.Map.include({

removeLayer: function (layer) {

var id = L.Util.stamp(layer);

if (layer._arrowheads){
layer._arrowheads.remove()
}

if (!this._layers[id]) { return this; }

if (this._loaded) {
layer.onRemove(this);
}

if (layer.getAttribution && this.attributionControl) {
this.attributionControl.removeAttribution(layer.getAttribution());
}

delete this._layers[id];

if (this._loaded) {
this.fire('layerremove', {layer: layer});
layer.fire('remove');
}

layer._map = layer._mapToAdd = null;

return this;
},

})

0 comments on commit a20fd80

Please sign in to comment.