Open matbeard opened 8 years ago
Thanks for the report, we'll take a look when we can. Testing with 1.0.0-rc3 is sufficient as we are primarily targeting 1.0 compatibility.
Any update on this? Still happening with Leaflet 1.0.3.
Is there a work around on how to manually remove the layer from the map?
Under
wms.Source = L.Layer.extend({
below
onAdd: function() {
this.refreshOverlay()
},
just add this code which is implementation for onRemove() so that the final code looks like:
onAdd: function() {
this.refreshOverlay()
},
onRemove: function() {
var subLayers = Object.keys(this._subLayers).join(",");
if (!this._map) {
return
}
if (subLayers) {
this._overlay.remove();
}
},
getEvents: function() {
if (this.options.identify) {
return {
click: this.identify
}
} else {
return {}
}
},
That enables when using TILED version of WMS service to remove current layer and then you can add another WMS layer to a map.
Good timing, just came across this problem again today but your solution works. Thanks @mgurjanov
What's going on with this? There's been a pull request to fix this issue for like 2 years.
https://github.com/heigeo/leaflet.wms/pull/66
Can this get merged please?
This is with Leaflet 1.0.0-rc3 (not tried any other versions):
If you create an instance of Leaflet map and add one or more wms layers, then try to remove the map instance with
map.remove()
an error is generated:Uncaught TypeError: layer.onRemove is not a function