如何检测设备是否朝向特定点方向
我有来自 CLLocation 的当前位置,
还有另一个位置 - 也是 CLLocation。
我想检测我的设备何时前往另一个位置。
(我可以计算这些点之间的距离(以米为单位),但无法计算出
与设备当前航向进行比较的精确角度)
谢谢。
I have my current location from CLLocation,
and I have another location- also an CLLocation.
I would like to detect when my device is heading towards that other location.
(I can calculate the distance in meters between this points- but can't workout
the calculation of an accurate angle to compare with the device current heading)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 CLLocation 的内置
course
属性怎么样?How about using CLLocation's built-in
course
property?待删除
一种方法可能是不断计算当前位置和目标位置之间的距离。如果距离减小,则您的设备正在向目标移动。
在现实世界的场景中(城市中的汽车,山区国家的汽车,例如瑞士),这是行不通的。您将需要一些通向目标的路径点(例如交叉点)并不断寻找最近的路径点。
To Be deleted
One approach could be to continuously calculate the distance between current location and target location. if the distance decreases, your device is moving towards the the target.
In a real world szenario (car in city, car in mountainous country e.g. Switzerland) this doesn't work. You would need some array of way-points (e.g. intersections) that lead towards the target and continuosly look for the closest waypoint.