This article is transferred fromHttp://blog.csdn.net/favormm/archive/2011/06/29/6574658.aspx
In ios sdk, There is only reverse gecoder, that is, the resolution from the longitude and latitude to the address, and there is no forward resolution from the address to the latitude and longitude. To support forward resolution, you only need to directly call the Google API. Today I will share with you two open-source projects that support forward and reverse resolution.
- Https://github.com/mjisrawi/iOS-Geocoding-Services
- Https://github.com/samvermette/SVGeocoder usage: http://samvermette.com/164
Tweet this
Svgeocoder
# Releases, # iphonedev
There is no forward geocoding class on IOS. and it's no secret that mkreversegeocoder is a pain in the butt and returns with an error half of the time. so I took the opportunity to write svgeocoder, a simple geocoder and reverse geocoder for IOS. my first GitHub release!
Svgeocoder requires the corelocation, mapkit and addressbook frameworks as well as the (pinned) touchjson parser by Jonathan Wight. it also uses the Google geocoding API so make sure you read theirterms of service before using svgeocoder.
Using the geocoder
Nsstring *Addressstring = @ "3245 St-Denis, Montreal"Svgeocoder *Geocoderequest = [[Svgeocoder Alloc] Initwithaddress:Addressstring];[Geocoderequest Setdelegate:Self];[Geocoderequest Startasynchronous];
View rawgeocoder. mThis gist brought to you by GitHub. Using the reverse geocoder
cllocationcoordinate2d coordinate =
cllocationcoordinate2dmake ( 45.54181 , - 73.62928 ); svgeocoder * rgeocoderrequest = [[ svgeocoder alloc ] initwithcoordinate: coordinate ]; [ rgeocoderrequest setdelegate: Self ]; [ rgeocoderrequest startasynchronous ];
View rawreversegeocoder. mThis gist brought to you by GitHub. svgeocoderdelegate
Best of all, svgeocoderdelegate returns an mkplacemark object just like with mkreversegeocoder:
- (Void)Geocoder:(Svgeocoder *)Geocoder Didfindplacemark:(Mkplacemark *)Placemark;- (Void)Geocoder:(Svgeocoder *)Geocoder Didfailwitherror:(Nserror *)Error;