Geolokalisierungs-API
Das Geolocation-Objekt
Das Geolocation-Objekt ermöglicht es dem Benutzer, Webanwendungen seinen Standort bereitzustellen. Aus Datenschutzgründen wird der Benutzer um Erlaubnis gebeten, Standortinformationen zu melden.
Hinweis: Diese Funktion ist nur in sicheren Kontexten (HTTPS) verfügbar.
Hinweis: Geolokalisierung ist am genauesten für Geräte mit GPS, wie iPhone.
Die Geolocation-API wird über das Objekt navigator.geolocation veröffentlicht.
Geolocation-Objekteigenschaften
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() |
Geolocation-Objektmethoden
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 |