promised-location
Promise-compatible version of navigator.geolocation. Compatible with react native!
Usage
PromisedLocation
works like navigator.geolocation.getCurrentPosition
, except instead of supplying callbacks for the success
and error
scenarios, you handle a standard Promise
. Call new PromisedLocation
with PositionOptions
, then handle like any other promise with then
and catch
.
var PromisedLocation = ; var options = enableHighAccuracy: true timeout: 10000 maximumAge: 60000; var locator = options;locator ;
FAQ
- What if my browser/environment doesn't support geolocation?
The returned Promise
will be rejected.
- What are the default values for
PositionOptions
?
Default PositionOptions
are the same as the Web API, namely:
enableHighAccuracy: false timeout: Infinity maximumAge: 0
Questions? Comments? Fixes?
File an issue or submit a pull request!