> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperwisor.com/llms.txt
> Use this file to discover all available pages before exploring further.

# location

> Read the viewing device's geolocation from a script.

The `location` global reads geolocation from the device the dashboard is being
viewed on (phone, tablet, or desktop), using the browser's geolocation.

## One-shot position

```js theme={null}
const pos = await location.getCurrentPosition(options?);
// pos: { latitude, longitude, accuracy, altitude, altitudeAccuracy,
//        heading, speed, timestamp }
```

```js theme={null}
const pos = await location.getCurrentPosition();
widget.setText('coords', `${pos.latitude.toFixed(5)}, ${pos.longitude.toFixed(5)}`);
```

## Watch position

`watchPosition` calls your callback on each update and returns a function to stop
watching.

```js theme={null}
const stop = location.watchPosition((pos) => {
  widget.setValue('speed', pos.speed ?? 0);
});
// later: stop();
```

## Support check

```js theme={null}
if (location.isSupported()) {
  // geolocation available
}
```

<Note>
  `options` accepts the standard browser `PositionOptions`
  (`enableHighAccuracy`, `timeout`, `maximumAge`).
</Note>

<Card title="Next: device & context" icon="circle-info" href="/script/device-context">
  Product, device, and environment info.
</Card>
