feat(weather-map): persist selected layer across navigation

This commit is contained in:
Graham McIntire 2026-04-20 14:49:39 -05:00
parent 7244a59a21
commit fc7481dca2
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -392,6 +392,12 @@ export const WeatherMap: WeatherMapHook = {
this.gridLookup = new Map()
this.selectedLayer = (this.el.dataset.selectedLayer || "refractivity_gradient") as LayerId
const storedLayer = localStorage.getItem("weatherMap.selectedLayer")
if (storedLayer && storedLayer in COLOR_SCALES && storedLayer !== this.selectedLayer) {
this.selectedLayer = storedLayer as LayerId
this.pushEvent("select_layer", { layer: storedLayer })
}
const initialData: WeatherPoint[] = JSON.parse(this.el.dataset.weather || "[]")
if (initialData.length > 0) {
this.weatherData = initialData
@ -526,6 +532,7 @@ export const WeatherMap: WeatherMapHook = {
const newLayer = this.el.dataset.selectedLayer as LayerId | undefined
if (newLayer && newLayer !== this.selectedLayer) {
this.selectedLayer = newLayer
localStorage.setItem("weatherMap.selectedLayer", newLayer)
this.renderLayer()
}
})