Capture GPS Locations
GPS locations can be captured in the foreground (i.e. the user can see that the location is being captured), in the background using the capture-coordinates component or recorded over time as a track.
To use the capture-coordinates component, you need to define a field or variable with type location.
To record GPS tracks you need to define a field with type track.
Capture a single GPS location
To capture a single GPS location in the foreground or background, please refer to the documentation on capture-coordinates:
Accessing GPS Information from JavaScript/TypeScript or Format Strings
These properties of a GPS location variable or field can be accessed from JavaScript/TypeScript and Format Strings, but cannot be modified:
latitudelongitudealtitudehorizontal_accuracyvertical_accuracytimestamp
Limitation
Capturing the altitude and/or vertical_accuracy is not supported on several platforms / devices, including Android devices. These devices will return null for these fields.
Example — Accessing GPS Information from JavaScript
Example — Accessing GPS Information from Format Strings
Recording GPS Tracks
GPS tracks are recorded to a data model field of type track.
The Track.start({'highFrequency': true}) method will start a track in high-frequency update mode (maximum update rate of 10 seconds) and return the track ID which should be saved to a field of type track. Calling Track.start({'highFrequency': false}) will record in low-frequency update mode (maximum update rate of 1 minute).
The Track.stop() method will stop the track recording.
The Track.isTracking() method will return a boolean, indicating if a track is in progress.
Common background tracking issues
Background tracking may not work in the following cases:
The correct permissions to track location in the background have been disabled.
If the app is "force-closed" or the OS has closed the app in the background. I.e. the app is no longer running in the background.
The device has a form of battery saver mode enabled.
Example — Recording GPS Tracks
The following example shows how to start and stop GPS track recording.
Data model XML:
View XML:
View JavaScript:
Last updated