From fc7481dca2964e80657f5b72f6b5738b467be8ba Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 20 Apr 2026 14:49:39 -0500 Subject: [PATCH] feat(weather-map): persist selected layer across navigation --- assets/js/weather_map_hook.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/assets/js/weather_map_hook.ts b/assets/js/weather_map_hook.ts index 9999ac16..ee3c63df 100644 --- a/assets/js/weather_map_hook.ts +++ b/assets/js/weather_map_hook.ts @@ -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() } })