我正在尝试通过 LocationManager 获取坐标。当我在 WIFI 网络上时,我得到了完美的位置。但是当我切换到蜂窝数据时,得到的位置不正确(在我当前位置的 500 米半径范围内)。我尝试了“desiredAccuracy”的所有组合,但未能获得准确的坐标。有什么解决办法吗?
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
currentLocation = nil;
[locationManager startUpdatingLocation];
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{if(currentLocation != nil)
currentLocation = NULL;
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
NSLog(@"Location age %f", locationAge);
if (locationAge > 0.1) return;
currentLocation = [[CLLocation alloc] initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude];
NSLog(@"current location - %@",currentLocation);
NSString *lat =[NSString stringWithFormat:@"%lf",currentLocation.coordinate.latitude];
NSString *lon =[NSString stringWithFormat:@"%lf",currentLocation.coordinate.longitude];
latitudeText.text = lat;
longitudeText.text = lon;
[manager stopUpdatingLocation];}
最佳答案
检查这个CLLocationManager responsiveness但是根据 Apple Docs ,接收器会尽力达到要求的精度;但是,不能保证实际精度。
但是 500 米还是太多了
关于ios - 通过蜂窝数据包跟踪时得到错误的坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20416702/