keep infoboxes regardless of overlays active

This does not apply on smaller screens, where we hide the infoboxes

fixes #9
This commit is contained in:
Hugh Rundle 2021-01-24 12:53:55 +11:00
parent bd664dd17d
commit 8c99dfc3fa

View file

@ -509,27 +509,9 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
)} )}
} }
// remove info boxes & markers when relevant layer is removed // loan period layer is always at bottom
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
map.on('overlayadd', l => { map.on('overlayadd', l => {
if (l.name == "Fines") {
if (!isSmallScreen) {
infoBoxes.fines.addTo(map)
}
}
if (l.name == "Loan Period") { if (l.name == "Loan Period") {
if (!isSmallScreen) {
infoBoxes.loanPeriod.addTo(map)
}
loanPeriod.bringToBack() loanPeriod.bringToBack()
} }
}) })
@ -551,6 +533,10 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
mapControl.removeLayer(overlayMaps[i]) mapControl.removeLayer(overlayMaps[i])
overlayMaps[i].remove() 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 modeButton.setAttribute('class', 'hidden'); // hide the mode button when it's not relevant
} else { } else {
mapControl.removeLayer(fines) mapControl.removeLayer(fines)