watchPosition


Purpose

This method returns the watchId value that uniquely identifies a watch operation. Then it asynchronously starts the watch operation, which first attempts to obtain the current location of the device.

If the attempt is successful, the successCallback method is invoked with a new Position object. If the attempt fails, the errorCallback method is called with a new PositionError object. The watch operation then continues to monitor the position of the device and invokes the appropriate callback periodically, depending on the settings defined in the options parameter, until the clearWatch method is called.

Signature

navigator.geolocation.watchPosition(successCallback, errorCallback, options)

Returns

The method returns the watchId long value that uniquely identifies a watch operation.

Parameter

Name Description Type Use
successCallback A callback function called to pass the device's current position. function required
errorCallback A callback function called to pass an error. function optional
options A PositionOptions object, used to configure the API's responsiveness. Refer to the object's description for default values of individual parameters. object optional

The table below lists the parameters supported by the successCallback callback.

Parameter Description Type
Position The geolocation position returned by the device through a callback function. object

The table below lists the parameters supported by the errorCallback callback.

Parameter Description Type
PositionError Geolocation error object returned through a callback function. object

Related topics

Geolocation
Public API reference
Legal notice | Copyright © 2017 and Confidential to Pegasystems Inc. All rights reserved
PDN | Pega Mobile Client | Feedback
Advanced...