Platform
Resources
Pricing
Sign in
Get started
Steve
Workspace
Fork
Published
By
Steve
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
geolocation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
options
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