Created
October 21, 2018 00:15
-
-
Save nosrednawall/6a32977ce9b149d7d33eb9e002824b3d to your computer and use it in GitHub Desktop.
Código para conseguir a longitude e a latitude de um usuário utilizando javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { | |
var longitude = position.coords.longitude; | |
document.getElementById('id_longitude').value = longitude; | |
latitude = position.coords.latitude; | |
document.getElementById('id_latitude').value = latitude; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment