Aye*_*ima 14 iphone objective-c mkmapview
如何使用mapkit框架的distanceFromLocation方法计算两英里之间的距离.
谢谢
Dan*_*ira 28
这已经在公制回答这里.现在你只需要将米转换为里程,即:
1 Meter = 0.000621371192 Miles
Run Code Online (Sandbox Code Playgroud)
要么
1 Mile = 1609.344 Meters
Run Code Online (Sandbox Code Playgroud)
Moh*_*him 25
试试以下代码:
double latA = [currentlat floatValue];
double logA = [currentlong floatValue];
double latB = [toLat floatValue];
double logB = [toLong floatValue];
CLLocation *locA = [[CLLocation alloc] initWithLatitude:latA
longitude:logA];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:latB longitude:logB];
CLLocationDistance distance = [locA distanceFromLocation:locB];
NSLog(@"Calculated Miles %@", [NSString stringWithFormat:@"%.1fmi",(distance/1609.344)]);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13746 次 |
最近记录: |