Display the current GPS info on the form

Use this example to display the current GPS info on your form.

This example shows how you can display the current GPS data within your form using the CURRENTLOCATION and SETLABEL functions. For the below example to work, add a Label field and set its label to GPS Info so that we can reference it in the Data Events script as gps_info.

GPS Info Example

ON('load-record', function(event) {
  var updateLocationInfo = function() {
    // get the current device location
    var location = CURRENTLOCATION();

    // if there is no location, display a special message
    if (!location) {
      SETLABEL('gps_info', 'No Location Available');

    // format the display of the location data
    var message = [
      'Latitude: ' + location.latitude,
      'Longitude: ' + location.longitude,
      'Accuracy: ' + location.accuracy,
      'Altitude: ' + location.altitude,
      'Course: ' + location.course,
      'Speed: ' + location.speed,
      'Time: ' + new Date(location.timestamp * 1000).toLocaleString()

    // set the label property of the label on the form
    SETLABEL('gps_info', message);

  // go ahead and update it now...

  // ... and every 3 seconds
  SETINTERVAL(updateLocationInfo, 3000);