通过蜂窝数据包跟踪时获取错误的坐标

时间:2013-12-06 05:31:46

标签: ios iphone gps core-location cllocationmanager

我试图通过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];}

1 个答案:

答案 0 :(得分:1)

检查CLLocationManager responsiveness但是根据Apple Docs The receiver does its best to achieve the requested accuracy; however, the actual accuracy is not guaranteed.,但500米仍然太多了