getAccurateCurrentPosition
getAccurateCurrentPosition copied to clipboard
Improvements
Thank you for your nice library. I was implementing roughly the same ideas, but it is much cleaner doing it by extending navigator.geolocation than polluting my proper code...
I wanted to make some improvements however:
- Use bestCheckedPostion instead of lastCheckedPosition,
- Always call geoprogress (also the last one)
- Dont force maximumAge. Can be set optionally
- New Option countMin, which is defaulted to 2 (exactly as it was)
- Check Options with isNaN() to allow for 0 (would be overwritten otherwise)
- New Option enableLowAccuracyOnTimeout (calls getCurrentPosition with lowAccuracy doubling timeout)
- New Option desiredAccuracyCountMin, so we can wait just a little bit longer for an even better result (maxWait is unaffected)
Everything is backwards compatible but
- not lastCheckedPosition but bestCheckedPosition is returned
- geoprogress is called one more time (along with the result)
I replaced enabelLowAccuracyOnTimeout by enableLowAccuracy, which starts a low accuracy getCurrentPosition simultaneously. However, this idea is at least not honored on Lollipop and Chrome 43.
http://stackoverflow.com/questions/17804469/html5-geolocation-ignores-enablehighaccuracy-option/32521789
Its a pitty, because instead of returning no position at all I would have liked at least the roughest idea of the position...
Maybe someone has a better idea?