mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-20 16:37:08 +00:00
Honour coords.z when passed to TileLayer.getTileUrl
cf #6004 #6006 Before this change, `coords.z` would not taken into account, and was always overriden by `this._tileZoom`. In the normal flow, `coords.z` is anyway set from `this._tileZoom` before `getTileUrl` is called (in GridLayer._update). But this prevents using `getTileUrl` out of this `_update` method. There are some scenarios where this is needed (see #5822), or (which is the case in uMap) when wanting to display a tile as a tilelayer preview.
This commit is contained in:

committed by
Florian Bischof

parent
35d79e012b
commit
a3ea289eb8
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user