[英]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.