standard.getGeolocation
Returns the Global Positioning System (GPS) location of a device.
Syntax
ui.Interface.frontCall("standard", "getGeolocation",
[], [status, latitude, longitude] )
- status - Holds the status of the front call execution.
- latitude - Holds the current latitude.
- longitude - Holds the current longitude.
Usage
The "getGeolocation
" front call returns the current location of the device,
based on the current GPS information.
To be usable with GBC, this front call needs a secure context / front-end connection, in addition to mobile device permissions, when required. A secure context is achieved by using the GAS via HTTPS, via localhost on the same machine, or running direct via GDC-UR. When using GDC-UR, additional security settings need to be enabled in the GDC configuration panel. See GDC documentation for more details.
For GMA / Androidâ„¢,
using the getGeolocation
front call needs the
android.permission.ACCESS_FINE_LOCATION
and
android.permission.ACCESS_COARSE_LOCATION
Dangerous Permissions to be specified
when building the APK.
See Android permissions
for more details.
- "
ok
": The device location was found. - In case of failure, the status variable contains the error description, for example,
"
location services not enabled
".
It is recommended that the returned coordinates are stored in FLOAT
variables.
If the device's location cannot be found within a given period, the front call returns an error status.
Example
DEFINE status STRING, latitude, longitude FLOAT
CALL ui.Interface.frontCall("standard", "getGeolocation",
[], [status, latitude, longitude] )
MESSAGE SFMT(
"Geo location: (status=%1) Latitude=%2 Longitude=%3",
status, latitude, longitude )