Skip to main content
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

const pos = await location.getCurrentPosition(options?);
// pos: { latitude, longitude, accuracy, altitude, altitudeAccuracy,
//        heading, speed, timestamp }
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.
const stop = location.watchPosition((pos) => {
  widget.setValue('speed', pos.speed ?? 0);
});
// later: stop();

Support check

if (location.isSupported()) {
  // geolocation available
}
options accepts the standard browser PositionOptions (enableHighAccuracy, timeout, maximumAge).

Next: device & context

Product, device, and environment info.