API di geolocalizzazione
L'oggetto di geolocalizzazione
L'oggetto Geolocation consente all'utente di fornire la propria posizione alle applicazioni web. Per motivi di privacy, all'utente viene richiesta l'autorizzazione a segnalare le informazioni sulla posizione.
Nota: questa funzione è disponibile solo in contesti protetti (HTTPS).
Nota: la geolocalizzazione è più precisa per i dispositivi con GPS, come iPhone.
L'API di geolocalizzazione viene pubblicata tramite l' oggetto navigator.geolocation .
Proprietà dell'oggetto di geolocalizzazione
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() |
Metodi di geolocalizzazione degli oggetti
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 |