Enter your email id to get regular update free
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.

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)
HTML5
Geolocation
HTML APIs
Ayesha
Tech writer at newsandstory
Total 581 views