斯威夫特 3.0
需要设置位置管理器并调用 startUpdatingHeading:
class NavegacaoRotaViewController: UIViewController ,GMSMapViewDelegate,CLLocationManagerDelegate
...
self.locationManager = CLLocationManager()
self.locationManager.delegate = self
self.locationManager.startUpdatingHeading()
然后包含以下委托方法,您应该能够从 newHeading 中提取航向角:
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
googleMapsView.animate(toBearing: newHeading.trueHeading)
}
对象-c
需要设置位置管理器并调用 startUpdatingHeading:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager startUpdatingHeading];
然后包含以下委托方法,您应该能够从 newHeading 中提取航向角:
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
NSLog(@"Updated heading: %@", newHeading);
}