此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。

View in English Always switch to English

GeolocationCoordinates

Baseline
Widely available
*

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年7月.

* Some parts of this feature may have varying levels of support.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

GeolocationCoordinates 介面表示設備在地球上的位置和高度,以及計算這些屬性的準確性。地理位置訊息是以世界大地測量系統座標(WGS84)提供的。

實例屬性

GeolocationCoordinates 介面不繼承任何屬性。

GeolocationCoordinates.latitude Read only

返回一個 double,表示位置的緯度(十進制度)。

GeolocationCoordinates.longitude Read only

返回一個 double,表示位置的經度(十進制度)。

GeolocationCoordinates.altitude Read only

返回一個 double,表示相對於名義海平面的高度(以公尺為單位)。如果實現無法提供數據,則此值可以為 null。

GeolocationCoordinates.accuracy Read only

返回一個 double,表示 latitude 和 longitude 屬性的準確性(以公尺為單位)。

GeolocationCoordinates.altitudeAccuracy Read only

返回一個 double,表示高度的準確性(以公尺為單位)。如果實現無法提供數據,則此值可以為 null。

GeolocationCoordinates.heading Read only

返回一個 double,表示設備面向的方向。此值以度為單位,表示設備偏離真北的程度。0 度表示真北,方向順時針確定(這意味著東是 90 度,西是 270 度)。如果 speed 為 0 或設備無法提供 heading 訊息,則 heading 為 null。

GeolocationCoordinates.speed Read only

返回一個 double,表示設備的速度(以公尺每秒為單位)。此值可以為 null。

實例方法

GeolocationCoordinates 介面不繼承任何方法。

GeolocationCoordinates.toJSON()

返回以 JSON 表示的 GeolocationCoordinates 物件,並啟用使用 JSON.stringify() 進行序列化。

規範

Specification
Geolocation
# coordinates_interface

瀏覽器相容性

參見