메뉴 건너뛰기

app

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

박영식2010.09.08 20:53조회 수 8826댓글 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
    • 글자 크기

댓글 달기

박영식
2006.09.01 조회 1412
lispro06
2015.05.15 조회 1453
lispro06
2015.05.15 조회 1467
lispro06
2015.11.20 조회 1471
lispro06
2013.12.11 조회 1484
suritam9
2013.11.26 조회 1490
lispro06
2016.11.02 조회 1566
lispro06
2014.08.16 조회 1568
lispro06
2017.07.16 조회 1593
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (2)
MapTutorial.zip
694.3KB / Download 238
122.JPG
87.7KB / Download 81
위로