Given that the mapkit doesn't provide forward geocoding functionality today, can anyone provide help on how I can i use a search bar to return a latitude and longitude coordinate from a user inputted address today. If someone can provide sample code that would be great.
7 Answers
iOS 5 now allows for forward Geocoding:
I hope this helps!

- 2,801
- 1
- 41
- 74
-
2With iOS6 this will probably be the only usable solution (besides possibly Yahoo) as I doubt Google will be happy with you overlaying Google geocoding data on an Apple map... – Kendall Helmstetter Gelner Jun 19 '12 at 19:17
-
@KendallHelmstetterGelner I think Google would be fine with this, but Apple?...perhaps not. – DataGraham Sep 10 '12 at 13:25
-
1It's Google's TOS that prevents it. https://developers.google.com/maps/documentation/geocoding/#Limits (no Google geocoding data displayed on non-Google maps). Apple doesn't care where you get the data for things you overlay on a map. Now that Apple is not using Google for map data there are no restrictions on how you can use MapKit. – Kendall Helmstetter Gelner Sep 10 '12 at 19:04
I've created a forward geocoding API for Google's geocoding server. Check out my blogpost: http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/
-
Needs to be updated to the new Google Geocoding API (for instance, no API key is needed now). Besides that, does great job. Thanks @Merrimack. http://code.google.com/apis/maps/documentation/geocoding/ – DenTheMan Jun 07 '11 at 20:14
-
Thanks DenTheMan, however the API does support both V2 and V3 (latest with no API key). Has been that way since the first release. – Merrimack Jun 10 '11 at 09:26
-
I have created SVGeocoder, a simple forward and reverse geocoder class for iOS. It uses the Google Geocoding API as well and returns an MKPlacemark.
This is how you geocode an address string:
NSString *addressString = @"3245 St-Denis, Montreal"
SVGeocoder *geocodeRequest = [[SVGeocoder alloc] initWithAddress:addressString];
[geocodeRequest setDelegate:self];
[geocodeRequest startAsynchronous];
And you reverse geocode an CLLocationCoordinate2D object like this:
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(45.54181, -73.62928);
SVGeocoder *rGeocoderRequest = [[SVGeocoder alloc] initWithCoordinate:coordinate];
[rGeocoderRequest setDelegate:self];
[rGeocoderRequest startAsynchronous];
The SVGeocoderDelegate offers these 2 methods:
- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark;
- (void)geocoder:(SVGeocoder *)geocoder didFailWithError:(NSError *)error;

- 40,269
- 27
- 112
- 144
-
1Important note for users: if you use the Google Geocoding API, you have to display the result on a map. – DenTheMan Jun 04 '11 at 18:07
-
great code, but why do you import AddressBook framework in SVGeocoder? – lu yuan May 23 '12 at 04:59
-
@luyuan because MKPlacemark requires it for the address components (not the case anymore with CLPlacemark in iOS 5 I think) – samvermette May 23 '12 at 19:29
-
-
4Now totally useless for iOS developers: From the Google TOS: "Note: the Geocoding API may only be used in conjunction with a Google map" https://developers.google.com/maps/documentation/geocoding/#Limits – Kendall Helmstetter Gelner Sep 10 '12 at 19:08
-
I have done some small work on forward and reverse geocoding using CLGeocoder in iOS5 CoreLocation framework on github hope it help you. https://github.com/Mangesh20/geocoding

- 574
- 4
- 16
It's a known issue with the current version of MapKit. File a bugreport and dupe #6628720 so they make fixing it a priority.
In the meantime, there are forward Geocoding APIs from Google Maps, via Yahoo Placemaker, or Cloudmade.

- 13,343
- 3
- 33
- 35
There is also a framework here: https://github.com/tylerhall/CoreGeoLocation
Comment from docs: An Objective GeoCoder and Reverse Geocoder wrapping around Yahoo's Geocoding services or Google's Geo APIs primarily.

- 490
- 5
- 11
-
Important note for users: if you use the Google Geocoding API, you have to display the result on a map. Yahoo doesn't seem to have this limitation. – DenTheMan Jun 04 '11 at 18:08
-
2You have to display the result on a GOOGLE map. Important distinction. – Kendall Helmstetter Gelner Sep 10 '12 at 19:33
There is no such functionality in MapKit. The best you can do is to call a third party web service. Google has some APIs to do this and so had Yahoo I think. Both have restrictions on commercial use though, so read the agreement.

- 34,311
- 8
- 67
- 88