Merge pull request #4344 from jieter/infinite-crs-gettileurl
Do not calculate inverted y coords for CRSes with infinite: true
This commit is contained in:
commit
24a2a11715
@ -340,6 +340,26 @@ describe('TileLayer', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Does not replace {-y} on map with infinite CRS', function () {
|
||||||
|
var simplediv = document.createElement('div');
|
||||||
|
simplediv.style.width = '400px';
|
||||||
|
simplediv.style.height = '400px';
|
||||||
|
simplediv.style.visibility = 'hidden';
|
||||||
|
|
||||||
|
document.body.appendChild(simplediv);
|
||||||
|
var simpleMap = L.map(simplediv, {
|
||||||
|
crs: L.CRS.Simple
|
||||||
|
}).setView([0, 0], 5);
|
||||||
|
var layer = L.tileLayer('http://example.com/{z}/{-y}/{x}.png');
|
||||||
|
|
||||||
|
expect(function () {
|
||||||
|
layer.addTo(simpleMap);
|
||||||
|
}).to.throwError('No value provided for variable {-y}');
|
||||||
|
|
||||||
|
simpleMap.remove();
|
||||||
|
document.body.removeChild(simplediv);
|
||||||
|
});
|
||||||
|
|
||||||
it('replaces {s} with [abc] by default', function () {
|
it('replaces {s} with [abc] by default', function () {
|
||||||
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png').addTo(map);
|
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png').addTo(map);
|
||||||
|
|
||||||
|
@ -75,16 +75,22 @@ L.TileLayer = L.GridLayer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTileUrl: function (coords) {
|
getTileUrl: function (coords) {
|
||||||
var invertedY = this._globalTileRange.max.y - coords.y;
|
var data = {
|
||||||
|
|
||||||
return L.Util.template(this._url, L.extend({
|
|
||||||
r: L.Browser.retina ? '@2x' : '',
|
r: L.Browser.retina ? '@2x' : '',
|
||||||
s: this._getSubdomain(coords),
|
s: this._getSubdomain(coords),
|
||||||
x: coords.x,
|
x: coords.x,
|
||||||
y: this.options.tms ? invertedY : coords.y,
|
y: coords.y,
|
||||||
'-y': invertedY,
|
|
||||||
z: this._getZoomForUrl()
|
z: this._getZoomForUrl()
|
||||||
}, this.options));
|
};
|
||||||
|
if (this._map && !this._map.options.crs.infinite) {
|
||||||
|
var invertedY = this._globalTileRange.max.y - coords.y;
|
||||||
|
if (this.options.tms) {
|
||||||
|
data['y'] = invertedY;
|
||||||
|
}
|
||||||
|
data['-y'] = invertedY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return L.Util.template(this._url, L.extend(data, this.options));
|
||||||
},
|
},
|
||||||
|
|
||||||
_tileOnLoad: function (done, tile) {
|
_tileOnLoad: function (done, tile) {
|
||||||
|
Loading…
Reference in New Issue
Block a user