feat(weather-map): persist selected layer across navigation
This commit is contained in:
parent
7244a59a21
commit
fc7481dca2
1 changed files with 7 additions and 0 deletions
|
|
@ -392,6 +392,12 @@ export const WeatherMap: WeatherMapHook = {
|
||||||
this.gridLookup = new Map()
|
this.gridLookup = new Map()
|
||||||
this.selectedLayer = (this.el.dataset.selectedLayer || "refractivity_gradient") as LayerId
|
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 || "[]")
|
const initialData: WeatherPoint[] = JSON.parse(this.el.dataset.weather || "[]")
|
||||||
if (initialData.length > 0) {
|
if (initialData.length > 0) {
|
||||||
this.weatherData = initialData
|
this.weatherData = initialData
|
||||||
|
|
@ -526,6 +532,7 @@ export const WeatherMap: WeatherMapHook = {
|
||||||
const newLayer = this.el.dataset.selectedLayer as LayerId | undefined
|
const newLayer = this.el.dataset.selectedLayer as LayerId | undefined
|
||||||
if (newLayer && newLayer !== this.selectedLayer) {
|
if (newLayer && newLayer !== this.selectedLayer) {
|
||||||
this.selectedLayer = newLayer
|
this.selectedLayer = newLayer
|
||||||
|
localStorage.setItem("weatherMap.selectedLayer", newLayer)
|
||||||
this.renderLayer()
|
this.renderLayer()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue