Skip to content

Commit

Permalink
fix error with onRemove hook that causes underlying image to catch on…
Browse files Browse the repository at this point in the history
…going requests
  • Loading branch information
ilsanchez committed Aug 19, 2019
1 parent cdd88e6 commit dc68239
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/leaflet.wms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions src/leaflet.wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
this.refreshOverlay();
},

onRemove: function() {},
onRemove: function() {

},

getEvents: function() {
if (this.options.identify) {
Expand All @@ -102,7 +104,7 @@

setZIndex: function(zIndex) {
this.options.zIndex = zIndex;
if(this._overlay) {
if (this._overlay) {
this._overlay.setZIndex(zIndex);
}
},
Expand Down Expand Up @@ -316,8 +318,16 @@
var url = this.getTileUrl(coords);
var img = document.createElement('img');
ajax(url, _done, this.options, 'blob');
L.DomEvent.on(img, 'load', L.Util.bind(this._tileOnLoad, this, done, img));
L.DomEvent.on(img, 'error', L.Util.bind(this._tileOnError, this, done, img));
L.DomEvent.on(
img,
'load',
L.Util.bind(this._tileOnLoad, this, done, img)
);
L.DomEvent.on(
img,
'error',
L.Util.bind(this._tileOnError, this, done, img)
);
return img;
}
});
Expand Down Expand Up @@ -421,6 +431,12 @@
onRemove: function(map) {
if (this._currentOverlay) {
map.removeLayer(this._currentOverlay);
if (
this._currentOverlay &&
this._currentOverlay._image
) {
L.DomUtils.remove(this._currentOverlay._image);
}
delete this._currentOverlay;
}
if (this._currentUrl) {
Expand Down

0 comments on commit dc68239

Please sign in to comment.