]> git.openstreetmap.org Git - rails.git/commitdiff
Fall back to the mapnik layer
authorTom Hughes <tom@compton.nu>
Fri, 23 Nov 2012 19:00:51 +0000 (19:00 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 23 Nov 2012 19:00:51 +0000 (19:00 +0000)
If there are no known layers in the layers string, then fall back to
showing the standard mapnik layer.

app/assets/javascripts/map.js.erb

index 393e9cae7d3e88f3b3a01b718e084fe37a8934e2..9df9ca2d99cc7b435ad586699ec10b9e6f826435 100644 (file)
@@ -184,11 +184,16 @@ function getMapLayers() {
 }
 
 function setMapLayers(layerConfig) {
+  var foundLayer = false;
   for (var i = 0; i < layers.length; i++) {
     if (layerConfig.indexOf(layers[i].layerCode) >= 0) {
       map.addLayer(layers[i].layer);
+      foundLayer = true;
     } else {
       map.removeLayer(layers[i].layer);
     }
   }
+  if (!foundLayer) {
+    map.addLayer(layers[0].layer);
+  }
 }