feat(navi): copy popover + map-click pin drop with reverse geocode

Replaces Share button with Copy dropdown (Address / Coordinates).
Map single-click drops preview pin, opens PlaceDetail with
"Dropped pin" placeholder, reverse geocodes via /api/reverse to
fill in address. Stop-pin clicks preserved via flag ref. Escape
key closes PlaceDetail. Double-click zoom unaffected.

Phase 3 Step 5 C1.5 of Navi.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-04-20 21:27:07 +00:00
commit a819458865
3 changed files with 183 additions and 26 deletions

View file

@ -110,3 +110,34 @@ export async function fetchElevation(lat, lon) {
return null
}
}
const REVERSE_URL = "/api/reverse"
/**
* Reverse geocode a point. Returns a place object or null.
* @param {number} lat
* @param {number} lon
* @returns {Promise<{lat, lon, name, address, type, source, raw}|null>}
*/
export async function fetchReverse(lat, lon) {
try {
const params = new URLSearchParams({ lat: String(lat), lon: String(lon) })
const resp = await fetch(`${REVERSE_URL}?${params}`, { timeout: 5000 })
if (!resp.ok) return null
const data = await resp.json()
if (!data.results || data.results.length === 0) return null
const r = data.results[0]
return {
lat: r.lat,
lon: r.lon,
name: r.name,
address: null,
type: r.type,
source: r.source,
matchCode: null,
raw: r.raw || {},
}
} catch {
return null
}
}