API de géolocalisation
L'objet de géolocalisation
L'objet Geolocation permet à l'utilisateur de fournir son emplacement aux applications Web. Pour des raisons de confidentialité, il est demandé à l'utilisateur l'autorisation de signaler des informations de localisation.
Remarque : Cette fonctionnalité est disponible uniquement dans des contextes sécurisés (HTTPS).
Remarque : La géolocalisation est plus précise pour les appareils avec GPS, comme l'iPhone.
L'API de géolocalisation est publiée via l' objet navigator.geolocation .
Propriétés de l'objet de géolocalisation
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éthodes d'objet de géolocalisation
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 |