Merge pull request #4099 from tcoats/tileunload-cases
Fire tileunload for all unloading of tiles
This commit is contained in:
commit
653f5d01ff
@ -38,6 +38,7 @@
|
||||
|
||||
grid.on('loading', function() { console.log('loading'); });
|
||||
grid.on('load', function() { console.log('load'); });
|
||||
grid.on('tileunload', function(tile) { console.log('tileunload ' + tile.coords.x + ',' + tile.coords.y + ',' + tile.coords.z); });
|
||||
|
||||
var map = L.map('map')
|
||||
.setView([50.5, 30.51], 10)
|
||||
|
@ -41,6 +41,7 @@ L.GridLayer = L.Layer.extend({
|
||||
},
|
||||
|
||||
onRemove: function (map) {
|
||||
this._removeAllTiles();
|
||||
L.DomUtil.remove(this._container);
|
||||
map._removeZoomLimit(this);
|
||||
this._container = null;
|
||||
@ -217,6 +218,7 @@ L.GridLayer = L.Layer.extend({
|
||||
this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z);
|
||||
} else {
|
||||
L.DomUtil.remove(this._levels[z].el);
|
||||
this._removeTilesAtZoom(z);
|
||||
delete this._levels[z];
|
||||
}
|
||||
}
|
||||
@ -273,6 +275,15 @@ L.GridLayer = L.Layer.extend({
|
||||
}
|
||||
},
|
||||
|
||||
_removeTilesAtZoom: function (zoom) {
|
||||
for (var key in this._tiles) {
|
||||
if (this._tiles[key].coords.z !== zoom) {
|
||||
continue;
|
||||
}
|
||||
this._removeTile(key);
|
||||
}
|
||||
},
|
||||
|
||||
_removeAllTiles: function () {
|
||||
for (var key in this._tiles) {
|
||||
this._removeTile(key);
|
||||
|
Loading…
Reference in New Issue
Block a user