From 8c99dfc3fa04cba934b8decfc7a78d64becfd0ea Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 24 Jan 2021 12:53:55 +1100 Subject: [PATCH] keep infoboxes regardless of overlays active This does not apply on smaller screens, where we hide the infoboxes fixes #9 --- website/load-map.js | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/website/load-map.js b/website/load-map.js index 7c909e7..f34485a 100644 --- a/website/load-map.js +++ b/website/load-map.js @@ -509,27 +509,9 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches]) )} } - // remove info boxes & markers when relevant layer is removed - map.on('overlayremove', l => { - if (l.name == "Fines") { - infoBoxes.fines.remove() - } - if (l.name == "Loan Period") { - infoBoxes.loanPeriod.remove() - } - }) - - // add info boxes & markers when relevant layer is added + // loan period layer is always at bottom map.on('overlayadd', l => { - if (l.name == "Fines") { - if (!isSmallScreen) { - infoBoxes.fines.addTo(map) - } - } if (l.name == "Loan Period") { - if (!isSmallScreen) { - infoBoxes.loanPeriod.addTo(map) - } loanPeriod.bringToBack() } }) @@ -551,6 +533,10 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches]) mapControl.removeLayer(overlayMaps[i]) overlayMaps[i].remove() } + if (!isSmallScreen) { // only add infoboxes to larger screens + infoBoxes.loanPeriod.addTo(map) + infoBoxes.fines.addTo(map) + } modeButton.setAttribute('class', 'hidden'); // hide the mode button when it's not relevant } else { mapControl.removeLayer(fines)