NSLeader
NSLeader

Reputation: 354

How to identify the country by clicking on the map?

For example, touch a region of the map and saw the alert with the name of the country, the clicked

Upvotes: 0

Views: 344

Answers (2)

NSLeader
NSLeader

Reputation: 354

Thank you all figured out

CLLocation *location = [[CLLocation alloc] initWithLatitude:55.755773 longitude:37.617761];
CLGeocoder *geocoder = [CLGeocoder new];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
    CLPlacemark *placemark = [placemarks objectAtIndex:0];

    NSLog(@"%@ %@ %@ %@ %@ %@ %@ %@", placemark.country, placemark.ISOcountryCode, placemark.postalCode, placemark.administrativeArea, placemark.locality, placemark.subLocality, placemark.thoroughfare, placemark.subThoroughfare);
}];

Upvotes: 2

Minthos
Minthos

Reputation: 900

Search for "reverse geocoding"

Upvotes: 1

Related Questions