This commit is contained in:
Carlos Matallín 2017-11-14 12:12:02 +01:00
parent 69cdd20c36
commit 9c9c7253ba
3 changed files with 25 additions and 25 deletions

View File

@ -180,20 +180,24 @@ GMapsTorqueLayer.prototype = torque.extend({},
// for each tile shown on the map request the data
onTileAdded: function(t) {
var self = this;
var successCallback = function (tileData) {
var callback = function (tileData, error) {
// don't load tiles that are not being shown
if (t.zoom !== self.map.getZoom()) return;
self._tileLoaded(t, tileData);
self.fire('tileLoaded');
if (tileData) {
self.redraw();
}
};
var errorCallback = function (error) {
self.fire('tileLoaded');
if (error) {
self.fire('tileError', error);
}
}
this.provider.getTileData(t, t.zoom, successCallback, errorCallback);
this.provider.getTileData(t, t.zoom, callback);
},
clear: function() {

View File

@ -105,31 +105,27 @@ L.TorqueLayer = L.CanvasLayer.extend({
// for each tile shown on the map request the data
this.on('tileAdded', function(t) {
var callback = function (tileData, error) {
self._onTileAdded(t, tileData);
// don't load tiles that are not being shown
if (t.zoom !== self._map.getZoom()) return;
self._tileLoaded(t, tileData);
self._clearTileCaches();
if (tileData) {
self.redraw();
}
self.fire('tileLoaded');
if (error) {
self.fire('tileError', error);
}
self.fire('tileLoaded');
};
var tileData = this.provider.getTileData(t, t.zoom, callback);
}, this);
},
_onTileAdded: function(t, tileData) {
// don't load tiles that are not being shown
if (t.zoom !== this._map.getZoom()) return;
this._tileLoaded(t, tileData);
this._clearTileCaches();
if (tileData) {
this.redraw();
}
},
_clearTileCaches: function() {
var t, tile;
for(t in this._tiles) {

View File

@ -267,11 +267,11 @@
return null;
},
getTileData: function(coord, zoom, successCallback, errorCallback) {
getTileData: function(coord, zoom, callback) {
if(!this._ready) {
this._tileQueue.push([coord, zoom, successCallback, errorCallback]);
this._tileQueue.push([coord, zoom, callback]);
} else {
this._getTileData(coord, zoom, successCallback, errorCallback);
this._getTileData(coord, zoom, callback);
}
},
@ -320,7 +320,7 @@
}
} else {
Profiler.metric('torque.provider.windshaft.tile.error').inc();
successCallback(null);
callback(null);
}
});
},