mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-20 16:37:08 +00:00
TileLayer: fix getTileUrl parameter regression (#9766)
This commit is contained in:
@ -440,6 +440,26 @@ describe('TileLayer', () => {
|
||||
i++;
|
||||
});
|
||||
});
|
||||
|
||||
it('consults options.foo for {foo}', () => {
|
||||
const OSMLayer = TileLayer.extend({options: {foo: 'bar'}});
|
||||
const layer = new OSMLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}').addTo(map);
|
||||
map.options.zoomSnap = 0;
|
||||
map._resetView(new LatLng(0, 0), 2.3);
|
||||
|
||||
const urls = [
|
||||
'https://tile.openstreetmap.org/2/1/1.png?bar',
|
||||
'https://tile.openstreetmap.org/2/2/1.png?bar',
|
||||
'https://tile.openstreetmap.org/2/1/2.png?bar',
|
||||
'https://tile.openstreetmap.org/2/2/2.png?bar'
|
||||
];
|
||||
|
||||
let i = 0;
|
||||
eachImg(layer, (img) => {
|
||||
expect(img.src).to.eql(urls[i]);
|
||||
i++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('crossOrigin option', () => {
|
||||
|
@ -187,14 +187,14 @@ export const TileLayer = GridLayer.extend({
|
||||
// Called only internally, returns the URL for a tile given its coordinates.
|
||||
// Classes extending `TileLayer` can override this function to provide custom tile URL naming schemes.
|
||||
getTileUrl(coords) {
|
||||
const data = {
|
||||
...this.options,
|
||||
const data = Object.create(this.options);
|
||||
Object.assign(data, {
|
||||
r: Browser.retina ? '@2x' : '',
|
||||
s: this._getSubdomain(coords),
|
||||
x: coords.x,
|
||||
y: coords.y,
|
||||
z: this._getZoomForUrl()
|
||||
};
|
||||
});
|
||||
if (this._map && !this._map.options.crs.infinite) {
|
||||
const invertedY = this._globalTileRange.max.y - coords.y;
|
||||
if (this.options.tms) {
|
||||
|
Reference in New Issue
Block a user