且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

找到CLLocationCoordinate2D点之间的距离

更新时间:2023-02-26 20:12:29

您应该使用



- (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];