Created
August 9, 2019 18:22
-
-
Save parzibyte/170d4353300f3c7070845d5a1dd0e806 to your computer and use it in GitHub Desktop.
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
// 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