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) {
const urls = []
for (const i in this.tilelayers) {
if (this.tilelayers.hasOwnProperty(i)) {
method.call(context, this.tilelayers[i])
urls.push(this.tilelayers[i]._url)
}
}
if (
this.customTilelayer &&
Array.prototype.indexOf &&
urls.indexOf(this.customTilelayer._url) === -1
) {
method.call(context || this, this.customTilelayer)
const call = (layer) => {
const url = layer.options.url_template
if (urls.indexOf(url) !== -1) return
method.call(context, layer)
urls.push(url)
}
if (this.customTilelayer) call(this.customTilelayer)
this.tilelayers.forEach(call)
},
setOverlay: function () {