From 4f906246bfbfc461d039218c2616b4d1adc819c4 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 15 Feb 2013 16:29:20 -0800 Subject: [PATCH] Enable cleaner overriding of TileLayer#getTileUrl Moved the called to _adjustTilePoint outside of getTileUrl, and moved the call to _getZoomForUrl into _adjustTilePoint. This allows getTileUrl to use x, y, z directly without any calls to private methods. --- src/layer/tile/TileLayer.WMS.js | 2 -- src/layer/tile/TileLayer.js | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/layer/tile/TileLayer.WMS.js b/src/layer/tile/TileLayer.WMS.js index 1daba748..8d155768 100644 --- a/src/layer/tile/TileLayer.WMS.js +++ b/src/layer/tile/TileLayer.WMS.js @@ -48,8 +48,6 @@ L.TileLayer.WMS = L.TileLayer.extend({ getTileUrl: function (tilePoint, zoom) { // (Point, Number) -> String - this._adjustTilePoint(tilePoint); - var map = this._map, crs = map.options.crs, tileSize = this.options.tileSize, diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index d17b6184..bc84ead6 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -416,11 +416,9 @@ L.TileLayer = L.Class.extend({ // image-specific code (override to implement e.g. Canvas or SVG tile layer) getTileUrl: function (tilePoint) { - this._adjustTilePoint(tilePoint); - return L.Util.template(this._url, L.extend({ s: this._getSubdomain(tilePoint), - z: this._getZoomForUrl(), + z: tilePoint.z, x: tilePoint.x, y: tilePoint.y }, this.options)); @@ -443,6 +441,8 @@ L.TileLayer = L.Class.extend({ if (this.options.tms) { tilePoint.y = limit - tilePoint.y - 1; } + + tilePoint.z = this._getZoomForUrl(); }, _getSubdomain: function (tilePoint) { @@ -479,6 +479,7 @@ L.TileLayer = L.Class.extend({ tile.onload = this._tileOnLoad; tile.onerror = this._tileOnError; + this._adjustTilePoint(tilePoint); tile.src = this.getTileUrl(tilePoint); },