3

I am trying to grab Coordinates through LocationManager. I am getting perfect location when i am on WIFI network. But get incorrect location (in radius of 500m from my current position) when i switch to Cellular data.. I tried all combinations of "desiredAccuracy" but failed to get accurate co-ordinates. Any solution?

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];}
Sagar Patil
  • 1,400
  • 15
  • 29
  • Are you checking this on a static location? – Dinesh Dec 06 '13 at 05:43
  • Nope. I am trying it on a device. – Sagar Patil Dec 06 '13 at 05:45
  • There can be 2 reasons for this.. 1) Net is not enabled on your sim.. 2) Problem with the cell towers.. Check your app on some other location other than your office.. Also try disabling the wifi and than check it with cellular data. – Dinesh Dec 06 '13 at 05:51
  • There is no issue with the internet connection. Everything is fine. I am getting coordinates, but around 500m radius – Sagar Patil Dec 06 '13 at 05:53
  • Yes Dinesh, tried all the above combinations you said. But still unable to grab accurate location. – Sagar Patil Dec 06 '13 at 05:54
  • 500m is the horizontalAccuracy in the CLLocation object? That sounds reasonable for cell only location. If you want higher accuracy, you have set set `desiredAccuracy` and *wait* for the GPS to lock on, which can take seconds. You'll need to show your code to get more help. – progrmr Dec 06 '13 at 13:12
  • Yes as you mentioned i have tried all combinations of desiredAccuracy. 500m radios is the "newLocation" that we get in "didUpdateToLocation" – Sagar Patil Dec 06 '13 at 13:36
  • Hi @Sagar Patil have you fixed this issue. I have facing same problem from 2 months but still I can't find where was the issue. The location of user locating on maps at different place. Please help me if you fixed this issue. Thanks in advance. – Karthik Mandava Apr 22 '16 at 07:12
  • @KarthiKMandava try hitting location multiple times. with in 30 seconds, hit location service for 10 times. Location improves over a time. so you have to wait for some time to get accurate location. – Sagar Patil Apr 22 '16 at 07:16

1 Answers1

1

check this CLLocationManager responsiveness But as per Apple Docs The receiver does its best to achieve the requested accuracy; however, the actual accuracy is not guaranteed. but 500 meters is still too much

Community
  • 1
  • 1
Dinesh
  • 929
  • 7
  • 25
  • When I check in google maps or other apps on my iPhone I get correct location. :( – Sagar Patil Dec 06 '13 at 06:03
  • 1
    Apple by default not using the Google maps anymore. so comparing with Google maps and apple native maps is useless as they both have different database of cell towers and wifi locations. I am not sure at this time but looks like its an issue with wrong cell tower location in Apple maps DB. – Dinesh Dec 06 '13 at 06:07