此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

GeolocationCoordinates:heading 属性

基线 广泛可用

自 2020年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

安全上下文: 此特性仅在一些支持的浏览器安全上下文(HTTPS)中可用。

GeolocationCoordinates 接口的 heading 只读属性是表示设备当前的移动方向的 double 类型值,指示设备朝向偏离正北方向的角度大小(单位为角度)。0 度表示正北方向,且角度按顺时针方向计算(即:东为 90 度,西为 270 度)。如果 GeolocationCoordinates.speed0,或设备无法提供航向信息,则 heading 的值为 null

表示设备当前的移动方向的 double 类型值。

规范

规范
Geolocation
# heading-attribute

浏览器兼容性

参见