1. Geocoding: The conversion of a ' place name string ' to ' latitude and longitude ' [Geocoder geocodeaddressstring:<# (NSString *) #> completionhandler:<#^ (Nsarray *placemarks, Nserror *error) Completionhandler#> 2. Anti-geocoding: Converting ' latitude and longitude ' to ' place name string ' [Geocoder reversegeocodelocation:< # (Cllocation *) #> completionhandler:<#^ (Nsarray *placemarks, Nserror *error) Completionhandler#>] 3. Specific method invocation: ://(1). geocoding
-(void) geocoder{
1. Creating the encoding/anti-encoding manager
Clgeocoder *geocoder = [[Clgeocoder alloc]init];
2. Geocoding: Convert ' place name string ' to ' latitude and longitude '
[Geocoder geocodeaddressstring:@ "Beijing" completionhandler:^ (Nsarray *placemarks, Nserror *error) {
Placemarks is the ' landmark ' array tag location
Clplacemark *plmark = Placemarks.firstobject;
Get User location information
Cllocation *loc = plmark.location;
Get the latitude and longitude of a user
NSLog (@ "place name:%@ Longitude:%f Latitude:%f", plmark.name,loc.coordinate.longitude,loc.coordinate.latitude);
NSLog (@ "error%@", error);
}];
}
2. Anti-geo-coding
-(void) reversegeocoder{
1. Creating the encoding/anti-encoding manager
Clgeocoder *geocoder = [[Clgeocoder alloc]init];
2. Anti-coding: is to have ' clear latitude and longitude of the location information ' into the corresponding ' place name string '
Cllocation *loc = [[Cllocation alloc]initwithlatitude:39 longitude:116];
[Geocoder reversegeocodelocation:loc completionhandler:^ (Nsarray *placemarks, Nserror *error) {
Receive the ' landmark array ' returned with ' landmarks '
Clplacemark *plmark = [Placemarks firstobject];
Get the returned place name
NSLog (@ "Place name:%@", plmark.name);
}];
}
Map Development-Geocoding & geo-coding