MKLocalSearch returns results outside of the region
I am using Apple Maps to get a list of addresses in a local area. However, it seems to be returning results from around the world, not the area of ββthe map I am specifying.
I use the following code and have checked the area to make sure it is "wide" all over London (see attachment) for a mapView with the same parameters. However, according to my results, I sometimes have places in Germany, USA or South America.
Can anyone see what I am doing wrong?
MKLocalSearchRequest* request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = searchTerm;
CLLocationCoordinate2D cornerCoordinate = CLLocationCoordinate2DMake(51.5007282, -0.1246263);
request.region = MKCoordinateRegionMakeWithDistance(cornerCoordinate, 50000, 50000);
MKLocalSearch* search = [[MKLocalSearch alloc] initWithRequest:request];
[search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
//results come in here
}];
Map area:
source to share
According to the documentation:
Specifying a region does not guarantee that all results will be within a region. This is just a hint for a search engine.
This is a bummer, but unfortunately there is no way to limit the results to just the scope provided.
You can use the Google Places API for this: https://developers.google.com/places/webservice/autocomplete
source to share
Try this solution. Here I think the problem is related to the region you specified.
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = searchTerm;
MKCoordinateSpan span = MKCoordinateSpanMake(.1, .1);
CLLocationCoordinate2D cornerCoordinate = CLLocationCoordinate2DMake(51.5007282, -0.1246263);
request.region = MKCoordinateRegionMake(cornerCoordinate, span);
MKLocalSearch *search = [[MKLocalSearch alloc] initWithRequest:request];
[search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
}];
source to share