Skip to content

Refine current location until it is GPS-accurate - #139

Merged
wcornwell merged 1 commit into
masterfrom
better-current-location
Nov 12, 2026
Merged

wcornwell merged 1 commit into
masterfrom
better-current-location

Conversation

@wcornwell

Copy link
Copy Markdown
Collaborator

'Use current location' was often rough. The app took the first fix the browser gave, and allowed a cached fix up to a minute old. On a phone that first fix usually comes from Wi-Fi or cell towers (±hundreds of m to km). The GPS fix arrives a few seconds later.

Change (web/js/app.js, locate()):

  • Uses watchPosition with enableHighAccuracy: true and maximumAge: 0, and keeps the best fix.
  • Rebuilds the list on the first fix, then only when the error shrinks by 25% or more.
  • Shows "Refining your location… ±N m so far" while it waits.
  • Stops at ±30 m or after 20 s, whichever comes first, and keeps the best fix it got.
  • If an error arrives after a fix, it keeps that fix. Permission denied still shows the error.
  • Warns when the error is more than half the chosen radius, with a hint to turn on precise location (phone) or that the location is only an estimate (laptop). The warning updates when the radius changes.

Some limits remain: laptops have no GPS, and iOS blurs the location to about 1–3 km when Precise Location is off.

New behaviour, not part of the Shiny port. (The Shiny app built high-accuracy options but never passed them to getCurrentPosition.)

Tested: a Node harness that fakes watchPosition (fix improves to GPS, stays coarse until timeout, permission denied, error after a fix, no fix at all). Not yet tried on a real phone.

🤖 Generated with Claude Code

… rough

A phone's first fix usually comes from Wi-Fi or cell towers; the GPS fix
arrives seconds later. Watch the position for up to 20 s, keep the best
fix, stop at 30 m or better, and never accept a cached fix. Warn when the
error is more than half the chosen radius.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wcornwell
wcornwell merged commit 9ad4794 into master Nov 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant