From abab5f54406404f754cae7a24c44d0417cf5b812 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 3 Jul 2016 14:54:14 +0100 Subject: [PATCH] Fix initial baselayer selection if no type was stored. --- public_html/script.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public_html/script.js b/public_html/script.js index 2977d7a..e954e46 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -366,7 +366,14 @@ function initialize_map() { }) if (!foundType) { - layers[0].setVisible(true); + ol.control.LayerSwitcher.forEachRecursive(layers, function(lyr) { + if (foundType) + return; + if (lyr.get('type') === 'base') { + lyr.setVisible(true); + foundType = true; + } + }); } var iconsLayer = new ol.layer.Vector({