Skip to content

feat: "use my location" on maidenhead converter and channel editor #59

Description

@pskillen

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

  1. Channel edit → Use my location → lat/lon populate, locator updates, map centres, Use Location checked.
  2. Deny permission → clear error message; form still usable.
  3. Maidenhead converter → same button → fields and map update.
  4. Save channel → coords persist after reload.

Workflow note

Branch from origin/main, atomic conventional commits (hook → channel edit → converter → docs), PR linking Closes #59.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions