mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-20 22:54:42 +02:00
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:
parent
02f2b25db3
commit
a819458865
3 changed files with 183 additions and 26 deletions
31
src/api.js
31
src/api.js
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue