Goal c, how to get landmarks for coordinate data

I have a question related to reverse geocoding.

In my application, I have some coordinates (not my current coordinates), and I want to convert them to labels. I dug a lot of sites and codes, but they all relate to reverse geocoding the current location ...

Is there a way to get labels for specific coordinates (which are not the current location)?

And if there is, please help me with some code or links.

+5
source share
1 answer

You can achieve this in two ways: -

The first way: - Get information using google api

-(void)findAddresstoCorrespondinglocation
{
    NSString *str = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",myCoordInfo.latitude,myCoordInfo.longitude];
    NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
    [request setRequestMethod:@"GET"];
    [request setDelegate:self];
    [request setDidFinishSelector: @selector(mapAddressResponse:)];
    [request setDidFailSelector: @selector(mapAddressResponseFailed:)];
    [networkQueue addOperation: request];
    [networkQueue go];

}

In response, you will receive all the information about the location coordinates that you provided.

Second approach: -

a.) mapkit framework

b.) MKReverseGeocoder .h

MKReverseGeocoder *reverseGeocoder;

c.) .m

self.reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:cordInfo];
    reverseGeocoder.delegate = self;
    [reverseGeocoder start];

MKReverseGeocoder

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
    NSLog(@"MKReverseGeocoder has failed.");
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
    MKPlacemark * myPlacemark = placemark;
    NSString *city = myPlacemark.thoroughfare;
    NSString *subThrough=myPlacemark.subThoroughfare;
    NSString *locality=myPlacemark.locality;
    NSString *subLocality=myPlacemark.subLocality;
    NSString *adminisArea=myPlacemark.administrativeArea;
    NSString *subAdminArea=myPlacemark.subAdministrativeArea;
    NSString *postalCode=myPlacemark.postalCode;
    NSString *country=myPlacemark.country;
    NSString *countryCode=myPlacemark.countryCode;
    NSLog(@"city%@",city);
    NSLog(@"subThrough%@",subThrough);
    NSLog(@"locality%@",locality);
    NSLog(@"subLocality%@",subLocality);
    NSLog(@"adminisArea%@",adminisArea);
    NSLog(@"subAdminArea%@",subAdminArea);
    NSLog(@"postalCode%@",postalCode);
    NSLog(@"country%@",country);
    NSLog(@"countryCode%@",countryCode);

    }
+2

All Articles