Monday 3 March 2014

Find Longitude and Latitude From Address String


 CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    NSString *addressString =@"Apple Inc";
    [geocoder
     geocodeAddressString:addressString
     completionHandler:^(NSArray *placemarks,
                         NSError *error) {
         if (error) {
             NSLog(@"Geocode failed with error: %@", error);
             return;
         }
         if (placemarks && placemarks.count > 0)
         {
             CLPlacemark *placemark = placemarks[0];

             CLLocation *location = placemark.location;
             NSLog(@"latitude = %f longitude = %f",location.coordinate.latitude , location.coordinate.longitude);
         }
     }];

No comments:

Post a Comment