Login
Your Email
Pasword
Home
Write
Trending
History
Liked
Earning

How to use HTML5 Geolocation?

The HTML Geolocation API is used to locate a user's position.

Do you have similar website/ Product?
Show in this page just for only $2 (for a month)
Create an Ad
0/60
0/180

Locate the User's Position
The HTML Geolocation API is used to get the geographical position of a user.
Using HTML Geolocation
The getCurrentPosition() method is used to return the user's position.
atitude and longitude:
<script>
var x = document.getElementById("demo"); function getLocation()
{
if (navigator.geolocation)
{ navigator.geolocation.getCurrentPosition(showPosition);
 }
else
 { x.innerHTML = "Geolocation is not supported by this browser.";
 }
 }
function showPosition(position)
 {
 x.innerHTML = "Latitude: " + position.coords.latitude + "
Longitude: " + position.coords.longitude;
 }
</script>

Location-specific Information
Geolocation is also very useful for location-specific information, like: Up-to-date local information 
Showing Points-of-interest near the user 
Turn-by-turn navigation (GPS)

CONTINUE READING
HTML5
Geolocation
HTML APIs
Ayesha
Tech writer at newsandstory