Make sure custom tilelayer is displayed first, if any

This commit is contained in:
Yohan Boniface 2023-12-15 16:19:15 +01:00
parent afd57d6806
commit 34d3beef25

View file

@ -648,19 +648,14 @@ L.U.Map.include({
eachTileLayer: function (method, context) { eachTileLayer: function (method, context) {
const urls = [] const urls = []
for (const i in this.tilelayers) { const call = (layer) => {
if (this.tilelayers.hasOwnProperty(i)) { const url = layer.options.url_template
method.call(context, this.tilelayers[i]) if (urls.indexOf(url) !== -1) return
urls.push(this.tilelayers[i]._url) method.call(context, layer)
} urls.push(url)
}
if (
this.customTilelayer &&
Array.prototype.indexOf &&
urls.indexOf(this.customTilelayer._url) === -1
) {
method.call(context || this, this.customTilelayer)
} }
if (this.customTilelayer) call(this.customTilelayer)
this.tilelayers.forEach(call)
}, },
setOverlay: function () { setOverlay: function () {