feat(map): restore point-detail panel across navigation
This commit is contained in:
parent
e2168c922e
commit
52ce44d738
1 changed files with 31 additions and 0 deletions
|
|
@ -862,6 +862,7 @@ export const PropagationMap: Record<string, unknown> & {
|
|||
|
||||
// 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<string, unknown> & {
|
|||
}
|
||||
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<string, unknown> & {
|
|||
this.clickedLatLng = null
|
||||
this.reachPolygon = null
|
||||
this.lastDetail = null
|
||||
localStorage.removeItem("propagationMap.clickedPoint")
|
||||
},
|
||||
|
||||
// Redraws the propagation reach polygon around the currently-clicked
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue