Reputation: 61
I use CLLocationManager
to detect the current user location. That's my code:
- (void)viewDidLoad {
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.delegate = self;
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[locationManager requestWhenInUseAuthorization];
}
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
curLocation = [locations lastObject];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude: curLocation.coordinate.latitude longitude: curLocation.coordinate.longitude zoom:currentZoom];
[mapView animateToCameraPosition:camera];
}
And now I'm facing the weird behavior of it. I'm sitting still in the office with the device next to me, but CLLocationManager
thinks that I'm randomly moving within +/- 1414.0 m area around me with speed = -1 and course = -1 all the times. I can filter all these "wrong moves" by these constant speed and course, but I don't understand why it works like this. Any idea kindly appreciated.
Upvotes: 2
Views: 1335
Reputation: 1001
Assuming that "randomly moving within +/- 1414.0m area" means "location readings show horizontal accuracy set to 1414.0":
Your device is unable to acquire GPS fix. That might be because GPS is not available from inside of your office building. Also you might have WiFi turned off, as with WiFi on you should be able to get much better horizontal accuracy - up to +/- 65m.
Keep in mind that there are 3 sources for location readings:
The +/- 1414m is what you typically get when cell towers are the only source
With WiFi access points you may get accuracy up to 65m - note that for wifi triangulation to work you need a) WiFi radio enabled - to scan for access points, and b) access to Apple access points database - to resolve access points to lat/long. If there are transient connections or database server issues you won't be able to use WiFi AP triangulation.
When location readings are acquired through GPS you start seeing non-negative speed.
To cut it short - probably all you need is to get out of office :o)
Upvotes: 3