메뉴 건너뛰기

app

[xcode] mapview 생성 후 현재 위치 지도 표시

박영식2010.09.08 20:53조회 수 8818댓글 0

  • 2
    • 글자 크기
core.location 과 mapkit 프레임웍을 이용함.

header파일에는


#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];

}

박영식 (비회원)
  • 2
    • 글자 크기
[xcode] map에 marker 찍기 (by 박영식) [xcode] NSMutableURLRequest POST전송과 결과 XML 출력(파싱포함) (by 박영식)

댓글 달기

이전 1 ... 3 4 5 6 7 8 9 10 11 12... 14다음
첨부 (2)
MapTutorial.zip
694.3KB / Download 233
122.JPG
87.7KB / Download 78
위로