Monday 27 August 2012

Get Address From Latitude,Longitude....

Hi Friends,
Very simple method for get address from latitude and longitude method is bellow..


-(NSString *)getAddressFromLatLon:(double)pdblLatitude withLongitude:(double)pdblLongitude
{
    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%f,%f&output=csv",pdblLatitude, pdblLongitude];
    NSError* error;
    NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];
    locationString = [locationString stringByReplacingOccurrencesOfString:@"\"" withString:@""];
    return [locationString substringFromIndex:6];
}

and for get output just call this method like bellow..

NSString *strAddress = [self getAddressFromLatLon:yourLatitude withLongitude:yourLongitude];

NSLog(@"Address is %@",strAddress);



No comments:

Post a Comment