fixed loading forever on torque visualizations

This commit is contained in:
javi 2015-11-24 14:26:46 +01:00
parent c660bc8fe7
commit a393186f9f

View File

@ -80,11 +80,12 @@ L.Mixin.TileLoader = {
}, },
_removeOtherTiles: function (bounds) { _removeOtherTiles: function (bounds) {
var self = this;
var kArr, x, y, z, key; var kArr, x, y, z, key;
var zoom = this._map.getZoom(); var zoom = this._map.getZoom();
for (key in this._tiles) { function checkTile(c, key) {
if (this._tiles.hasOwnProperty(key)) { if (c.hasOwnProperty(key)) {
kArr = key.split(':'); kArr = key.split(':');
x = parseInt(kArr[0], 10); x = parseInt(kArr[0], 10);
y = parseInt(kArr[1], 10); y = parseInt(kArr[1], 10);
@ -92,22 +93,41 @@ L.Mixin.TileLoader = {
// remove tile if it's out of bounds // remove tile if it's out of bounds
if (zoom !== z || x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) { if (zoom !== z || x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) {
this._removeTile(key); self._removeTile(key);
} }
} }
} }
for (key in this._tiles) {
checkTile(this._tiles, key);
}
for (key in this._tilesLoading) {
checkTile(this._tilesLoading, key);
}
}, },
_removeTile: function (key) { _removeTile: function (key) {
this.fire('tileRemoved', this._tiles[key]); this.fire('tileRemoved', this._tiles[key]);
delete this._tiles[key]; delete this._tiles[key];
delete this._tilesLoading[key]; if (this._tilesLoading[key]) {
--this._tilesToLoad;
delete this._tilesLoading[key];
}
}, },
_tileKey: function(tilePoint) { _tileKey: function(tilePoint) {
return tilePoint.x + ':' + tilePoint.y + ':' + tilePoint.zoom; return tilePoint.x + ':' + tilePoint.y + ':' + tilePoint.zoom;
}, },
_tileFromKey: function(key) {
var kArr = key.split(':');
return {
x: parseInt(kArr[0], 10),
y: parseInt(kArr[1], 10),
z: parseInt(kArr[2], 10)
}
},
_tileShouldBeLoaded: function (tilePoint) { _tileShouldBeLoaded: function (tilePoint) {
var k = this._tileKey(tilePoint); var k = this._tileKey(tilePoint);
return !(k in this._tiles) && !(k in this._tilesLoading); return !(k in this._tiles) && !(k in this._tilesLoading);