#import <MapKit/MKReverseGeocoder.h>
#import <CoreLocation/CoreLocation.h>
@interface ~~ : UIViewController<MKReverseGeocoderDelegate,CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
MKPlacemark *mPlacemark;
CLLocationCoordinate2D location;
}
@property(nonatomic, retain) CLLocationManager *locationManager;
가 포함되어야 하면
m파일에는
나타내고자 하는 부분에 아래 코드를
{
self.locationManager=[[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyNearestTenMeters;
[locationManager startUpdatingLocation];
}
상단에 아래 부분이 포함되어야 한다.
@synthesize locationManager;
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
NSLog(@"Geocoder completed");
mPlacemark=placemark;
[mapView addAnnotation:placemark];
}
#pragma mark -
#pragma mark CLLocationManagerDelegate Methods
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
location=newLocation.coordinate;
//One location is obtained.. just zoom to that location
MKCoordinateRegion region;
region.center=location;
[mapView setRegion:region animated:TRUE];
}
댓글 달기