我有特定地点的纬度和经度,我想计算距离,那么我该如何计算呢?
最佳答案
CLLocation *location1 = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1];
CLLocation *location2 = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2];
NSLog(@"Distance i meters: %f", [location1 distanceFromLocation:location2]);
[location1 release];
[location2 release];
您还需要将CoreLocation.framework
添加到您的项目中,并添加导入语句:
#import <CoreLocation/CoreLocation.h>
关于iphone - 如何计算经纬度两点之间的距离?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2652167/