메뉴 건너뛰기

app

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

박영식2010.09.08 20:53조회 수 9128댓글 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 박영식)

댓글 달기

박영식
2010.09.09 조회 4901
박영식
2010.05.25 조회 4248
박영식
2010.01.14 조회 5086
박영식
2009.09.21 조회 4267
박영식
2008.08.18 조회 6186
박영식
2008.08.17 조회 4375
박영식
2008.07.24 조회 4790
박영식
2008.07.23 조회 8139
박영식
2008.07.22 조회 3463
박영식
2008.04.11 조회 2316
박영식
2008.01.20 조회 2161
박영식
2007.12.23 조회 3330
첨부 (2)
MapTutorial.zip
694.3KB / Download 255
122.JPG
87.7KB / Download 100
위로