[英]objective-c : How to find heading (direction) from location services?
我正在从事定位服务,并且希望从定位服务中获得航向,我拥有所有所需的属性,例如纬度,经度等,但是我也想找到方向(航向)
(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];
}
我找到了一些从CLHeading获取它的线索,但仍然无法从CLHeading获取它。 我正在使用上面的代码
阅读http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLHeading_Class/Reference/Reference.html :)我想您应该使用trueHeading。
trueHeading
相对于真北的航向(以度为单位)。 (只读)@property(只读,非原子)CLLocationDirection trueHeading
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.