Geolocation API Hands-On
In this lesson, we will tackle a hands-on coding exercise that makes use of the Geolocation API in HTML5 to get the user's coordinates. Let's begin!
We'll cover the following...
Challenge: Get to know your coordinates
In this challenge, you are required to use the Geolocation API in HTML to get the user’s current location coordinates and display them on the front-end.
-
For this, write a function called
getLocation()
to get the current position of the user. In case there is an error or user permission is denied, display the following message"Geolocation is not supported by this browser."
-
Write a second function called
showPosition(position)
that displays the coordinates saved in theposition
...