Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Get Location (Latitude and Longitude) of Gallery Image

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.23k
    Comment on it

    If you are using ImagePickerController and wants to get selected Image location then use below code:-

    - (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)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)
        {
            NSMutableDictionary *assetMetadata = [[[myasset defaultRepresentation] metadata] mutableCopy];
                   // Get the location property from the asset
            CLLocation *assetLocation = [myasset valueForProperty:ALAssetPropertyLocation];
            NSDictionary *gpsData = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithDouble:[assetLocation coordinate].longitude], @"Longitude",     [NSNumber numberWithDouble:[assetLocation coordinate].latitude], @"Latitude", nil];
            [assetMetadata setObject:gpsData forKey:@"Location Information"];
        };
        // This block will handle errors:
        ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
        {
            NSLog(@"Can not get asset - %@",[myerror localizedDescription]);
            // Do something to handle the error
        };
    
        ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
        [assetslibrary assetForURL:url
                       resultBlock:resultblock
                      failureBlock:failureblock];
    
        // Use the url to get the asset from ALAssetsLibrary,
        // the blocks that we just created will handle results
    
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: