Problem
Setting a channel or converter location today requires manual coordinate entry, Maidenhead input, map click, or address geocoding. There is no way to seed coordinates from the operator's current device position — useful when programming a hotspot or simplex channel at the current QTH.
The channel edit page (src/routes/channels/edit.tsx) and the Maidenhead converter (src/routes/reference/maidenhead.tsx) both support map pick and (on the converter) address lookup, but neither uses the browser Geolocation API.
Intended outcome
Add a Use my location button that reads the device position and populates the location fields.
Surfaces
| Surface |
Behaviour |
Channel edit (/channels/:id/edit) |
Set lat/lon, derive 6-char locator, set useLocation true; move map marker |
Maidenhead converter (/reference/maidenhead) |
Set lat/lon and locator at current precision; centre MapLocationPicker on result |
UX
- Button label: Use my location (or compact variant with crosshairs icon + accessible label).
- Show loading state while
navigator.geolocation.getCurrentPosition (or watchPosition with immediate clear) is pending.
- On success: apply coordinates via existing helpers (
applyCoords on channel edit; shared coord/locator sync on converter).
- On failure: inline error — permission denied, position unavailable, timeout, insecure context (non-HTTPS). Do not throw; do not block the rest of the form.
- Optional: display reported accuracy (e.g. "±12 m") as dimmed helper text when the browser provides it.
Implementation notes
- Extract a small hook or util, e.g.
src/hooks/useGeolocation.ts or src/lib/geolocation.ts, wrapping the Geolocation API with typed errors.
- Reuse
coordsToLocator from src/lib/maidenhead.ts — do not duplicate conversion math.
- Channel edit: coordinate with existing location section (
applyCoords, map onLocationPick).
- No server round-trip; position never leaves the browser except via existing localStorage persistence when the channel is saved.
Privacy
- Geolocation requires explicit user gesture (button click) and browser permission prompt.
- Document in
docs/features/maidenhead.md that device location is used only on demand, not tracked continuously.
Affected
src/routes/channels/edit.tsx — Location section button
src/routes/reference/maidenhead.tsx — button near map / coordinates
- New
useGeolocation hook or geolocation.ts helper
docs/features/maidenhead.md — geolocation behaviour
- Optionally
src/components/MapLocationPicker/MapLocationPicker.md if button is shared
Notes / dependencies
Out of scope
- Continuous location tracking / watch mode for live updates.
- Setting operator home QTH in Settings as a default for all new channels.
- Mobile-specific UI beyond standard responsive layout.
Manual verify
- Channel edit → Use my location → lat/lon populate, locator updates, map centres,
Use Location checked.
- Deny permission → clear error message; form still usable.
- Maidenhead converter → same button → fields and map update.
- Save channel → coords persist after reload.
Workflow note
Branch from origin/main, atomic conventional commits (hook → channel edit → converter → docs), PR linking Closes #59.
Problem
Setting a channel or converter location today requires manual coordinate entry, Maidenhead input, map click, or address geocoding. There is no way to seed coordinates from the operator's current device position — useful when programming a hotspot or simplex channel at the current QTH.
The channel edit page (
src/routes/channels/edit.tsx) and the Maidenhead converter (src/routes/reference/maidenhead.tsx) both support map pick and (on the converter) address lookup, but neither uses the browser Geolocation API.Intended outcome
Add a Use my location button that reads the device position and populates the location fields.
Surfaces
/channels/:id/edit)useLocationtrue; move map marker/reference/maidenhead)MapLocationPickeron resultUX
navigator.geolocation.getCurrentPosition(orwatchPositionwith immediate clear) is pending.applyCoordson channel edit; shared coord/locator sync on converter).Implementation notes
src/hooks/useGeolocation.tsorsrc/lib/geolocation.ts, wrapping the Geolocation API with typed errors.coordsToLocatorfromsrc/lib/maidenhead.ts— do not duplicate conversion math.applyCoords, maponLocationPick).Privacy
docs/features/maidenhead.mdthat device location is used only on demand, not tracked continuously.Affected
src/routes/channels/edit.tsx— Location section buttonsrc/routes/reference/maidenhead.tsx— button near map / coordinatesuseGeolocationhook orgeolocation.tshelperdocs/features/maidenhead.md— geolocation behavioursrc/components/MapLocationPicker/MapLocationPicker.mdif button is sharedNotes / dependencies
localhostis usually fine; GitHub Pages HTTPS is fine).Out of scope
Manual verify
Use Locationchecked.Workflow note
Branch from
origin/main, atomic conventional commits (hook → channel edit → converter → docs), PR linkingCloses #59.