getCurrentPosition


Purpose

Passes the device's current position. When called, it returns the initial Position object, which describes the device's current location.

If the attempt is successful, the successCallback method is called periodically, depending on the settings defined in the options parameter, with a new Position object. If the attempt fails, the errorCallback method is invoked with a new PositionError object, reflecting the reason for the failure.

Signature

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

Returns

The method returns and then asynchronously attempts to obtain the current location of the device.

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 © 2019 and Confidential to Pegasystems Inc. All rights reserved
Pega Community | Feedback
Advanced...