Merge pull request #111 from CartoDB/correctionfix
Substitutes inherited functions from leaflet to own correction
This commit is contained in:
commit
7cb1d7b33b
@ -86,11 +86,6 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
|
|
||||||
// for each tile shown on the map request the data
|
// for each tile shown on the map request the data
|
||||||
this.on('tileAdded', function(t) {
|
this.on('tileAdded', function(t) {
|
||||||
var fixedPoint = new L.Point(t.x, t.y);
|
|
||||||
this._adjustTilePoint(fixedPoint);
|
|
||||||
t.corrected = {};
|
|
||||||
t.corrected.x = fixedPoint.x;
|
|
||||||
t.corrected.y = fixedPoint.y;
|
|
||||||
var tileData = this.provider.getTileData(t, t.zoom, function(tileData) {
|
var tileData = this.provider.getTileData(t, t.zoom, function(tileData) {
|
||||||
// don't load tiles that are not being shown
|
// don't load tiles that are not being shown
|
||||||
if (t.zoom !== self._map.getZoom()) return;
|
if (t.zoom !== self._map.getZoom()) return;
|
||||||
@ -104,39 +99,6 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_adjustTilePoint: function (tilePoint) {
|
|
||||||
|
|
||||||
var limit = this._getWrapTileNum();
|
|
||||||
|
|
||||||
// wrap tile coordinates
|
|
||||||
if (!this.options.continuousWorld && !this.options.noWrap) {
|
|
||||||
tilePoint.x = ((tilePoint.x % limit.x) + limit.x) % limit.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.tms) {
|
|
||||||
tilePoint.y = limit.y - tilePoint.y - 1;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_getWrapTileNum: function () {
|
|
||||||
var crs = this._map.options.crs,
|
|
||||||
size = crs.getSize(this._map.getZoom());
|
|
||||||
return size.divideBy(this._getTileSize())._floor();
|
|
||||||
},
|
|
||||||
|
|
||||||
_getTileSize: function () {
|
|
||||||
var map = this._map,
|
|
||||||
zoom = map.getZoom() + this.options.zoomOffset,
|
|
||||||
zoomN = this.options.maxNativeZoom,
|
|
||||||
tileSize = this.options.tileSize;
|
|
||||||
|
|
||||||
if (zoomN && zoom > zoomN) {
|
|
||||||
tileSize = Math.round(map.getZoomScale(zoom) / map.getZoomScale(zoomN) * tileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tileSize;
|
|
||||||
},
|
|
||||||
|
|
||||||
_clearTileCaches: function() {
|
_clearTileCaches: function() {
|
||||||
var t, tile;
|
var t, tile;
|
||||||
for(t in this._tiles) {
|
for(t in this._tiles) {
|
||||||
|
@ -281,10 +281,12 @@
|
|||||||
var self = this;
|
var self = this;
|
||||||
var prof_fetch_time = Profiler.metric('torque.provider.windshaft.tile.fetch').start();
|
var prof_fetch_time = Profiler.metric('torque.provider.windshaft.tile.fetch').start();
|
||||||
var subdomains = this.options.subdomains || '0123';
|
var subdomains = this.options.subdomains || '0123';
|
||||||
var index = Math.abs(coord.corrected.x + coord.corrected.y) % subdomains.length;
|
var limit_x = Math.pow(2, zoom);
|
||||||
|
var corrected_x = ((coord.x % limit_x) + limit_x) % limit_x;
|
||||||
|
var index = Math.abs(corrected_x + coord.y) % subdomains.length;
|
||||||
var url = this.templateUrl
|
var url = this.templateUrl
|
||||||
.replace('{x}', coord.corrected.x)
|
.replace('{x}', corrected_x)
|
||||||
.replace('{y}', coord.corrected.y)
|
.replace('{y}', coord.y)
|
||||||
.replace('{z}', zoom)
|
.replace('{z}', zoom)
|
||||||
.replace('{s}', subdomains[index])
|
.replace('{s}', subdomains[index])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user