【问题标题】:ios CLLocationManager didUpdateToLocation Latitude and longitude migrationios CLLocationManager didUpdateToLocation 经纬度迁移
【发布时间】:2013-02-18 03:33:35
【问题描述】:

我使用这段代码来获取经度和纬度。

    (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
         fromLocation:(CLLocation *)oldLocation {
    NSLog(@"%f",newLocation.coordinate.latitude);
    self.location = newLocation;
}

但是我得到的经纬度与实际地理位置有偏差。如何解决这个问题?

【问题讨论】:

  • 我不明白这个问题。你能解释一下你的期望吗?
  • 我想得到经度和纬度。但与实际地理位置有偏差。我怎样才能得到准确的位置?

标签: ios


【解决方案1】:

您应该测试返回的 CLLocation 对象的准确性,并确保它符合您的位置准确性标准。

if (newLocation.horizontalAccuracy > 1000) {
  // Throw away this location and wait for another one as this is over 1km away
}

此外,locationManager:didUpdateToLocation:fromLocation: 方法在 iOS6 中已被弃用,因此如果您的目标是 iOS6+,则应使用 locationManager:didUpdateLocations:

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多