# getLocation

## Description

Get the current location details (GPS coordinate) of the device.

## Input / Parameter

| Name               | Description                                            | Input Type | Default | Options | Required |
| ------------------ | ------------------------------------------------------ | ---------- | ------- | ------- | -------- |
| timeout            | Connection time out period, in millisecond.            | Number     | -       | -       | -        |
| enableHighAccuracy | To enable or disable high accuracy of GPS coordinates. | Boolean    | False   | -       | -        |

## Output

| Description                        | Output Type |
| ---------------------------------- | ----------- |
| Returns the formatted information. | Object      |

### Object

| Key     | Description                                                             | Output Type |
| ------- | ----------------------------------------------------------------------- | ----------- |
| success | Boolean value to denote whether the function was executed successfully. | Text        |
| message | The message to print.                                                   | Text        |
| data    | Any additional message or data to print.                                | Text        |

## Callback

### callback

The function to be executed when location is obtained successfully.

### errorCallback

The function to be executed when location is not obtained successfully.

## Example

In this example, we will retrieve the device location data and use it as the coordinate value of the `setMapCenter` function.

### Steps

1. Drag a `map` component and a `button` component to a page in the mobile designer.

   ![](/files/v8fK4Ex5fLsx62SiANnu)
2. Select the event `press` for the button and drag the function `Device.getLocation` to the event flow. Fill in the parameters of the function.

   ![](/files/biSXRaVg13xaCWLEhRPx)
3. Drag the function to be executed if the location data is successfully received to the node below `Device.getLocation`. In this example, we are using the `Variable.set` function to save the location data into a variable.

   ![](/files/qxzl6evOJLU8dgJnxBS7)
4. Drag the function `Device.setMapCenter` below `Variable.set` and fill in the parameters of the function. Use the location data from `Device.getLocation` by adding `Variable.getAttribute` to the `coordinate` field of the `Device.setMapCenter` function.

   ![](/files/k9UwAJqmYeLS765zMWyd)

### Result

1. The location data will be received and it's `latLng` value (latitude and longitude) will be used as the center of the Map component.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/react-native/device/getlocation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
