0

Possible Duplicate:
How to search MKMapView with UISearchBar?

I have one UISearchBar with MKMapView with google maps. I need suggestions whenever i started typing. So what should i need to do for that ? Is there any web service for google api ?

Community
  • 1
  • 1
DipakSonara
  • 2,598
  • 3
  • 29
  • 34
  • 1
    Be careful about doing this on iOS 6. Google's API license states that you can only display its data on its maps. Since iOS 6 uses Apple's maps you can't use Google's API to get data. – Craig Oct 04 '12 at 21:01

2 Answers2

2

Use CLGeocoder to generate address results based on a string.
This is known as forward geocoding.
You'll get a number of placemarks returned which you can populate into your UI.

http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html

Quick example here:

NSString *address = @"Big Ben";

CLGeocoder *coder = [[CLGeocoder alloc] init];
[coder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error){

     //Do something with the returned placemarks
}];

You can also restrict results to a set region if specific, that's all documented at the link above.

sagarkothari
  • 24,520
  • 50
  • 165
  • 235
Andy Smart
  • 715
  • 1
  • 6
  • 10
  • He is not asking about placemarks ! he is asking about suggestions. MKMapView is just part of UI. He is asking for general suggestions from google. – sagarkothari Oct 04 '12 at 13:46
  • 1
    It sounded like he wanted location recommendations, based on the question (which this would produce). – Andy Smart Oct 05 '12 at 09:16
  • Now, I also wonder - may be he is looking for just locations suggestions. Edited your answer & upvoted. My Apology – sagarkothari Oct 05 '12 at 09:27
0
  1. create a request http://google.com/complete/search?output=toolbar&q=YOURQUERY
  2. receive response & parse it.
  3. Display it into your UITableView as a suggestions.

To see complete illustration go through this post.

sagarkothari
  • 24,520
  • 50
  • 165
  • 235