iosiphonecore-location

Finding distance between CLLocationCoordinate2D points


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.


Solution

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