Get GEO Location Coordinates of User
In this video I have shown how you can get the GEO Location Coordinates of the user using simple java script code.
<!DOCTYPE html>
<html>
<body onload="getLocation()">
<p>Your Location Details are Shown Below.</p>
<p id="demo"></p>
<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;
}
</script>
</body>
</html>
Since the code is onload, It will automatically Ask the physical location of the user
After the User approves to share the Location. It will show the location as below.
0 Comments
Comments
Leave a Comment