Skip to content

Commit

Permalink
Merge pull request Leaflet#2160 from perliedman/crs-size
Browse files Browse the repository at this point in the history
Remove hardcoded world size from L.TileLayer
  • Loading branch information
mourner committed Nov 6, 2013
2 parents 2464d13 + 37d303d commit e2977a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/geo/crs/CRS.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ L.CRS = {

scale: function (zoom) {
return 256 * Math.pow(2, zoom);
},

getSize: function (zoom) {
var s = this.scale(zoom);
return L.point(s, s);
}
};
9 changes: 5 additions & 4 deletions src/layer/tile/TileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,9 @@ L.TileLayer = L.Class.extend({
},

_getWrapTileNum: function () {
// TODO refactor, limit is not valid for non-standard projections
return Math.pow(2, this._getZoomForUrl());
var crs = this._map.options.crs,
size = crs.getSize(this._getZoomForUrl());
return size.divideBy(this.options.tileSize);
},

_adjustTilePoint: function (tilePoint) {
Expand All @@ -483,11 +484,11 @@ L.TileLayer = L.Class.extend({

// wrap tile coordinates
if (!this.options.continuousWorld && !this.options.noWrap) {
tilePoint.x = ((tilePoint.x % limit) + limit) % limit;
tilePoint.x = ((tilePoint.x % limit.x) + limit.x) % limit.x;
}

if (this.options.tms) {
tilePoint.y = limit - tilePoint.y - 1;
tilePoint.y = limit.y - tilePoint.y - 1;
}

tilePoint.z = this._getZoomForUrl();
Expand Down

0 comments on commit e2977a1

Please sign in to comment.