2

在我的印象中,iOS 中的谷歌地图指南针运行得非常好。我说的是地图中小蓝色“我的位置”点的指南针箭头,请参阅Google Maps SDK - My Location。它已在最近的 1.7 版本中引入,请在此处输入链接描述。我不知道他们是如何获得如此准确和稳定的指南针的,但我希望我的应用程序也能做到这一点,因为它依赖于精确的航向信息。

因此问题是:是否可以从 Google Maps SDK 中提取航向角?

4

1 回答 1

1

需要设置位置管理器并调用 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);
}
于 2016-07-23T15:08:52.537 回答