From: Tom Hughes Date: Mon, 2 Jun 2008 12:45:24 +0000 (+0000) Subject: Don't try and parse an empty string as a layer config, and cope a bit X-Git-Tag: live~7855 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c25a20ff133d0ff9c865ac2cbc0076544cb4f16b?hp=48000eb09ad072e83789c1efb002c259222ae91a Don't try and parse an empty string as a layer config, and cope a bit better if we do hit the end of the string. Closes #942. --- diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index d6247158d..3e0400ce4 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -109,7 +109,7 @@ by the OpenStreetMap project and its contributors. setMapCenter(centre, zoom); <% end %> - <% if layers %> + <% if !layers.empty? %> setMapLayers("<%= layers %>"); <% end %> diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 7591d7d16..9f9be0987 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -155,7 +155,11 @@ function setMapLayers(layerConfig) { for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { var c = layerConfig.charAt(l++); - layers[i].setVisibility(c == "T"); + if (c == "T") { + layers[i].setVisibility(true); + } else if(c == "F") { + layers[i].setVisibility(false); + } } }