我遇到了一个问题,有时我需要 15 秒左右才能找到我的位置。相反,谷歌地图几乎每次都会在几秒钟内找到我的位置。我想知道是否无论如何我可以加快核心位置和 CLLocationManager 以便它更快地找到用户位置。这是我的设置
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.activityType = CLActivityTypeFitness;
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
[self.locationManager startUpdatingLocation];
[NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(checkAccuracy:) userInfo:nil repeats:YES];
对于 CLLocationManagerDelegate 我有:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
CLLocation* location = [locations lastObject];
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0) {
// If the event is recent, do something with it.
NSLog(@"latitude %+.6f, longitude %+.6f\n",
location.coordinate.latitude,
location.coordinate.longitude);
[[NSNotificationCenter defaultCenter] postNotificationName:kLocationChanged object:nil];
}
}
最后的通知更改地图视图中心。对此有任何想法吗?我错过了什么吗?