Skip to content

Instantly share code, notes, and snippets.

@mpaloulack
Created March 26, 2014 10:00
Show Gist options
  • Save mpaloulack/9780046 to your computer and use it in GitHub Desktop.
Save mpaloulack/9780046 to your computer and use it in GitHub Desktop.
Get distance between 2 locations
-(float)kilometersfromPlace:(CLLocationCoordinate2D)from andToPlace:(CLLocationCoordinate2D)to {
CLLocation *userloc = [[CLLocation alloc]initWithLatitude:from.latitude longitude:from.longitude];
CLLocation *dest = [[CLLocation alloc]initWithLatitude:to.latitude longitude:to.longitude];
CLLocationDistance dist = [userloc distanceFromLocation:dest]*4;
NSString *distance = [NSString stringWithFormat:@"%f",dist];
return [distance floatValue];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment