By positioning we can get latitude and longitude, and geo-coding can return the relevant textual description of a place by geographical coordinates.
These descriptions are encapsulated in the Clplacemark class, and its properties are:
1) addressdictionary, Geographic Information dictionary
2) Isocountrycode,iso Country code
3) country, national information
4) PostalCode, zip code
5) Adminisrativearea, Administrative Region information
6) locality, specify City information
Personally, the value stored in the dictionary is the same as the value of the other attributes in Clplacemark.
Geo-Information anti-coding is implemented using the Clgeocoder class, which enables the conversion between geographic coordinates and geographic text description information
The code is as follows:
-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) Locations
{
Clgeocoder * Geocoder = [[Clgeocoder alloc] init];
[Geocoder reversegeocodelocation:[locations Lastobject] completionhandler:^ (Nsarray *placemarks, NSError *error) {
if ([placemarks count] > 0) {
Clplacemark * placemark = placemarks[0];
You can use the dictionary type to obtain the geographic text information, you can use the corresponding key value in the Address Book framework to obtain the corresponding information
Nsdictionary * dict = placemark.addressdictionary;
NSString * str = [dict objectforkey: (NSString *) kabpersonaddresscitykey];//get city Info
You can also get information through property values
NSLog (@ "%@", placemark.country);//Output Country information
NSLog (@ "%@", placemark.locality);//Specify City information
NSLog (@ "%@", placemark.thoroughfare);//Specify Street-level information
}
}];
}
iOS geo-Information anti-coding