我在iOS上使用gebase的firebase我正在从我的firebase数据库加载数据但是如果位置有点远,它在地图中不显示为MKAnnotation ....
我需要一种方法来过滤它应搜索的半径。
我看了geo queryAtRegion:
,但它不是应该使用的那个..
代码是
[[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth * _Nonnull auth, FIRUser * _Nullable user) {
[self.geo setLocation:[[CLLocation alloc] initWithLatitude: lat longitude:log] forKey:[NSString stringWithFormat:@"%@", user.displayName] withCompletionBlock:^(NSError *error) {
if (error){
NSLog(@"%@", error.localizedDescription);
} else {
}
}];
}];
对于抓取是这个..
- (void)loadData{
self.regionQuery = [self.geo queryWithRegion:region];
NSDate *methodStart = [NSDate date];
[_regionQuery observeEventType:GFEventTypeKeyEntered withBlock:^(NSString *key, CLLocation *location) {
pinAnnotation = [[Pin alloc] init];
[pinAnnotation setKey: key];
[pinAnnotation setCoordinate:location.coordinate];
[pinAnnotation setTitle: [NSString stringWithFormat:@"%f",location.coordinate.latitude]];
[pinAnnotation setSubtitle:keyy];
[self.mapView addAnnotation:pinAnnotation];
self.annotations[key] = pinAnnotation;
NSDate *methodFinish = [NSDate date];
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart];
NSLog(@"executionTime = %f", executionTime);
}];
}