getLocation
Description
Get the current location details (GPS coordinate) of the device.
Input / Parameter
timeout
Connection time out period, in millisecond.
Number
-
-
-
enableHighAccuracy
To enable or disable high accuracy of GPS coordinates.
Boolean
False
-
-
Output
Returns the formatted information.
Object
Object
success
Boolean value to denote whether the function was executed successfully.
Text
message
The message to print.
Text
data
Any additional message or data to print.
Text
Callback
callback
The function to be executed when location is obtained successfully.
errorCallback
The function to be executed when location is not obtained successfully.
Example
In this example, we will retrieve the device location data and use it as the coordinate value of the setMapCenter
function.
Steps
Drag a
map
component and abutton
component to a page in the mobile designer.Select the event
press
for the button and drag the functionDevice.getLocation
to the event flow. Fill in the parameters of the function.Drag the function to be executed if the location data is successfully received to the node below
Device.getLocation
. In this example, we are using theVariable.set
function to save the location data into a variable.Drag the function
Device.setMapCenter
belowVariable.set
and fill in the parameters of the function. Use the location data fromDevice.getLocation
by addingVariable.getAttribute
to thecoordinate
field of theDevice.setMapCenter
function.
Result
The location data will be received and it's
latLng
value (latitude and longitude) will be used as the center of the Map component.
Last updated