Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 9, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/170d4353300f3c7070845d5a1dd0e806 to your computer and use it in GitHub Desktop.
Save parzibyte/170d4353300f3c7070845d5a1dd0e806 to your computer and use it in GitHub Desktop.
// https://parzibyte.me/blog
const funcionInit = () => {
if (!"geolocation" in navigator) {
return alert("Tu navegador no soporta el acceso a la ubicación. Intenta con otro");
}
const onUbicacionConcedida = ubicacion => {
console.log("Tengo la ubicación: ", ubicacion);
}
const onErrorDeUbicacion = err => {
console.log("Error obteniendo ubicación: ", err);
}
const opcionesDeSolicitud = {
enableHighAccuracy: true, // Alta precisión
maximumAge: 0, // No queremos caché
timeout: 5000 // Esperar solo 5 segundos
};
// Solicitar
navigator.geolocation.getCurrentPosition(onUbicacionConcedida, onErrorDeUbicacion, opcionesDeSolicitud);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment