Capture GEO Location Values on Form Fields

In this guide, we will explain how to capture Latitude and Longitude values on your form.

  1. Please add two Text fields for the Latitude and Longitude:
image
  1. Please add a JavaScript field with the below code:
var latitude_field = 'bd15-19d1-ac08';
var longitude_field = '9222-7efb-8af0';
// Get Location
navigator.geolocation.getCurrentPosition(
  function( position ) {
    // Set values
    window.formyoula.form_fields[ latitude_field ].set( 'value', position.coords.latitude );
    window.formyoula.form_fields[ longitude_field ].set( 'value', position.coords.longitude );
  },
  function( error ) {}, 
	{ maximumAge: 0, timeout: 5000, enableHighAccuracy: true }
);
image
  1. Please update the Text field IDs in the code:
image
image

For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂