Question

I am using the following code to get the user's city and country in Iphone.

CLLocation *location = // Some location


 [[[CLGeocoder alloc] init] reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {}];

It works but the problem is that it returns the values in a specified language. For example, if the user's current country is UAE and City Dubai then it gives me values as دبي and لإمارات . I want to get these values in English, for example, Dubai and United Arab Emirates.

Was it helpful?

Solution

use this code to get detail.

#define REVERSE_GEO_CODING_URL @"https://maps.googleapis.com/maps/api/geocode/json?"

    NSString *urlStr = [NSString stringWithFormat:@"%@latlng=%@,%@&sensor=true",REVERSE_GEO_CODING_URL,latitude,longitude];

        DLog(@"%@",urlStr);
        NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
        NSString *json = [BKAPIClient handleConnection:request];
        [request release];
        if (json)
            return (NSMutableDictionary *)[json JSONValue];

I have tested this using saudi arabia's latlong and it return english address in return.

see this link its gives address of somewhere in Saudi arabia .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top