diff --git a/spec/suites/layer/tile/TileLayerSpec.js b/spec/suites/layer/tile/TileLayerSpec.js index 8def2deaf..004bb0ebd 100644 --- a/spec/suites/layer/tile/TileLayerSpec.js +++ b/spec/suites/layer/tile/TileLayerSpec.js @@ -511,4 +511,16 @@ describe('TileLayer', () => { layer.setUrl(placeKitten); }); }); + + describe('#getTileUrl', function () { + it('can call with static coords', function () { + // Layer is not added to the map + var layer = L.tileLayer('http://example.com/{z}/{x}/{y}.png'); + var url = layer.getTileUrl({z: 1, x: 2, y: 3}); + expect(url).to.equal('http://example.com/1/2/3.png'); + layer.addTo(map) + var url = layer.getTileUrl({z: 1, x: 2, y: 3}); + expect(url).to.equal('http://example.com/1/2/3.png'); + }); + }); }); diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 44b347b30..6f62b7c31 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -181,7 +181,7 @@ export const TileLayer = GridLayer.extend({ s: this._getSubdomain(coords), x: coords.x, y: coords.y, - z: this._getZoomForUrl() + z: this._getZoomForUrl(coords.z) }; if (this._map && !this._map.options.crs.infinite) { const invertedY = this._globalTileRange.max.y - coords.y; @@ -210,8 +210,7 @@ export const TileLayer = GridLayer.extend({ e.tile.onload = null; }, - _getZoomForUrl() { - let zoom = this._tileZoom; + _getZoomForUrl: function (zoom) { const maxZoom = this.options.maxZoom, zoomReverse = this.options.zoomReverse, zoomOffset = this.options.zoomOffset;