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.