API de geolocalização
O objeto de geolocalização
O objeto Geolocation permite que o usuário forneça sua localização para aplicativos da web. Por motivos de privacidade, é solicitada permissão ao usuário para relatar informações de localização.
Nota: Este recurso está disponível apenas em contextos seguros (HTTPS).
Nota: A geolocalização é mais precisa para dispositivos com GPS, como o iPhone.
A API de geolocalização é publicada por meio do objeto navigator.geolocation .
Propriedades do objeto de geolocalização
Property | Description |
---|---|
coordinates | Returns the position and altitude of the device on Earth |
position | Returns the position of the concerned device at a given time |
positionError | Returns the reason of an error occurring when using the geolocating device |
positionOptions | Describes an object containing option properties to pass as a parameter of Geolocation.getCurrentPosition() and Geolocation.watchPosition() |
Métodos de objetos de geolocalização
Method | Description |
---|---|
clearWatch() | Unregister location/error monitoring handlers previously installed using Geolocation.watchPosition() |
getCurrentPosition() | Returns the current position of the device |
watchPosition() | Returns a watch ID value that then can be used to unregister the handler by passing it to the Geolocation.clearWatch() method |