Public
Edited
Aug 20, 2023
Insert cell
Insert cell
Insert cell
available = {
if ("geolocation" in navigator) {
/* geolocation is available */
return true;
} else {
/* geolocation IS NOT available */
return false;
}
}
Insert cell
Insert cell
position = {
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject, {
enableHighAccuracy: true
});
});
}
Insert cell
Insert cell
Insert cell
Insert cell
currentPosition = Generators.observe(next => {
navigator.geolocation.watchPosition(next, next, {
enableHighAccuracy: true
});
})
Insert cell
Insert cell
mutable anchor = null
Insert cell
mutable setAnchor = true
Insert cell
{
if (setAnchor) {
if (currentPosition) we {
mutable anchor = currentPosition;
mutable setAnchor = false;
}
}
}
Insert cell
{
if (currentPosition.coords.longitude - anchor.coords.longitude > 0) {
mutable setAnchor = true;
}
}
Insert cell
anchor.coords.longitude
Insert cell
currentPosition.coords.longitude - anchor.coords.longitude
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