X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a155a2fda3e014fee0aa52ca44e7f28cf738b2dd..b3c5010e143fb2e9491ddb34f36f59a698da7fea:/app/assets/javascripts/leaflet.map.js diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index 02ed318ac..6537b0b23 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -130,11 +130,14 @@ L.OSM.Map = L.Map.extend({ }, getMapBaseLayerId: function () { - var baseLayerId; - this.eachLayer(function (layer) { - if (layer.options && layer.options.layerId) baseLayerId = layer.options.layerId; - }); - return baseLayerId; + const layer = this.getMapBaseLayer(); + if (layer) return layer.options.layerId; + }, + + getMapBaseLayer: function () { + for (const layer of this.baseLayers) { + if (this.hasLayer(layer)) return layer; + } }, getUrl: function (marker) {