2011-06-14 5 views
0

아래 코드를 따르면 출력물을 콘솔에 인쇄 할 수 있지만 MapView에서 업데이트하는 방법은 무엇입니까?plist의 주소를 Mapview로 업데이트하는 방법은 무엇입니까?

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    /* We have our address */ 
    NSString *oreillyAddress = @"1005 Gravenstein Highway North, Sebastopol, CA 95472, USA"; 

    /* We will later insert the address and the format that we want our output in, into this API's URL */ 
    NSString *geocodingURL = @"http://maps.google.com/maps/geo?q=%@&output=%@"; 
    /* Insert the address and the output format into the URL */ 
    NSString *finalURL = [NSString stringWithFormat:geocodingURL, oreillyAddress, GOOGLE_OUTPUT_FORMAT_CSV]; 
    /* Now escape the URL using appropriate percentage marks */ 

    finalURL = [finalURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    /* Create our URL */ 
    NSURL *urlToCall = [NSURL URLWithString:finalURL]; 
    /* And a request for the connection using the URL */ 
    NSURLRequest *request = [NSURLRequest requestWithURL:urlToCall]; 

    /* We will put all the connection's received data into this instance of the NSMutableData class */ 
    NSMutableData *newMutableData = [[NSMutableData alloc] init]; 
    self.connectionData = newMutableData; 
    [newMutableData release]; 
    NSURLConnection *newConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 
    /* Create the connection and start the downloading of geocoding results */ 
    self.myConnection = newConnection; 
    [newConnection release]; 
} 

- (void) viewDidUnload{ 
    [super viewDidUnload]; 
    [self.myConnection cancel]; 
    self.myConnection = nil; 
    self.connectionData = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation: 
(UIInterfaceOrientation)interfaceOrientation { 
    /* Support all orientations */ 
    return YES; 
} 

- (void)dealloc { 
    [myConnection cancel]; 
    [myConnection release]; 
    [connectionData release]; 
    [super dealloc]; 
} 
@end 

답변

0

위치에 대한 위도 정보가 있어야합니다. MKAnnotation 프로토콜을 사용하는 클래스를 만들고 addAnnotation: 메서드를 사용하여 MKMapView 개체에 가져온 위치를 저장하는 인스턴스를 추가해야합니다. 위치가지도의 표시된 영역 내에 있으면지도보기 객체는 위임 방법 mapView:viewForAnnotation:을 호출하여 해당 주석을 표시 할보기를 가져옵니다. 따라서 MKMapViewDelegate 프로토콜을 채택하여 대리인이되어야합니다. mapView:viewForAnnotation: 메서드를 구현하여 MKPinAnnotationView 인스턴스 또는 자신의 하위 클래스 인 MKAnnotationView을 반환하십시오.

위치가 표시된 지역 내에 있지 않다면 setRegion:animated: 방법을 사용하여 위치로 이동하십시오.

+0

@Gere Tan이 정보가 도움이 되었습니까? 이 문제에 대해 도움이 더 필요하십니까? –

관련 문제