0
Good afternoon, I am doing some projects using the Google Maps API and wanted to know how to save the values of latitude and longitude of the user in a variable each, which will be used later in other functions, can anyone help me? I’m using the following code to get the location:
<!DOCTYPE html>
<html>
<body>
<p id="demo">Clique no botão para receber sua localização em Latitude e Longitude:</p>
<button onclick="getLocation()">Clique Aqui</button>
<script>
var x=document.getElementById("demo");
function getLocation(){
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition);
}
else{
x.innerHTML="O seu navegador não suporta Geolocalização.";
}
}
function showPosition(position){
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
Nuss, mt bound it went super right here, the links tbm helped mt , I saved kkkk
– Daniel Lucas