Refactoring: fix background layer switch and hotkeys

This commit is contained in:
Pieter Vander Vennet 2023-04-21 17:37:50 +02:00
parent c2b9a81c51
commit 23b26c4197
5 changed files with 44 additions and 64 deletions

View file

@ -23,20 +23,24 @@ export default class BackgroundLayerResetter {
availableLayers.addCallbackAndRunD((availableLayers) => {
// We only check on move/on change of the availableLayers
const currentBgPolygon: RasterLayerPolygon | undefined = currentBackgroundLayer.data
if (currentBackgroundLayer === undefined) {
return
}
if (availableLayers.findIndex((available) => currentBgPolygon == available) >= 0) {
// Still available!
return
}
console.log("Current layer properties:", currentBgPolygon)
// Oops, we panned out of range for this layer!
// What is the 'best' map of the same category which is available?
const availableInSameCat = RasterLayerUtils.SelectBestLayerAccordingTo(
availableLayers,
currentBgPolygon?.properties?.category ?? "osmbasedmap"
currentBgPolygon?.properties?.category
)
console.log("Selecting a different layer:", availableInSameCat.properties.id)
currentBackgroundLayer.setData(availableInSameCat ?? AvailableRasterLayers.osmCarto)
currentBackgroundLayer.setData(availableInSameCat)
})
}
}

View file

@ -71,7 +71,7 @@ export default class MetaTagging {
return
}
console.trace("Recalculating metatags...")
console.debug("Recalculating metatags...")
const metatagsToApply: SimpleMetaTagger[] = []
for (const metatag of SimpleMetaTaggers.metatags) {
if (metatag.includesDates) {