1

我使用此代码获取经度和纬度。

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

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

4

1 回答 1

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 中已被弃用,因此locationManager:didUpdateLocations:如果您的目标是 iOS6+,则应使用该方法。

于 2013-02-18T05:24:50.920 回答