Using the Geolocation API we can ask the browser for the user’s position coordinates.
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.
windowis the global object, we can access
Let’s see how to use it.
Lessons in this unit:
|Getting the user's position
|Watching the position for changes
|If the user denies the position
|Adding more options