Html5
Is used to get the geographical position of a user.
Since this can compromise user privacy, the position is not available unless the user approves it.
Se utilizapara obtener la posición geográfica de un usuario.
Dado que esto puede comprometer la privacidad del usuario, la posición no está disponible a menos que el usuario lo apruebe.
Geolocation soundsscary, can I turn it off?
Since this can compromise user privacy, the position is not available unless the user approves it.
Dado que esto puede comprometer la privacidad del usuario, la posición noestá disponible a menos que el usuario lo apruebe.
What does getCurrentPosition() method do?
The getCurrentPosition() method returns an object if it is successful. The latitude, longitude and accuracyproperties are always returned. The other properties below are returned if available.
El getCurrentPosition () devuelve un objeto si tiene éxito. Las propiedades de la latitud, longitud y precisiónsiempre se devuelven. Las demás propiedades se devuelven a continuación si está disponible.
How can you check if geolocation is supported by your web browser?
Through the following script<script>
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by thisbrowser.";}
}
</script>
Mediante el siguiente script:
<script>
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
</script>
How can you handle errors when working with geolocation?
The second parameter of thegetCurrentPosition() method is used to handle errors. It specifies a function to run if it fails to get the user's location:
Example
function showError(error)
{
switch(error.code)
{...
Regístrate para leer el documento completo.