]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.map.js
Merge remote-tracking branch 'upstream/pull/5420'
[rails.git] / app / assets / javascripts / leaflet.map.js
index 02ed318acffc89eded8d0dccad99a682c8e2d05f..6537b0b233568ada1988c56d6c215789864a8f30 100644 (file)
@@ -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) {