[
https://issues.apache.org/jira/browse/CB-10370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16399617#comment-16399617
]
ASF GitHub Bot commented on CB-10370:
-------------------------------------
infil00p closed pull request #153: CB-10370: Added option useGeolocation. Also
fixed saving geolocation.
URL: https://github.com/apache/cordova-plugin-camera/pull/153
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/README.md b/README.md
index 700722b6..fe1be4b0 100644
--- a/README.md
+++ b/README.md
@@ -229,6 +229,7 @@ Optional parameters to customize the camera settings.
| saveToPhotoAlbum | <code>Boolean</code> | | Save the image to the photo
album on the device after capture. |
| popoverOptions |
<code>[CameraPopoverOptions](#module_CameraPopoverOptions)</code> | | iOS-only
options that specify popover location in iPad. |
| cameraDirection | <code>[Direction](#module_Camera.Direction)</code> |
<code>BACK</code> | Choose the camera to use (front- or back-facing). |
+| useGeolocation | <code>Boolean</code> | <code>set by CameraUsesGeolocation
preference</code> | For capturing JPEGs, set to true to get geolocation data in
the EXIF header. This will trigger a request for geolocation permissions if set
to true. |
---
diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m
index 850f4479..992ebb15 100644
--- a/src/ios/CDVCamera.m
+++ b/src/ios/CDVCamera.m
@@ -83,7 +83,7 @@ + (instancetype)
createFromTakePictureArguments:(CDVInvokedUrlCommand*)command
pictureOptions.cameraDirection = [[command argumentAtIndex:11
withDefault:@(UIImagePickerControllerCameraDeviceRear)] unsignedIntegerValue];
pictureOptions.popoverSupported = NO;
- pictureOptions.usesGeolocation = NO;
+ pictureOptions.usesGeolocation = [[command argumentAtIndex:12
withDefault:@(NO)] boolValue];
return pictureOptions;
}
@@ -146,7 +146,7 @@ - (void)takePicture:(CDVInvokedUrlCommand*)command
CDVPictureOptions* pictureOptions = [CDVPictureOptions
createFromTakePictureArguments:command];
pictureOptions.popoverSupported = [weakSelf popoverSupported];
- pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
+ pictureOptions.usesGeolocation = pictureOptions.usesGeolocation ||
[weakSelf usesGeolocation];
pictureOptions.cropToSize = NO;
BOOL hasCamera = [UIImagePickerController
isSourceTypeAvailable:pictureOptions.sourceType];
@@ -361,7 +361,7 @@ - (NSData*)processImage:(UIImage*)image
info:(NSDictionary*)info options:(CDVPic
if (options.usesGeolocation) {
NSDictionary* controllerMetadata = [info
objectForKey:@"UIImagePickerControllerMediaMetadata"];
if (controllerMetadata) {
- self.data = data;
+ self.data = UIImageJPEGRepresentation(image,
[options.quality floatValue] / 100.0f);
self.metadata = [[NSMutableDictionary alloc] init];
NSMutableDictionary* EXIFDictionary =
[[controllerMetadata
objectForKey:(NSString*)kCGImagePropertyExifDictionary]mutableCopy];
@@ -500,7 +500,8 @@ - (void)resultForImage:(CDVPictureOptions*)options
info:(NSDictionary*)info comp
[library writeImageToSavedPhotosAlbum:image.CGImage
orientation:(ALAssetOrientation)(image.imageOrientation) completionBlock:nil];
}
- completion(result);
+ if (result)
+ completion(result);
}
- (CDVPluginResult*)resultForVideo:(NSDictionary*)info
diff --git a/www/Camera.js b/www/Camera.js
index 5ddaf096..9210371b 100644
--- a/www/Camera.js
+++ b/www/Camera.js
@@ -147,9 +147,10 @@ cameraExport.getPicture = function(successCallback,
errorCallback, options) {
var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
var popoverOptions = getValue(options.popoverOptions, null);
var cameraDirection = getValue(options.cameraDirection,
Camera.Direction.BACK);
+ var useGeolocation = !!options.useGeolocation;
var args = [quality, destinationType, sourceType, targetWidth,
targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum,
popoverOptions, cameraDirection];
+ mediaType, allowEdit, correctOrientation, saveToPhotoAlbum,
popoverOptions, cameraDirection, useGeolocation];
exec(successCallback, errorCallback, "Camera", "takePicture", args);
// XXX: commented out
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Camera: Allow programmatically specify use of geolocation on iOS
> ----------------------------------------------------------------
>
> Key: CB-10370
> URL: https://issues.apache.org/jira/browse/CB-10370
> Project: Apache Cordova
> Issue Type: Improvement
> Components: cordova-plugin-camera
> Reporter: vldmrrrr
> Priority: Minor
>
> Currently the use of geolocation for taking pictures is specified only
> through preferences. The user might want to change geolocation preference
> while using application. Additional option in call getPicture can be used to
> specify the use of geolocation for each picture taken.
> Update: While adding the option I found that saving geolocation was broken -
> result was returned to javascript before location manager code had a chance
> to update image data. The fix for that is included in patch. The issue type
> is changed to Bug, and priority changed to major.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]