API Reference - ninjatronic/ngGeolocation GitHub Wiki

Methods

$geolocation.getCurrentPosition(options)

Asynchronously attempts to obtain the current location of the device.

Parameters

options - A PositionOptions object

Returns

A promise, resolved with a Position object or rejected with a PositionError object.

$geolocation.watchPosition(options)

Asynchronously begins a watch operation which monitors the position of the device and update $geolocation.position every time this position changes. If a watch operation is already in progress, this method does nothing.

Parameters

options - A PositionOptions object

Events

  • $geolocation.position.changed - fired when the user's position have been updated
  • $geolocation.position.error - fired when getting the position resulted in an error

$geolocation.clearWatch()

Cancels the current watch operation. If there is no current watch operation this method does nothing.

Properties

$geolocation.position

This property is kept up to date if there is a watch operation in progress. If the last update was successful then it is populated with the most recently available Position. If the last update was not successfull $geolocation.position.error is populated with the relevant PositionError object.