1

I have a UISearchBar where the user types in a string (e.g. an address) and it should suggestion some addresses.

So let's say I am within Apple's Maps App, and I type in "New Yo" I'll get the city of New York + some local search results.

It seems like Apple's using a mixture between a MKLocalSearch and a forward geocoding.

Now If I search the docu, it clearly states that I must not use the CLGeoCoding for searching addresses but I should use the MKLocalSearch.

So what is the best approach here? MKLocalsearch is actually for finding spots within a near distance to the user or am I wrong?

By the way, I am using Swift :D Thanks

Christian
  • 6,961
  • 10
  • 54
  • 82
  • If you are trying to implement auto-complete or incremental search, MapKit and CoreLocation do not currently support this. I have found MKLocalSearch to be very limited and "unproductive" even for what it is supposed to do. For auto-complete, the Google Places Autocomplete API is excellent but may require you to switch to using Google Maps only to comply with the licensing. See http://stackoverflow.com/questions/23505097/ios-app-getting-throttled-from-local-searches. –  Feb 11 '15 at 13:07

1 Answers1

0

If you want to be able to search locations use CLGeocoder. (the downside is that apple limits the amount of api calls, so you probably won't get a bunch of results when you type "new yo..." for example, but it does the job).

MKLocalSearch, on the other hand, is specifically designed for Mapkit.

"MKLocalSearch allows developers to find nearby points of interest within a geographic region."

I'm not sure how much map kit integration you are doing, but if you are just trying to allow the user to search for locations, the above should help.

I should also note that google has a geocoding API that you can use if you aren't satisfied with CLGeocoder.

Community
  • 1
  • 1
MendyK
  • 1,643
  • 1
  • 17
  • 30
  • So this means there's actually no really possibility to get a suggestion list for addresses while the user is typing? I mean the LocalSearch does what it says, it searches within a region, but if I want to search for an address within another city, I am out of luck? – Christian Feb 11 '15 at 07:15
  • You can search for an address within another city using CLGeocoder (and it will work), but you won't get the autocomplete suggestions you are looking for. – MendyK Feb 11 '15 at 14:38