> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://docs.flokzu.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Georeferencing and Geolocation


# Georeferencing and Geolocation

Depending on the type of process we are automating it may be important to obtain the location of the user who is completing the task.

1. Add a field to the form, for example "GPS", which should be a text type.

2. Then click on "Visibility settings and scripts" and go to the third tab "Script" in the popup that opens.

Select the task you want (e.g. to create a document so that the location is loaded when a request is being entered)

And paste the following script:

```javascript
function getLocation() {
     if (navigator.geolocation) {
         navigator.geolocation.getCurrentPosition(showPosition);
     } else { 
         console.log("Geolocation is not supported by this browser.");
     }
 }
 function showPosition(position) {
     Flokzu.setFieldValue( [[GPS]] , "Latitud: " + position.coords.latitude + 
     " Longitud: " + position.coords.longitude);
 }
 Flokzu.onInit(getLocation);
```

### Here's what happens:
* With **Flokzu.onInit** (i.e. when the form is loaded), we call the function getLocation.
* The function **getLocation**, asks the browser for the current location.
* Once the location is obtained, the function getLocation will call the function ** showPosition** that by means of Flokzu.setFieldValue will load in the GPS field, the current position in a format "Latitude: -34.898676 Longitude: -56.1533002".

|| The first time, the user will be asked for permission to access the location.

![](https://storage.crisp.chat/users/helpdesk/website/ccc3fbb5dc442800/gps-en_1lm1q9j.png)