【问题标题】:Collect GPS Location and Compass Direction at time of camera capture?在相机拍摄时收集 GPS 位置和指南针方向?
【发布时间】:2012-07-21 14:37:59
【问题描述】:

我的应用目前使用带有自定义叠加层的相机来拍摄和保存照片。

理想情况下,我还想在拍照时收集以下 3 个参数:

  1. 精确的 GPS 定位
  2. 指南针方向
  3. 手机倾斜

我主要专注于获取项目 1 和 2。关于如何做到这一点的任何想法?

【问题讨论】:

  • CoreLocation 和 CoreMotion
  • 在我已经使用自定义叠加层调用 UIImagePickerController 之后如何实现这两个方面的任何指导?
  • 您找到解决方案了吗?请分享我也在寻找相同的

标签: iphone objective-c ios


【解决方案1】:

你应该在 viewController 的 .h 文件中声明几个变量

float locLat;   //for latitude
float locLon;   //for longitude
float direction;  // for angle in radian
CLLocationManager *Manager; 

在 viewdidload 方法的 .m 文件中

Manager = [[CLLocationManager alloc] init];
Manager.delegate = self; 
Manager.desiredAccuracy = kCLLocationAccuracyBest; 
Manager.distanceFilter = 1.0; 
[Manager startUpdatingLocation];
[Manager startUpdatingHeading];

这些委托方法将被调用以获取位置更新

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{
    userlat = newLocation.coordinate.latitude;
    userlon = newLocation.coordinate.longitude;
}

这将为您提供指南针值更新

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading 
{
    float direction = newHeading.trueHeading;    
}

您可以在 imagepicker 的 didFinishPickingMediaWithInfo 委托方法中使用这三个值。

【讨论】:

  • 我们如何获得 3. Title?通过加速度计?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多