2011-08-22 132 views
1

我正在開發一個應用程序,在該應用程序中我必須顯示給定經度和緯度的地址。 我有經度和緯度,但我不知道如何從那個經度和緯度得到我的地址。 任何建議將不勝感激 在此先感謝!從經緯度獲取位置地址

+0

[如何獲取iphone應用程序中經度和緯度的地址]的可能重複(http://stackoverflow.com/questions/2063717/how-to-get-the-address-of-a-latitude-和經度在iphone應用程序) –

回答

7

我最近做了一些非常類似的事情。使用座標,您可以使用MKReverseGeocoder來獲取地址。

當你找到座標

self.reverseGeocoder =[[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate]autorelease]; 
    reverseGeocoder.delegate=self; 
    [reverseGeocoder start]; 

//調用時reverseGeocoder是能夠成功中檢索地址

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{ 
    NSString *street=[placemark.addressDictionary objectForKey:@"Street"]; 
    //get the different address components 
} 

//調用時reverseGeocoder無法中檢索地址

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{ 

} 

希望這會有所幫助

+0

非常感謝你 – SampathKumar