Question - Please explain the Geolocation API in HTML5. How will you create a Geolocation object?
Answer -
The Geolocation API in HTML5 allows users to share their location with selected websites. J.S. is capable of capturing a user's latitude and longitude and sending the same to the backend server.
Doing so enables location-aware features like finding local places of interest and finding out one's location on the map. A new geolocation object can be created using the following code:
var geolocation = navigator.geolocation;
The Geolocation object is actually a service object. It allows widgets to retrieve information about the geographical location of a user's device. Most browsers and mobile devices provide support for the Geolocation API. The API works with a new property of the global navigator object.