minimum accuracy before showing GeolocateControl dot
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
The default `GeolocateControl` shows the viewer's position as reported by `navigator.geolocation.watchPosition` immediately, but this often has a very high margin of error. The dot is often in the wrong location, which can be confusing or even dangerous depending on the application.
## Design Alternatives
An even better design would be to show the dot with the radius of confusion as a circle around it (common design pattern in many driving/aviation applications).
## Design
A simpler edit is to allow the user to provide a "minimum accuracy" in meters, and ignore `watchPosition` calls that do not meet this level of accuracy.
### Mock-Up
Will look the same visually, but the geolocation dot will only show once the minimum gps accuracy is met.
### Concepts
New concept is a minimum GPS accuracy, should be documented at https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/control/geolocate_control.js#L77-L81
### Implementation
`navigator.geolocation.watchPosition` already returns an accuracy value (in meters) as `position.coords.accuracy` (see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates)
The `_onSuccess` function of `GeolocateControl` can easily be updated to ignore position events below a threshold accuracy: https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/control/geolocate_control.js#L184
A minimum accuracy can be provided as an optional configuration at https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/control/geolocate_control.js#L14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/ui/control/geolocate_control.js, especially the configuration documentation near lines 77-81 and the _onSuccess function near line 184. Check how GeolocateControl options are defined near line 14 and inspect existing control tests before making changes. Done means an optional minimum accuracy is documented and position updates below that threshold do not show the geolocation dot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100