Handling Geolocation¶
Any components in moxie-js-client can access the users location data through two different APIs found in the moxie.position module.
Follow/Unfollow - subscribe to updates¶
-
UserPosition.follow(callback)¶ Arguments: - callback (function) – a callback to be called each time the user position updates.
Start listening to user position updates.
-
UserPosition.unfollow(callback)¶ Arguments: - callback (function) – the callback already registered you want to remove from the listener
Stop listening to user position updates.
getLocation - one shot accurate position¶
-
UserPosition.getLocation(cb[, options])¶ Arguments: - callback (function) – a callback to be called once a good enough position has returned from the navigator APIs or the timeout has fired.
- options (object) – Optional paramters passed in this object include,
errorMarginspecify in meters how accurate a response you want returned by getLocation. Also atimeoutin ms how long should getLocation wait before returning the most recent result which didn’t meet theerrorMargincriteria.
Uses the phones most accurate capabilities to get a good position result within the specified paramaters.