Press enter to see results or esc to cancel.


Locate Your Web user on Google Map

In this video I am showing how you can locate your Client or user of your Web Project using Google Map api and Javascript function. This will work in all platforms supporting HTML and Javascript.

<!DOCTYPE html>
<html>
<head>
</head>
<body onload="getLocation()">
<p id="demo"></p>
<iframe id="myFrame" src="" width="360" height="270" frameborder="0" style="border:0"></iframe>
<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;
 document.getElementById("myFrame").src = 'http://maps.google.com/maps?q='+position.coords.latitude+', '+position.coords.longitude+'&z=15&output=embed';
}
</script>
</body>
</html>

In the above code, Javascript will first take the location coordinates from the browser and then it will pass it to create the google map to show the location pin pointed as shown below.


You can check your location real time here,
get_location_cordinates.html