Search code examples
iphoneobjective-cmkmapviewmkreversegeocoder

Getting Location Address from latitude and longitude


I am developing an application in which I have to show the address that of the given latitude and longitude. I have latitude and longitude but I dont know how to get my address from that latitude and longitude. Any suggestion will be highly appreciated Thanks in advance!


Solution

  • I have done something very similar to this recently. With the coordinates you can use MKReverseGeocoder to get the address.

    when you find the coordinates,

        self.reverseGeocoder =[[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate]autorelease];
        reverseGeocoder.delegate=self;
        [reverseGeocoder start];
    

    //called when reverseGeocoder was successfully able to retreive address

    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
        NSString *street=[placemark.addressDictionary objectForKey:@"Street"];
        //get the different address components
    }
    

    //called when reverseGeocoder was unable to retreive address

    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
    
    }
    

    Hope this helps