MKReverseGeocoder возвращает города, которые не являются городом?

Привет, я использую 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];

  }

}

1 ответ

Решение

Вы можете получить правильный ответ, используя API-интерфейс карты Google, в котором вам нужно отправить широту / длину места, и вы получите ответ в виде json/xml. Пожалуйста, проверьте этот вопрос

Обратное геокодирование с помощью Google Map API и PHP для получения ближайшего местоположения с использованием широты и длинных координат

Другие вопросы по тегам