I would like to fetch latitude,longitude or address from photo which is taken from camera ,I have used the link iPhone Get UIImagePickerController Lat/Lng
and the code which I used is,
So this is how we handle the info given by the picker:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if ([picker sourceType] == UIImagePickerControllerSourceTypePhotoCamera) {
// We'll store the info to use in another function later
self.imageInfo = info;
// Get the asset url
NSURL *url = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
// We need to use blocks. This block will handle the ALAsset that's returned:
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
// Get the location property from the asset
CLLocation *location = [myasset valueForProperty:ALAssetPropertyLocation];
// I found that the easiest way is to send the location to another method
[self handleImageLocation:location];
};
// This block will handle errors:
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"Can not get asset - %@",[myerror localizedDescription]);
// Do something to handle the error
};
// Use the url to get the asset from ALAssetsLibrary,
// the blocks that we just created will handle results
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:url
resultBlock:resultblock
failureBlock:failureblock];
}
}
But the location variable returns nil. How extract the location or address from photo which is taken from camera.