1

안녕하세요 저는 현재 city.It 사용자를 찾으려면 mkreversegeocoder를 사용하고 있지만 다른 위치에서 시도 할 때 내 나라 (터키)의 자치구/구의 이름을 제공합니다. 예를 들어 "istanbul"가 정확하지만 내 나라에서 "susurluk"과 같은 도시 이름이 없습니다. 그것은 지구입니다. 왜 그것이 도시 이름 대신에 지구를 반환하는지 모르는가? 당신은 내가 게시 할하려는 경우 내 코드의MKReverseGeocoder는 도시가 아닌 도시를 반환합니까?

편집 1 :

-(void)viewDidLoad { 
[super viewDidLoad]; 


manager=[[CLLocationManager alloc]init]; 
manager.delegate=self; 
manager.desiredAccuracy=kCLLocationAccuracyBest; 

[manager startUpdatingLocation]; 

} 

-(void)locationManager:(CLLocationManager *)aManager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 


    MKReverseGeocoder *geocoder=[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate]; 
    geocoder.delegate=self; 
    [geocoder start]; 

    [manager startUpdatingLocation]; 

} 

-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { 

NSDictionary * addressDict= [placemark addressDictionary]; 

//NSString *country = [addressDict objectForKey:@"Country"]; 

NSString *city = [addressDict objectForKey:@"City"]; 

//change the country name into en_US 

NSLocale *locale = [NSLocale currentLocale]; 
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; 

NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]; 

NSString *country1 = [usLocale displayNameForKey: NSLocaleCountryCode value: countryCode]; 

[[NSUserDefaults standardUserDefaults] setObject:country1 forKey:@"country"]; 
[[NSUserDefaults standardUserDefaults] setObject:city forKey:@"city"]; 

[[NSUserDefaults standardUserDefaults] synchronize]; 

} 


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

if (error.code == kCLErrorHeadingFailure) { 
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Problem" 
                message:@"Can't find the location!" 
                delegate:self 
              cancelButtonTitle:@"OK" 
              otherButtonTitles: nil]; 

    [alertView show]; 
    [alertView release]; 
    [manager stopUpdatingLocation]; 
     } 

} 

-(void)locationManager:(CLLocationManager *)manager1 didFailWithError:(NSError *)error  { 

if (error.code != kCLErrorDenied) { 

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Problem" 
                 message:@"Can't find the location!" 
                 delegate:self 
               cancelButtonTitle:@"OK" 
               otherButtonTitles: nil]; 

    [alertView show]; 
    [alertView release]; 
    [manager stopUpdatingLocation]; 

    } 

} 
+0

를 확인하시기 바랍니다 경우에서의 – Srinivas

+0

일어나고 난 "발리 케시 르"도시와 지역에서 나는 때 "susurluk는"내가 볼 수있는 응용 프로그램을 사용하고 대신 저를 반환하는 susurluk 저를 반환 " balıkesir ". 그리고 두 개의 더 많은 지구"balıkesir ". –

+0

초기화하는 동안 좌표 (위도/경도)를 전달하여 수행 할 작업 또는 다른 작업; – Srinivas

답변

1

당신은 장소의 위도/경도를 보내 당신이 가지고있는 구글의지도 API를 사용하여 정확한 답변을 얻을 수 있으며 것 json/xml 형식으로 답을 얻으십시오. 이 질문에

Reverse Geocoding With Google Map API And PHP To Get Nearest Location Using Lat,Long coordinates

+0

대답 주셔서 감사하지만 내가 PHP와 연결해야합니까? 아이폰 GPS 혼자 작동하지 않습니다? 위치 –

+0

혼자 작동하지만 Google API에 의해 주어진 것입니다 답변을 찾을 수 있습니다. 나는 그것을 사용했습니다. 많은 앱과 모든 앱이 잘 작동합니다. – Ballu

관련 문제