【发布时间】:2011-07-09 02:41:27
【问题描述】:
我正在使用 CLLocation 来计算与当前用户位置的距离以及注释。但是我只是想知道这是否正确。我目前正在为此使用 iPhone 模拟器,根据 MKMapView,iPhone 模拟器位于此处:
Lat: 0 Long: -1067024384
注解的位置是:
workingCoordinate.latitude = 40.763856;
workingCoordinate.longitude = -73.973034;
但是,如果您查看谷歌地图,您会发现这些距离有多近,但根据 CLLocation 却相距甚远。我正在使用以下代码来确定它们之间的距离。
CLLocation *loc = [[CLLocation alloc] initWithLatitude:annotation.coordinate.latitude longitude:annotation.coordinate.longitude];
CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:self.mapView.userLocation.coordinate.latitude longitude:self.mapView.userLocation.coordinate.longitude];
CLLocationDistance dist = [loc distanceFromLocation:loc2];
int distance = dist
NSLog(@"%i", distance);
被NSLogged的距离是12769908。我认为这是不正确的,因此我的代码肯定有问题。
如果有请指出来!
【问题讨论】:
标签: iphone xcode ios4 mkmapview core-location