Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2017 17:45
Show Gist options
  • Save anonymous/5008dd70af11f4c1764f9d2d4be88324 to your computer and use it in GitHub Desktop.
Save anonymous/5008dd70af11f4c1764f9d2d4be88324 to your computer and use it in GitHub Desktop.
Geolocalización // adjuntamos: https://github.com/mglriosr/Wreckec
function iniciar(){
var boton=document.getElementById('obtener');
boton.addEventListener('click', obtener, false);
}
function obtener(){navigator.geolocation.getCurrentPosition(mostrar, gestionarErrores);}
function mostrar(posicion){
var ubicacion=document.getElementById('localizacion');
var datos='';
datos+='Latitud: '+posicion.coords.latitude+'<br>';
datos+='Longitud: '+posicion.coords.longitude+'<br>';
datos+='Exactitud: '+posicion.coords.accuracy+' metros.<br>';
ubicacion.innerHTML=datos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment