Published
Edited
Sep 15, 2022
Insert cell
Insert cell
geolocation = {
if (!navigator.geolocation) throw Error('Geolocation is not accessible');
return navigator.geolocation;
}
Insert cell
options = ({
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0,
});
Insert cell
// ref: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition
{
const success = (pos) => { console.log('getCurrentPosition pos=', pos) };
const error = (err) => { throw err };
geolocation.getCurrentPosition(success, error, options);
}
Insert cell
// ref: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition
{
const success = (pos) => { console.log('watchPosition pos=', pos) };
const error = (err) => { throw err };
geolocation.watchPosition(success, error, options);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more