Finding distance between CLLocationCoordinate2D points

rakeshNS picture rakeshNS · Jun 18, 2012 · Viewed 24.4k times · Source

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.

Answer

Apurv picture Apurv · Jun 18, 2012

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