Search for Nearby Points of Interest Using Local Search
The Search API (i.e
MKLocalSearch) allows iOS developers to search for points of interest and display them on maps. App developers can use this API to perform searches for locations, which can be name, address, or type, such as coffee or pizza.
The use of
MKLocalSearch is very similar to the
MKDirections API covered in the previous chapter. You'll first need to create an
MKLocalSearchRequest object that bundles your search query. You can also specify the map region to narrow down the search result. You then use the configured object to initialize an
MKLocalSearch object and perform the search.
The search is performed remotely in an asynchronous way. Once Apple returns the search result (as an
MKLocalSearchResponse object) to your app, the complete handler will be executed. In general, you'll need to parse the response object and display the search results on the map.
To continue reading and access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.