您可以做的一件事是检查您被退回的horizontalAccuracy
财产。CLLocation
如果这高于某个阈值,那么您可以丢弃结果并等待更准确的结果。如果它在数英里之外,那么我希望准确度数字会很大。它最有可能使用蜂窝站点而不是 GPS 来确定位置,并且误差范围会大得多。
在您CLLocationManagerDelegate
的locationManager:didUpdateLocations:
方法中,您可以执行以下操作:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
if ([locations count] > 0) {
CLLocation *lastUpdatedLocation = [locations lastObject];
CLLocationAccuracy desiredAccuracy = 1000; // 1km accuracy
if (lastUpdatedLocation.horizontalAccuracy > desiredAccuracy) {
// This location is inaccurate. Throw it away and wait for the next call to the delegate.
return;
}
// This is where you do something with your location that's accurate enough.
}
}