Platform
Resources
Pricing
Sign in
Get started
Forest Gregg
Workspace
Fork
Public
By
Forest Gregg
Edited
Aug 20, 2023
Fork of
The Geolocation API
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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
available
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
position
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
currentPosition
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
anchor
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
setAnchor
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML