Permalink
Browse files

Merge pull request #256 from CodeJosch/tileunload

Fire a "tileunload" when tiles removed
  • Loading branch information...
2 parents 77d28a7 + 3a6efaa commit d36d4b514c0ddca184884acc91f7d4fc735e3179 @mourner mourner committed Aug 31, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/layer/tile/TileLayer.js
@@ -177,12 +177,16 @@ L.TileLayer = L.Class.extend({
// remove tile if it's out of bounds
if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) {
+ var tile = this._tiles[key];
+ this.fire("tileunload", {tile: tile, url: tile.src});
+
// evil, don't do this! crashes Android 3, produces load errors, doesn't solve memory leaks
// this._tiles[key].src = '';
- if (this._tiles[key].parentNode == this._container) {
- this._container.removeChild(this._tiles[key]);
+ if (tile.parentNode == this._container) {
+ this._container.removeChild(tile);
}
+ // could be tile...?
delete this._tiles[key];
}
}

0 comments on commit d36d4b5

Please sign in to comment.