Adding destroy method, as suggested by @bartvde
This commit is contained in:
@@ -170,11 +170,25 @@ OpenLayers.TileManager = OpenLayers.Class({
|
||||
var layer = evt.layer;
|
||||
if (layer instanceof OpenLayers.Layer.Grid) {
|
||||
this.clearTileQueue({object: layer});
|
||||
layer.events.un({
|
||||
addtile: this.addTile,
|
||||
retile: this.clearTileQueue,
|
||||
scope: this
|
||||
});
|
||||
if (layer.events) {
|
||||
layer.events.un({
|
||||
addtile: this.addTile,
|
||||
retile: this.clearTileQueue,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
if (layer.grid) {
|
||||
var i, j, tile;
|
||||
for (i=layer.grid.length-1; i>=0; --i) {
|
||||
for (j=layer.grid[i].length-1; j>=0; --j) {
|
||||
tile = layer.grid[i][j];
|
||||
this.unloadTile({object: tile});
|
||||
if (tile.url) {
|
||||
this.manageTileCache({object: tile});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -322,6 +336,31 @@ OpenLayers.TileManager = OpenLayers.Class({
|
||||
this.tileQueue.splice(i, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
window.clearTimeout(this.tileQueueId);
|
||||
var map = this.map;
|
||||
if (map.layers) {
|
||||
for (var i=0, ii=map.layers.length; i<ii; ++i) {
|
||||
this.removeLayer({layer: map.layers[i]});
|
||||
}
|
||||
}
|
||||
if (map.events) {
|
||||
map.events.un({
|
||||
move: this.move,
|
||||
zoomend: this.zoomEnd,
|
||||
addlayer: this.addLayer,
|
||||
removelayer: this.removeLayer,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
this.map = null;
|
||||
this.tileQueue = null;
|
||||
if (this.tileCache !== OpenLayers.TileManager.prototype.tileCache) {
|
||||
this.tileCache = null;
|
||||
this.tileCacheIndex = null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user