I use MKLocalSearchto perform a map search. My problem is ordering MKMapItems in the response. For example, searching for the city I am in will initially return a number of businesses related to the city name, and I will need to scroll down to find the actual city. I use the property region MKLocalSearchRequestto focus the search in the nearest area.
My questions:
- Can you follow the order in which the answers will be returned to you? For example, the Maps application will list my city above after entering the first letter. How is it that the POI: or businesses were not listed above?
- Is there a way to completely exclude a business from the search and get only answers in response?
Not sure if it’s relevant or not, but here is the code to search for:
-(void)issueLocalSearchLookup:(NSString *)searchString {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(self.location.coordinate, 30000, 30000);
self.localSearchRequest = [[MKLocalSearchRequest alloc] init];
self.localSearchRequest.region = region;
self.localSearchRequest.naturalLanguageQuery = searchString;
self.localSearch = [[MKLocalSearch alloc] initWithRequest:self.localSearchRequest];
[self.localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
if(error){
NSLog(@"LocalSearch failed with error: %@", error);
return;
} else {
for(MKMapItem *mapItem in response.mapItems){
[self.data addObject:mapItem];
}
[self.searchDisplayController.searchResultsTableView reloadData];
}
}];
}