From 1f45ef73488612a941fb27e43305631b4407e529 Mon Sep 17 00:00:00 2001 From: Majiir Paktu Date: Fri, 23 Dec 2011 12:56:56 -0500 Subject: [PATCH] Added zoomInvert option to reverse the order in which zooms are numbered. --- src/layer/tile/TileLayer.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 859c65ed..ccceea98 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -17,6 +17,7 @@ L.TileLayer = L.Class.extend({ continuousWorld: false, noWrap: false, zoomOffset: 0, + zoomReverse: false, unloadInvisibleTiles: L.Browser.mobile, updateWhenIdle: L.Browser.mobile @@ -209,7 +210,7 @@ L.TileLayer = L.Class.extend({ var tilePos = this._getTilePos(tilePoint), zoom = this._map.getZoom(), key = tilePoint.x + ':' + tilePoint.y, - tileLimit = Math.pow(2, (zoom + this.options.zoomOffset)); + tileLimit = Math.pow(2, this._getOffsetZoom(zoom)); // wrap tile coordinates if (!this.options.continuousWorld) { @@ -240,6 +241,14 @@ L.TileLayer = L.Class.extend({ container.appendChild(tile); }, + + _getOffsetZoom: function(zoom) { + if (this.options.zoomReverse) { + return (this.options.maxZoom - zoom) + this.options.zoomOffset; + } else { + return zoom + this.options.zoomOffset; + } + }, _getTilePos: function (tilePoint) { var origin = this._map.getPixelOrigin(), @@ -256,7 +265,7 @@ L.TileLayer = L.Class.extend({ return L.Util.template(this._url, L.Util.extend({ s: s, - z: zoom + this.options.zoomOffset, + z: this._getOffsetZoom(zoom), x: tilePoint.x, y: tilePoint.y }, this._urlParams));