diff --git a/assets/js/propagation_map_hook.ts b/assets/js/propagation_map_hook.ts index a2e30842..6ec997d8 100644 --- a/assets/js/propagation_map_hook.ts +++ b/assets/js/propagation_map_hook.ts @@ -862,6 +862,7 @@ export const PropagationMap: Record & { // Remember click location for the center marker this.clickedLatLng = [e.latlng.lat, e.latlng.lng] + localStorage.setItem("propagationMap.clickedPoint", JSON.stringify(this.clickedLatLng)) // Show a temporary marker while computing L.circleMarker(this.clickedLatLng, { @@ -903,6 +904,35 @@ export const PropagationMap: Record & { } this.lastDetail = null + // Restore a previously-clicked point across page navigation: replay the + // click side-effects so the user lands back on the same detail panel + // they had open, with fresh server-side factors + viewshed. + const storedPoint = localStorage.getItem("propagationMap.clickedPoint") + if (storedPoint) { + try { + const parsed = JSON.parse(storedPoint) + if (Array.isArray(parsed) && typeof parsed[0] === "number" && typeof parsed[1] === "number") { + const [lat, lon] = parsed as [number, number] + this.clickedLatLng = [lat, lon] + this.viewshedLoading = true + L.circleMarker([lat, lon], { + radius: 6, color: "#fff", weight: 2, + fillColor: "#888", fillOpacity: 0.8, interactive: false + }).addTo(this.rangeCircles) + this.pushEvent("compute_viewshed", { lat, lon }) + const basic = this.lookupPoint(lat, lon) + if (basic && this.detailPanel) { + const merged = { ...basic, ...this.bandInfo, factors: null } as unknown as PointDetail + this.detailPanel.innerHTML = buildLoadingHTML(merged) + this.showDetailPanel() + } + this.pushEvent("point_detail", { lat, lon }) + } + } catch { + localStorage.removeItem("propagationMap.clickedPoint") + } + } + this.handleEvent("rain_scatter_update", ({ rain_scatter }: { lat: number; lon: number; rain_scatter: RainScatter }) => { if (!this.lastDetail || !this.detailPanel) return this.lastDetail.rain_scatter = rain_scatter @@ -1080,6 +1110,7 @@ export const PropagationMap: Record & { this.clickedLatLng = null this.reachPolygon = null this.lastDetail = null + localStorage.removeItem("propagationMap.clickedPoint") }, // Redraws the propagation reach polygon around the currently-clicked