Merge pull request #2160 from perliedman/crs-size

Remove hardcoded world size from L.TileLayer
This commit is contained in:
Vladimir Agafonkin 2013-11-06 14:03:30 -08:00
commit e2977a1244
2 changed files with 10 additions and 4 deletions

View File

@ -23,5 +23,10 @@ L.CRS = {
scale: function (zoom) { scale: function (zoom) {
return 256 * Math.pow(2, zoom); return 256 * Math.pow(2, zoom);
},
getSize: function (zoom) {
var s = this.scale(zoom);
return L.point(s, s);
} }
}; };

View File

@ -473,8 +473,9 @@ L.TileLayer = L.Class.extend({
}, },
_getWrapTileNum: function () { _getWrapTileNum: function () {
// TODO refactor, limit is not valid for non-standard projections var crs = this._map.options.crs,
return Math.pow(2, this._getZoomForUrl()); size = crs.getSize(this._getZoomForUrl());
return size.divideBy(this.options.tileSize);
}, },
_adjustTilePoint: function (tilePoint) { _adjustTilePoint: function (tilePoint) {
@ -483,11 +484,11 @@ L.TileLayer = L.Class.extend({
// wrap tile coordinates // wrap tile coordinates
if (!this.options.continuousWorld && !this.options.noWrap) { 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) { if (this.options.tms) {
tilePoint.y = limit - tilePoint.y - 1; tilePoint.y = limit.y - tilePoint.y - 1;
} }
tilePoint.z = this._getZoomForUrl(); tilePoint.z = this._getZoomForUrl();