From e2168c922e394ebb3011dd6cd64446e24c9599c4 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 20 Apr 2026 14:53:17 -0500 Subject: [PATCH] feat(maps): persist grid and radar overlay toggles across navigation --- assets/js/propagation_map_hook.ts | 10 ++++++++++ assets/js/weather_map_hook.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/assets/js/propagation_map_hook.ts b/assets/js/propagation_map_hook.ts index 9d8bd88d..a2e30842 100644 --- a/assets/js/propagation_map_hook.ts +++ b/assets/js/propagation_map_hook.ts @@ -801,6 +801,7 @@ export const PropagationMap: Record & { // Listen for grid toggle from LiveView this.handleEvent("toggle_grid", ({ visible }: { visible: boolean }) => { this.gridVisible = visible + localStorage.setItem("propagationMap.gridVisible", String(visible)) if (visible) { this.gridLayer.addTo(this.map) updateGridOverlay(this.map, this.gridLayer) @@ -809,12 +810,17 @@ export const PropagationMap: Record & { } }) + if (localStorage.getItem("propagationMap.gridVisible") === "true") { + this.pushEvent("toggle_grid", {}) + } + // Weather radar overlay (ECCC GeoMet WMS — CONUS + Canada composite dBZ). // Lazy-created on first toggle so we don't hit the service until asked. this.radarLayer = null this.radarRefreshTimer = null this.handleEvent("toggle_radar", ({ visible }: { visible: boolean }) => { + localStorage.setItem("propagationMap.radarVisible", String(visible)) if (visible) { if (!this.radarLayer) { this.radarLayer = L.tileLayer.wms("https://geo.weather.gc.ca/geomet", { @@ -844,6 +850,10 @@ export const PropagationMap: Record & { } }) + if (localStorage.getItem("propagationMap.radarVisible") === "true") { + this.pushEvent("toggle_radar", {}) + } + // Click on map to request viewshed + factor detail from server this.map.on("click", (e: L.LeafletMouseEvent) => { this.rangeCircles.clearLayers() diff --git a/assets/js/weather_map_hook.ts b/assets/js/weather_map_hook.ts index ee3c63df..7ab44ca1 100644 --- a/assets/js/weather_map_hook.ts +++ b/assets/js/weather_map_hook.ts @@ -466,6 +466,7 @@ export const WeatherMap: WeatherMapHook = { this.handleEvent("toggle_grid", ({ visible }: { visible: boolean }) => { this.gridVisible = visible + localStorage.setItem("weatherMap.gridVisible", String(visible)) if (visible) { this.gridLayer.addTo(this.map) updateGridOverlay(this.map, this.gridLayer) @@ -474,12 +475,17 @@ export const WeatherMap: WeatherMapHook = { } }) + if (localStorage.getItem("weatherMap.gridVisible") === "true") { + this.pushEvent("toggle_grid", {}) + } + // Weather radar overlay (ECCC GeoMet WMS — CONUS + Canada composite dBZ). // Lazy-created on first toggle so we don't hit the service until asked. this.radarLayer = null this.radarRefreshTimer = null this.handleEvent("toggle_radar", ({ visible }: { visible: boolean }) => { + localStorage.setItem("weatherMap.radarVisible", String(visible)) if (visible) { if (!this.radarLayer) { this.radarLayer = L.tileLayer.wms("https://geo.weather.gc.ca/geomet", { @@ -509,6 +515,10 @@ export const WeatherMap: WeatherMapHook = { } }) + if (localStorage.getItem("weatherMap.radarVisible") === "true") { + this.pushEvent("toggle_radar", {}) + } + requestAnimationFrame(() => this.sendBounds()) this.map.on("moveend", () => { this.sendBounds()