Take the current mobile phone as an example:
Get the current mobile address, and then convert from latitude to detailed address (including: Country name-Country code, province, city, street name, postal code, etc.).
1: Get the current mobile phone latitude and longitude degree
Reverse Geoder Class
1:-(void) Startedreversegeoderwithlatitude: (double) latitude Longitude: (double) longitude{ Cllocationcoordinate2d coordinate2d; Coordinate2d.longitude = longitude; Coordinate2d.latitude = latitude; if (Self.locationinfo = = nil) {self.locationinfo = [[[Location alloc] init] autorelease]; self.locationInfo.latitude = Latitude; Self.locationInfo.longitude = longitude; Mkreversegeocoder *geocoder = [[Mkreversegeocoder alloc] initwithcoordinate:coordinate2d]; Geocoder.delegate = self; [Geocoder start];} #pragma mark-#pragma mark Mkreversegeocoderdelegate methods-(void) Reversegeocoder: (Mkreversegeocoder *) Geocoder Didfindplacemark: (Mkplacemark *) placemark {NSLog (@ "reverse finished ..."); NSLog (@ "country:%@", placemark.country); NSLog (@ "countrycode:%@", Placemark.countrycode); NSLog (@ "locality:%@", placemark.locality); NSLog (@ "sublocality:%@", placemark.sublocality); NSLog (@ "postalcode:%@", Placemark.postalcode); NSLog (@ "subthoroughfare:%@", Placemark.subthoroughfare); NSLog (@ "thoroughfare:%@ ", placemark.thoroughfare); NSLog (@ "administrativearea:%@", Placemark.administrativearea); Self.locationInfo.locationName = [NSString stringwithformat:@ "%@%@,%@%@,%@", Placemark.country, Placemark.administrativearea, Placemark.locality, placemark.sublocality, Placemark.thoroughfare]; NSLog (@ "administrativearea:%@", self.locationInfo.locationName); [Self.target performSelector:self.callBack withobject:@ "0"]; Geocoder = nil;} -(void) Reversegeocoder: (Mkreversegeocoder *) Geocoder didfailwitherror: (nserror *) error {NSLog (@ "Error%@", error); [Self.target performSelector:self.callBack withobject:@ "1"];}
2: Get the current mobile phone latitude and longitude, the detailed address.
Current Location class
-(void) startupdatinglocation{//Start the location manager. [[Selflocationmanager] startupdatinglocation]; #pragma mark-#pragma mark Location manager/** return a Location Manager-create one if necessary. */-(Cllocationmanager *) Locationmanager {if (Locationmanager!= nil) {return locationmanager;} locationmanager = [[CLL Ocationmanager alloc] init]; [Locationmanager Setdesiredaccuracy:kcllocationaccuracynearesttenmeters]; [Locationmanager setdelegate:self]; return Locationmanager;} /** conditionally enable the ADD button:if the location manager is generating updates, then enable the button; If The location manager is failing, then disable the button. */-(void) Locationmanager: (Cllocationmanager *) Manager didupdatetolocation: (cllocation *) newlocation fromLocation: ( Cllocation *) oldlocation {[self.target performSelector:self.callBack withobject:@ ' 0];} -(void) Locationmanager: (Cllocationmanager *) Manager didfailwitherror: (nserror *) error {[Self.target performselector : Self.CallBack withobject:@ "1"];