How to get Latitude and Longitude(location) using javascript

by THavamani 2013-08-07 16:05:15

Javascript code
Code is used to get the location of the user...
<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 +
"<br>Longitude: " + position.coords.longitude;
}
getLocation()


</script>

Html Code:
<html>
<body>
<div id="demo">
</div>
</body>
</html>

Out put:
Latitude: 11.016845
Longitude: 76.955832
1226
like
0
dislike
0
mail
flag

You must LOGIN to add comments