找到CLLocationCoordinate2D点之间的距离

编程入门 行业动态 更新时间:2024-10-25 16:19:55
本文介绍了找到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点之间的距离

本文发布于:2023-07-27 23:15:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1225226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:距离   CLLocationCoordinate2D

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!