iOS - Apple Maps MKMapKit search location not functioning properly

500 views Asked by At

Apple Maps MKMapKit search location not functioning properly using MKLocalSearch.

I have to provide Location search functionality where user can enter input and app will suggest matched result and user can select one of them to display it on to map view and to get the address details from the location fetched from the selected result entry.

Currently MKLocalSearch request results sometimes provides error code "loadingThrottled" though we are cancelling previous request with a new search character entered.

Also MKLocalSearch provides only 10 results for searched string.

Is there any way I can improve this location search feature and provide a autocomplete in a better way?

According to apple docs:

There are no request limits per app or developer ID, so well-written apps that operate correctly should experience no problems. However, throttling may occur in a poorly written app that creates extremely large numbers of requests. https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/EnablingSearch/EnablingSearch.html

1

There are 1 answers

0
Sagar Thummar On

You should use MKLocalSearchCompleter to retrieve auto-complete suggestions. It is provides most relevant results compared to MKLocalSearch.

An MKLocalSearchCompleter object takes a partial search string and generates a list of potential completions. You use a search completer object to retrieve auto-complete suggestions for your own map-based search controls.

Advantage:

  • Provide most relevant results compared to MKLocalSearch.
  • Location filter(MKSearchCompletionFilterType) is available.
  • Less chance to get "loadingThrottled" error.
  • Approx provides maximum 15 results.(Based on my experience till now.)

Limitation:

  • MKLocalSearchComplete not provides a location in response, only provides location name & address. (If you want location than you have to create MKLocalSearch Object & will get more location details.)

As the user types text, you feed the current text string into the search completer object, which delivers possible string completions that match locations or points of interest. You then use the fully-formed search completion objects to create an MKLocalSearch object and retrieve more detailed information about the geographic location.

Reference: Apple API Reference: MKLocalSearchCompleter