2014-04-03 94 views
2

让我印象深刻的是,iOS中的Google地图指南针工作得非常好。我正在谈论地图上小蓝色“我的位置”点的指南针箭头,请参阅Google Maps SDK - My Location。它已在最近的版本1.7 enter link description here中引入。我不知道他们如何设法得到如此精确和稳定的指南针,但我希望我的应用程序依赖于精确的标题信息。从适用于iOS的Google Maps SDK中提取标题(指南针)

因此,问题是否可以从Google Maps SDK中提取标题角度?

+0

它不可能Google SDK,获取数据创建[CLLocationManager](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html)的最简单方法,并且已启用跟踪用户标题。这提供了[CLHeading](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLHeading_Class/Reference/Reference.html)对象,其中包含相对于真北方的标题(以度数度量)。 –

+1

谢谢,但这不是我要找的。我知道可以通过CLLocationManager获得(相当粗略的估计)当前的标题。为了获得精确的航向信息,绝对有必要利用设备的其他传感器,即传感器融合算法。苹果公司通过CMDeviceMotion提供这种服务(例如后者给出的当前态度)。 关键是知道我为什么要问如何从Google SKD中提取标题,因为在我看来,他们的工作比苹果在这里做得更好!只是比较苹果指南针与谷歌地图指南针自己...... – user2980195

+0

您可以在谷歌移动指南针映射在这里: http://stackoverflow.com/a/23489785/3607287 – Tharoth

回答

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); 
} 
相关问题