From fafbf5e6b36476f5bd65b47a4f36d3082e7602d6 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 23 Jan 2021 18:11:42 +1100 Subject: [PATCH] fix fragility toggle mapControl was declared as a const instead of a var, which prevented switchMode() from working properly. This fixes that by using var rather than const, and also moves the Controls and initial layer declarations above switchMode() so we don't have to rely on hoisting to use variables declared later. Fixes #16 --- website/load-map.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/website/load-map.js b/website/load-map.js index 5cf0314..599abb0 100644 --- a/website/load-map.js +++ b/website/load-map.js @@ -319,6 +319,24 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches]) setGeneral() } + // add control layers + var mapControl = L.control.layers( + baseMaps, + overlayMaps, + { "collapsed" : false } + ).addTo(map); + + // scale + L.control.scale().addTo(map); + + // info boxes + const infoBoxes = { + branches: L.control(), + fines: L.control(), + loanPeriod: L.control(), + serviceInfo: L.control({position: 'topleft'}) + } + // switching mode between standard and fragile function switchMode() { if (sessionStorage.getItem('mapMode') === 'fragile') { @@ -340,24 +358,6 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches]) modeButton.addEventListener('click', switchMode, false); - // add control layers - const mapControl = L.control.layers( - baseMaps, - overlayMaps, - { "collapsed" : false } - ).addTo(map); - - // scale - L.control.scale().addTo(map); - - // info boxes - const infoBoxes = { - branches: L.control(), - fines: L.control(), - loanPeriod: L.control(), - serviceInfo: L.control({position: 'topleft'}) - } - function getFinesColor(f) { return f == 'no' ? '#4dac26' : f == 'yes' ? '#d01c8b' :