Iphone iOS:MapKit:如何设置搜索请求获取的注释数
我有以下代码用于在我的应用程序中检索餐馆Iphone iOS:MapKit:如何设置搜索请求获取的注释数,iphone,ios,objective-c,mapkit,Iphone,Ios,Objective C,Mapkit,我有以下代码用于在我的应用程序中检索餐馆 NSLog(@"getting restaurants"); MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init]; request.naturalLanguageQuery = @"restaurant"; request.region = self.mapView.region; MKLocalSearch *localSearch = [[MKLocalSearch
NSLog(@"getting restaurants");
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = @"restaurant";
request.region = self.mapView.region;
MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
NSMutableArray *annotations = [NSMutableArray array];
[response.mapItems enumerateObjectsUsingBlock:^(MKMapItem *item, NSUInteger idx, BOOL *stop) {
MapViewAnnotation *annotation = [[MapViewAnnotation alloc] initWithPlacemark:item.placemark];
annotation.title = item.name;
annotation.coordinate = item.placemark.location.coordinate;
//annotation.subtitle = item.placemark.addressDictionary[kABPersonAddressStreetKey];
//annotation.phone = item.phoneNumber;
[annotations addObject:annotation];
}];
[self.mapView addAnnotations:annotations];
}];
如何设置要加载的批注数量限制?
现在,只加载了一手可用的点。当我进一步放大时,我再次调用代码,并显示其他点。在向数组添加对象时,您可以设置计数器。如果大于指定的数字。停止向数组中添加。我得到的是很少的..不是很多:)