Search nearby in iOS Maps

brainnews picture brainnews · Jun 5, 2013 · Viewed 7.3k times · Source

I am trying to build a simple application using MapKit that will automatically search for a specific place when the app launches and drop pin(s) on the map at the locations(s). I am seeing all sorts of ways to load locations (lat/lon, etc), but nothing that lets me search for a specific business name, restaurant name, etc.

I am expecting to work with Apple Maps. However, if Google Maps would be a better solve than so be it.

Any help would be appreciated. Thanks

Answer

Sanjit Saluja picture Sanjit Saluja · Jun 5, 2013

iOS >= 6.1 provides MKLocalSearch, MKLocalSearchRequest to search for natural language points of interest. Sample

MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.region = regionToSearchIn;
request.naturalLanguageQuery = @"restaurants"; // or business name
MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
    // do something with the results / error
}];