OGeek|极客世界-中国程序员成长平台

标题: ios - MKLocalSearch 没有找到附近的所有餐馆 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:27
标题: ios - MKLocalSearch 没有找到附近的所有餐馆

我在 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];

 }];
}       



Best Answer-推荐答案


因此,尽管我已经有一段时间没有提出这个问题了,但我仍然想解决,因为我认为我应该这样做。在偶然发现 stackoverflow 和苹果开发者论坛上的各种链接之后,似乎内置的 MKLocalSearch 方法仅限于返回最多 10 个结果。然而,Google Maps API 最多可以返回 60 个结果。因此,恐怕我的问题的答案是

,您无法让 MKLocalSearch 方法返回与特定 naturalLanguageQuery 关键字相关的区域内超过 10 个位置。

关于ios - MKLocalSearch 没有找到附近的所有餐馆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29322394/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4