Crystal
Crystal

Reputation: 29518

iOS search api for Apple Maps

Is there a search API for Apple Maps? Like in Apple Maps, if you start typing an address, it filters the list with some possibilities. Is this available to developers? I saw that they added some MKLocalSearch in iOS 7, but I could not find anything that gives that capability.

Upvotes: 0

Views: 110

Answers (1)

Kris Gellci
Kris Gellci

Reputation: 9687

MKLocalSearch with MKLocalSearchRequest is exactly what you are looking for. A basic search can be done as follows:

MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
        request.naturalLanguageQuery = @"some address";

MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
           // do stuff with the response
        }];

This should put you on the right path. Read the docs for MKLocalSearch, MKLocalSearchRequest, and MKLocalSearchResponse.

Upvotes: 2

Related Questions