简体   繁体   中英

MKLocalSearch not finding all nearby restaurants

I implemented an MKLocalSearch within a certain region on the mkmapview that returns an array of restaurants within the region. Through research, only 10 restaurants are being shown. Is there's a way so that the MKLocalSearch can return more than 10 restaurants within a region? Here is the code,

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

 }];
}       

So although it's been a while since I've asked this question, I still want to address because I think I should. After stumbling across various links on stackoverflow and the apple developer forums, it seems that the built-in MKLocalSearch method is limited to returning up to 10 results. Whereas, the Google Maps API can return up to 60 results. Therefore, I'm afraid the answer to my question is

No , you can't get the MKLocalSearch method to return more than 10 locations within a region tied to a specific naturalLanguageQuery keyword.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM