Using the Geolocation API we can ask the browser for the user’s position coordinates.
The window.navigator
property exposed by browsers points to a Navigator object which is a container object that makes a lot of Web Platform APIs available to us.
The browser exposes a navigator.geolocation
object, through which we’ll do all the geolocation operations. It’s only available on pages served using HTTPS, for security purposes, and it’s available on all modern browsers.
Since
window
is the global object, we can accessnavigator
without specifyingwindow.navigator
navigator.geolocation
Let’s see how to use it.
Lessons in this unit:
0: | ▶︎ Introduction |
1: | Getting the user's position |
2: | Watching the position for changes |
3: | If the user denies the position |
4: | Adding more options |
Are you intimidated by Git? Can’t figure out
merge vs rebase? Are you afraid of screwing up
something any time you have to do something in
Git? Do you rely on ChatGPT or random people’s
answer on StackOverflow to fix your problems?
Your coworkers are tired of explaining Git to
you all the time? Git is something we all need
to use, but few of us really master it. I
created this course to improve your Git (and
GitHub) knowledge at a radical level. Launching
May 21, 2024. Join the waiting list!