My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

What is Geolocation API in HTML?

Sujal Singh's photo
Sujal Singh
·Jul 16, 2022·

2 min read

What is Geolocation API in HTML?

*INTRODUCTION:-

**Before coming to our topic, let's understand what geolocation is, geolocation is just a geographic position of anything referred to. Now, what is API? API (Application Programming Interface ) is a mode of communication between two or more systems and this communication is based on request and response method let's understand this with a simple example In a restaurant there is waiter takes the order of food and later the order is passed on to the kitchen so here waiter acts as an API a communicator between the customer and the kitchen. Geolocation API (Application Programming Interface) in HTML is used to get the geographical position of a user. Geolocation is one of the best HTML5 APIs which is used to identify the user's geographic location for the web application. When it comes to sharing the physical location of users, privacy is a serious concern and to avoid this privacy issue Geolocation API comes into the picture, in other words, a user must always have an option to share location information with a website. Now the question is, why do these websites need a user location? the main objective is to show the related content to the user as per their location for eg, Olx shows the ads of the user's nearby location.

geo.jpeg

1. How does the geolocation API work?

Geolocation detects latitude and longitude coordinates by using the device's GPS or the device's mobile/WIFI signal if GPS is not available. The mobile/WIFI signals are triangulated to work out the latitude and longitude.

2. What browsers support geolocation?

HTML5 geolocation is widely used and supported on all major browsers and there are some requirements for these browsers like Google Chrome (version 5.0 onwards) and Firefox (version 3.5 onwards) and Safari (version 5.0 onwards) etc.

Like Geolocation there is an Ip geolocation they both are quite different and do the same job the only thing that is different is the accuracy level of both types. In HTML5 geolocation codes are written in