ジオロケーションAPI
ジオロケーションオブジェクト
Geolocationオブジェクトを使用すると、ユーザーは自分の場所をWebアプリケーションに提供できます。プライバシー上の理由から、ユーザーは位置情報を報告する許可を求められます。
注:この機能は、セキュアコンテキスト(HTTPS)でのみ使用できます。
注: ジオロケーションは、iPhoneなどのGPSを搭載したデバイスで最も正確です。
Geolocation APIは、 navigator.geolocationオブジェクトを介して公開されます。
ジオロケーションオブジェクトのプロパティ
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() |
ジオロケーションオブジェクトメソッド
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 |