#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>
@interface viewcontroller ()
@end
@implementation Viewcontroller
-(void) viewdidload {
[Super viewdidload];
// geo-coding
[self geocoder:nil];
// anti-geo-coding ;
}
No Internet , no way to do it.
-(void) Geocoder: (UIButton*) sender
{
// Initialize geocoding classes
clgeocoder *geo=[[clgeocoder alloc]init];
// start geocoding
[Geo geocodeaddressstring:@ " Beijing " completionhandler: ^ (nsarray *placemarks, nserror *error) {
if(placemarks. Count= =0| | Error)
NSLog(@ "%@", error);
for (clplacemark *mark in placemarks) {
NSLog(@ "%f,%f,%@,%@", Mark. Location. Coordinate. Latitude, Mark. Location. Coordinate. Longitude, mark. Name, Mark. Description);
}
}];
NSLog(@ "= = =");
}
Anti-geo-coding
-(void) Digeocoder
{
cllocation *location=[[cllocation alloc]initwithlatitude:38.1 Longitude:[];
clgeocoder *geo=[[clgeocoder alloc]init];
[Geo reversegeocodelocation: Location completionhandler: ^ (nsarray *placemarks, nserror *error) {
for (clplacemark *mark in placemarks) {
NSLog(@ "%f,%f,%@,%@", Mark. Location. Coordinate. Latitude, Mark. Location. Coordinate. Longitude, mark. Name, Mark. Description);
}
}];
}
Geocoding and geo-coding