1
我想查找到某个位置的距离以及该设备与该位置相关的朝向。我有距离工作,但无法找到如何找到位置的方式。查找设备是否指向正确的标题/方向?
_theLocation = [[CLLocation alloc]initWithLatitude:-41.561004 longitude:173.849030];
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocationDistance meters = [newLocation distanceFromLocation:_theLocation] * 0.000621371192;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
NSString *str = [NSString stringWithFormat:@"Heading = %.f", newHeading.trueHeading];
}
是否可以从我们的位置找到标题_theLocation
?
你需要计算两个坐标之间的 “轴承”。没有内置的功能,所以需要编写自己的。请参阅[this](http://stackoverflow.com/questions/3198186/calculate-compass-heading-to-a-cllocation-haversine-functions-for-ios)和[this](http://stackoverflow.com/问题/ 3925942/cllocation类别换计算轴承-W-半正矢函数)。 – Anna 2011-08-17 12:56:28
谢谢你将看看这些链接。 – daidai 2011-08-17 13:21:04