Skip to main content
Version: 4.64

getLocation

Gets the current location or address by reverse geocoding if necessary. The latitude and longitude are available as eventParameters in the onSuccess event.

Field Configurations​

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters​

KeyTypeDescriptionDefault Value
"async"BooleanSpecifies whether the action should perform asynchronously.null
"getAddress"Boolean,StringIndicates whether the location should be reverse geocoded to an adddress.false
"maxAge"Number,StringThe maximum age for the location. No new location will be collected if there is an older one meeting the maxAge criteria.null
"onError"StringEvent that is fired in case of an error.null
"onErrorType"OnErrorTypeType of event that will be fired on error.null
"onSuccess" (required)StringEvent that is fired in case of success.null
"onSuccessType"OnSuccessTypeType of event that will be fired on success.null
"timeout"Number,StringThe action will throw an error if the timeout is exceeded.60

Inherited​

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples​

Example 1: Get the location​

Show ExampleHide Example

Get the device's current location.

{
"type": "getLocation",
"params": {
"onSuccess": "displayCoordinates",
"onError": "getLocationError"
}
}
The app showing the results of the sample code from Example 1.The app showing the results of the sample code from Example 1.

Example 2: Get the location's address​

Show ExampleHide Example

Get the device's current location reverse geocoded to the corresponding address.

{
"type": "getLocation",
"params": {
"getAddress": true,
"onSuccess": "displayAddress",
"onError": "getLocationError"
}
}
The app showing the results of the sample code from Example 1.The app showing the results of the sample code from Example 1.