Calculate distance between two latitudes / longitudes


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:appDelegate.mapView2.userLocation.coordinate];
  2. CLLocation *poiLoc = [[CLLocation alloc] initWithLatitude: [aPOI.latitude doubleValue] longitude: [aPOI.longitude doubleValue]];
  3.  
  4. double dist = [userLoc getDistanceFrom:poiLoc] / 1000;
  5.  
  6. NSLog(@"%f",dist);

URL: http://www.iphonedevsdk.com/forum/iphone-sdk-development/35043-calculate-distance-between-two-latitudes-longitudes.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.