如何在 iOS Web 应用程序中查找指南针方向?
有谁知道如何从网络应用程序中查找 iOS 设备的指南针方向? iOS 4.2 中支持的新设备方向 API 似乎仅提供旋转的相对变化。有人能找到解决方法吗? (使用 navigator.geolocation
时,我还获得了 coords.heading
属性的 null
值。)
Does anyone know how to find the compass heading of an iOS device from within a web app? The new Device Orientation APIs supported in iOS 4.2 only seem to provide relative changes in rotation. Was anyone able to find a workaround to this? (I also get a null
value for the coords.heading
property when using navigator.geolocation
.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
devicemotion 事件中通过新属性提供指南针支持:webkitCompassHeading 和 webkitCompassAccuracy。我们还可以订阅一个新事件:compassneedscalibration。这仅适用于 iPad 2、iPhone 4、4S 和上一代 iPod touch。
来源:http://www.mobilexweb.com/blog/ ios-5-iphone-and-ipad-html5
或者:使用 Javascript 从 webb 应用程序访问设备指南针
Compass support is available in the devicemotion event through new attributes: webkitCompassHeading and webkitCompassAccuracy. There is also a new event we can subscribe to: compassneedscalibration. This will work only on iPad 2, iPhone 4, 4S and iPod touch last generation.
source: http://www.mobilexweb.com/blog/ios-5-iphone-and-ipad-html5
alternatively: Access device compass from webb app with Javascript