本文介绍了找到CLLocationCoordinate2D点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从文档中了解到,我们可以使用函数 distanceFromLocation:找到两个 CLLocation 点之间的距离。但我的问题是我没有CLLocation数据类型与我,我有CLLocationCoordinate2D点。那么如何找到两个CLLocationCoordinate2D点之间的距离。我看过帖子发布但对我没有帮助。
解决方案您应该使用
- (id)initWithLatitude:(CLLocationDegrees)latitude 经度:(CLLocationDegrees)经度;然后,您应该可以使用
$ b来计算距离$ b [location1 distanceFromLocation:location2];
I know from documentation we can find distance between two CLLocation points using the function, distanceFromLocation:. But my problem is I dont have CLLocation data type with me, I have the CLLocationCoordinate2D points. So how can I find distance between two CLLocationCoordinate2D points. I have seen the post post but not helpful for me.
解决方案You should create an object of CLLocation using,
- (id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude;Then, you should be able to calculate the distance using
[location1 distanceFromLocation:location2];
更多推荐
找到CLLocationCoordinate2D点之间的距离
发布评论