Chr*_*ong 2 objective-c mkmapview ios mklocalsearch mklocalsearchrequest
我在 mkmapview 的某个区域内实现了一个 MKLocalSearch,它返回该区域内的一系列餐馆。通过研究,只展示了 10 家餐厅。有没有办法让 MKLocalSearch 可以返回一个区域内的 10 多家餐厅?这是代码,
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc]init];
request.naturalLanguageQuery = @"restaurant";
request.region = midRegion;
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){
CustomAnnotation *annotation = [[CustomAnnotation alloc] initWithPlacemark:item.placemark];
annotation.title = item.name;
annotation.subtitle = item.placemark.addressDictionary[(NSString *)kABPersonAddressStreetKey];
annotation.phone = item.phoneNumber;
[annotations addObject:annotation];
}];
[self.mapView addAnnotations:annotations];
}];
}
Run Code Online (Sandbox Code Playgroud)
所以虽然我已经有一段时间没有问这个问题了,但我仍然想解决这个问题,因为我认为我应该这样做。在 stackoverflow 和苹果开发者论坛上的各种链接绊倒后,似乎内置的 MKLocalSearch 方法仅限于返回最多 10 个结果。而 Google Maps API 最多可以返回 60 个结果。因此,恐怕我的问题的答案是
不,您无法让 MKLocalSearch 方法返回一个区域内与特定自然语言查询关键字相关联的 10 个以上的位置。
| 归档时间: |
|
| 查看次数: |
794 次 |
| 最近记录: |