Published
Edited
Jul 12, 2018
4 stars
Insert cell
Insert cell
geolocation = new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(
position => { resolve(position.coords) },
error => { reject(error) }
)
}).catch(error => error)
Insert cell
md`
Latitude: ${geolocation.latitude}
Longitude: ${geolocation.longitude}
`
Insert cell
Insert cell
md`${geolocation_status}`
Insert cell
mutable geolocation_status = "Please enable location permissions for this page to work."
Insert cell
{
if (geolocation.toString() !== "[object PositionError]") {
mutable geolocation_status = "Thanks for enabling location!" // or set it to an empty string to get rid of the message
}
}
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