I want to get user's location when he/she submits a form. I tried to use Google's navigator.geolocation.watchPosition but this returns incorrect data when website is accessed using computer machine. The code I used is given below:
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.watchPosition(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;
}
I want to know whether this is possible or not using any personal computer?
Else I'll try to provide a map where user can put/drag marker to his/her location (like displayed on this link: https://www.gps-coordinates.org/)
Thanks
Aucun commentaire:
Enregistrer un commentaire