简体   繁体   English

Objective-C:如何从定位服务中找到航向(方向)?

[英]objective-c : How to find heading (direction) from location services?

Iam working on Location serves and want o get heading from location services, I have all desired attributes eg latitude, longitude etc but I want to find Direction (heading) too 我正在从事定位服务,并且希望从定位服务中获得航向,我拥有所有所需的属性,例如纬度,经度等,但是我也想找到方向(航向)

 (void)locationUpdate:(CLLocation *)location {
    locationLable.text = [location description];
    CLLocationCoordinate2D coordinate = [location coordinate];
    NSLog(@"This is location   %@",[location description]);
    NSLog(@"Lattitude          =   %@",[NSString stringWithFormat:@"%f", coordinate.latitude]);
    NSLog(@"Langitude          =   %@",[NSString stringWithFormat:@"%f", coordinate.longitude]);
    NSLog(@"Altitude           =   %@",[NSString stringWithFormat:@"%gm", location.altitude]);
    NSLog(@"horizontalAccuracy =   %@",[NSString stringWithFormat:@"%gm", location.horizontalAccuracy]);
    NSLog(@"verticalAccuracy   =   %@",[NSString stringWithFormat:@"%gm", location.verticalAccuracy]);
    NSLog(@"Speed   =   %@",[NSString stringWithFormat:@"%gm", location.speed]);

}


- (void)headingUpdate:(CLHeading *)heading {
    NSLog(@"This is heading   %@",[heading description]);

}

- (void)viewDidLoad {
    locationController = [[MyCLController alloc] init];
    locationController.delegate = self;
    [locationController.locationManager startUpdatingLocation];
    [locationController.locationManager startUpdatingHeading];
}

I found some clue to get it from CLHeading but still unable to get it from CLHeading. 我找到了一些从CLHeading获取它的线索,但仍然无法从CLHeading获取它。 I am using the above code 我正在使用上面的代码

Read http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLHeading_Class/Reference/Reference.html :) I think you should use trueHeading, I guess.. 阅读http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLHeading_Class/Reference/Reference.html :)我想您应该使用trueHeading。

trueHeading trueHeading

The heading (measured in degrees) relative to true north. 相对于真北的航向(以度为单位)。 (read-only) @property(readonly, nonatomic) CLLocationDirection trueHeading (只读)@property(只读,非原子)CLLocationDirection trueHeading

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM