X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/0c2d538aa7394b3d040cbe40cc6b3f5d26de4850..ba5107ebb543a396fc78069c75c431e4d3887ee1:/app/assets/javascripts/map.js.erb diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index 393e9cae7..291633f53 100644 --- a/app/assets/javascripts/map.js.erb +++ b/app/assets/javascripts/map.js.erb @@ -95,6 +95,7 @@ function createMap(divName, options) { if (options.layerControl) { layersControl.addTo(map); + map.layersControl = layersControl; } for (var i = 0; i < layers.length; i++) { @@ -184,11 +185,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); + } }