]> git.openstreetmap.org Git - rails.git/commitdiff
Make sure we always have a base layer
authorTom Hughes <tom@compton.nu>
Mon, 9 Sep 2013 17:30:27 +0000 (18:30 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 9 Sep 2013 17:30:27 +0000 (18:30 +0100)
app/assets/javascripts/index.js

index a19a6a61e5c714b318b2d55441ab3b2332e2b1d8..95771a4b2ae4645416ac0e26bcfb3f9e229330c5 100644 (file)
@@ -53,14 +53,20 @@ $(document).ready(function () {
 
   function updateLayers(params) {
     var layerParam = params.layers || "M";
+    var layersAdded = "";
 
     for (var i = layers.length - 1; i >= 0; i--) {
       if (layerParam.indexOf(layers[i].options.code) >= 0) {
         map.addLayer(layers[i]);
+        layersAdded = layersAdded + layers[i].options.code;
       } else {
         map.removeLayer(layers[i]);
       }
     }
+
+    if (layersAdded == "") {
+      map.addLayer(layers[0]);
+    }
   }
 
   updateLayers(params);