使用磁航向获取地理方向
如何计算磁航向值以获得地理方向,即北、东北、东、东西南、南、西南、西、西北?
由于磁航向仅返回度数值,因此我需要在不断更新的磁航向的基础上显示地理方向。
我怎样才能使它成为可能?
How to calculate magnetic heading value to get geographical direction i.e., North, North-East, East, East-South, South, South-West, West, West-North?
As magnetic heading returns only value of degree and its required for me to show the geographical direction, on the basis of continuous updated magnetic heading.
How can I make it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
下面是我用来显示不断更新的地理方向的代码。
在我这边工作得很好。如有需要修改的地方,欢迎各位大师告知。
Below is the code that I have used to display continuously updating geographical direction.
It is working fine at my end. Masters are welcome to let me know if any modification required.
尝试一下 Matt Neuburg 在 Github 上提供的示例。
https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch22p775heading/ch35p1035heading/ViewController.swift
太完美了!
Try this example offered by Matt Neuburg on Github.
https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch22p775heading/ch35p1035heading/ViewController.swift
It is perfect!
Swift (5.0) 版本接受了 @alloc_iNit 的答案并进行了测试。
Swift (5.0) version of accepted answer from @alloc_iNit and tested as well.