GMSReverseGeocodeResponse
contains
- (GMSReverseGeocodeResult *)firstResult;
whose definition is like:
@interface GMSReverseGeocodeResult : NSObject<NSCopying>
/** Returns the first line of the address. */
- (NSString *)addressLine1;
/** Returns the second line of the address. */
- (NSString *)addressLine2;
@end
Is there any way to obtain the country, ISO country code, state (administrative_area_1 or corresponding one) from those two strings (valid for all the countries and all the addresses)?
NOTE: I tried to execute this piece of code
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(40.4375, -3.6818) completionHandler:^(GMSReverseGeocodeResponse *resp, NSError *error)
{
NSLog( @"Error is %@", error) ;
NSLog( @"%@" , resp.firstResult.addressLine1 ) ;
NSLog( @"%@" , resp.firstResult.addressLine2 ) ;
} ] ;
But for some reason the handler was never called. I did add the app key, and also added the iOS bundle id to the app key. No error is printed in the console. With this I mean I am not aware of the content of the lines.
Best Answer
The simplest way is to upgrade to Version 1.7 of the Google Maps SDK for iOS (released February 2014).
From the release notes:
From
GMSAddress
Class Reference, you can find these properties:No ISO country code though.
Also note that some properties may return
nil
.Here's a full example:
and its output:
Alternatively, you may consider using Reverse Geocoding in the The Google Geocoding API (example).