feat(maps): persist grid and radar overlay toggles across navigation
This commit is contained in:
parent
fc7481dca2
commit
e2168c922e
2 changed files with 20 additions and 0 deletions
|
|
@ -801,6 +801,7 @@ export const PropagationMap: Record<string, unknown> & {
|
|||
// 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<string, unknown> & {
|
|||
}
|
||||
})
|
||||
|
||||
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<string, unknown> & {
|
|||
}
|
||||
})
|
||||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue