Iphone 查找设备是否指向正确的航向/方向?

Iphone 查找设备是否指向正确的航向/方向?,iphone,objective-c,cllocationmanager,cllocation,Iphone,Objective C,Cllocationmanager,Cllocation,我想找出到某个位置的距离以及设备相对于该位置的方向。我已经计算了距离,但不知道如何找到位置 _theLocation = [[CLLocation alloc]initWithLatitude:-41.561004 longitude:173.849030]; - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLoc

我想找出到某个位置的距离以及设备相对于该位置的方向。我已经计算了距离,但不知道如何找到位置

_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];  
}  

是否可以从我们的位置找到指向位置的标题?

您不能简单地在两个实例中捕获设备的位置并找出位置的方向吗

这不是一个完整的解决方案,但假设设备仅沿连接设备和位置的线路移动,您可以使用
–distance fromLocation:
。如果在两个实例中捕捉到距离位置的距离,并查看后一个值是否小于前一个值,则可以推断设备已移动到距离位置更近的位置

_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];  
}  
事实上,从您的问题来看,您似乎想确定设备是否已移近该位置(而不是确切的方向,例如N或NE)。如果是这样的话,这应该行得通

嗯,


Akshay

您需要计算两个坐标之间的“方位”。它没有内置函数,所以需要自己编写。请参阅和。谢谢。我们将查看这些链接。这就是问题所在。在Objective-C中你是如何做到的?是的,它并不是越走越近,而是指向了位置的方向。在这种情况下,安娜的评论是正确的。