2010-05-13 2 views
1

나는 현재 위치 (도시 이름 또는 아마 주소의 관점에서)를 알아야하는 iPhone 응용 프로그램이 있습니다. 그러나 나는 그것을 할 수 없었다. 나는 현재의 위도와 경도를 알아낼 수있다. 위도와 경도를 제공하면 현재 웹 사이트 이름을 반환 할 수있는 웹 서비스가 있습니까?위도 및 경도를 사용하여 위치 이름에 대한 웹 서비스

대기 모든 답장. 사전에

감사합니다 ..

기쁨

답변

1

iPhone OS 3.0 이상을 대상으로한다고 가정하면 MapKit 프레임 워크의 일부인 MKReverseGeocoder을 사용할 수 있습니다. 개발자 문서에는 샘플 프로젝트가 포함되어 있습니다. MKReverserGeocoder Class Reference

+0

주의 :. 당신은 지도에서이 정보를 사용해야한다. 앱에 표시되어 Google TOS 내에 있습니다. – z8000

0

MKReverseGeocoder은 훌륭한 수준이지만, 때때로 오류가 반환 할 수 있습니다. 오류 도메인 = PBRequesterErrorDomain 코드 = 6001 "작업을 완료 할 수 없습니다 (PBRequesterErrorDomain 오류 6001)

위 luvieere의 제안이 좋은 장소를 .. 나는 구글 HTTP 역 지오 코더를 사용하는 예로서 한 일이다, 시작 여기에 내가 쓴 GoogleReverseGeocoder 클래스의 내 구현의 IT를 사용하는 방법에 대한 전체 설명은 HERE 찾을 수 있습니다

// Send Google A Request 
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%lf,%lf&output=csv&sensor=false",self.locationToGeocode.coordinate.latitude,self.locationToGeocode.coordinate.longitude]; 
NSURL *urlFromString = [NSURL URLWithString:urlString]; 
NSStringEncoding encodingType = NSUTF8StringEncoding; 
NSString *reverseGeoString = [NSString stringWithContentsOfURL:urlFromString encoding:encodingType error:nil]; 

// Parse Out Response 
NSArray *listItems = [reverseGeoString componentsSeparatedByString:@","]; 
NSArray *tempAddressArray = [[listItems objectAtIndex:2] componentsSeparatedByString:@"\""]; 
NSArray *tempCountryArray = [[listItems objectAtIndex:[listItems count]-1] componentsSeparatedByString:@"\""]; 

// Did Google Find Address? 200 is yes 
if ([[listItems objectAtIndex:0] intValue] == 200) 
{ 
    // Set Class Member Variables 
    [self setGoogleReturnDidFindAddress:YES]; 
    [self setGoogleReturnAddress:[tempAddressArray objectAtIndex:[tempAddressArray count]-1]]; 
    [self setGoogleReturnCountry:[tempCountryArray objectAtIndex:0]]; 
    [self setGoogleReturnCode:[[listItems objectAtIndex:0] intValue]]; 
    [self setGoogleReturnAccuracy:[[listItems objectAtIndex:1] intValue]]; 

} else if ([[listItems objectAtIndex:0] intValue] > 600) 
{ 
    [self setGoogleReturnDidFindAddress:NO]; 
} 
관련 문제