简体   繁体   English

计算与位置的距离-iPhone

[英]Calculate distance from Location - iPhone

I'm trying to calculate the distance between two places user Core Location. 我正在尝试计算用户核心位置在两个地方之间的距离。 I've found a few posts that state to use 我发现一些状态可以使用

-(CLLocationDistance)distanceFromLocation:(const CLLocation *)location

Found some other test code in the thread below: 在下面的线程中找到了一些其他测试代码:

CLLocationDistance NaN CLLocationDistance NaN

I'm not sure how to put it all together, to get the result I want ? 我不确定如何将所有内容组合在一起以获得所需的结果?

Anyone any thoughts ? 有人有什么想法吗?

Regards, Stephen 问候斯蒂芬

If you have a location named myLocation and want to find the distance from another location, say, restaurantLocation , then it seems you would do something like 如果您有一个名为myLocation的位置,并且想要查找与另一个位置的距离,例如restaurantLocation ,那么您似乎会做类似的事情

CLLocationDistance distance = [myLocation distanceFromLocation:restaurantLocation]

This will give you the distance, in meters, between the two. 这将为您提供两者之间的距离(以米为单位)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM