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