How to do a local search autocomplete as Apple's native map app does?

ios, iphone, mapkit, mklocalsearch

Solution

MkLocalSearchRequest will not perform auto complete on your search string, perhaps because Apple wants to limit the number of requests from 3rd party apps.

In theory you could reverse-engineer the requests and responses to https://gsp-ssl.ls.apple.com/auto_complete.arpc and then perform those requests yourself, not using MkLocalSearchRequest at all. But that would probably lead to your app being rejected on the App Store.

Problem

I have done an implementation by adopting most of the concept from Apple's sample code of the MKlocalSearch from here Currently for the auto complete, every time user is typing inside the search bar, I am sending a new request where I specified: ``` MkLocalSearchRequest.naturalLanguageQuery = searchBar.text MkLocalSearchRequest.region = userlocation.region ``` But I get totally different set of response from sever comparing to Apple's default map app as shown in the image below Then I capture the traffic and find that my request goes to https://gsp-ssl.ls.apple.com/search.arpc while Apple's goes to https://gsp-ssl.ls.apple.com/auto_complete.arpc Is there any way to tune the `MkLocalSearchRequest` to get the same set of response objects?

Original source