Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

Take picture with geo location doesn’t work!


I am trying to figure out how can I get the photo with geolocation data.
I set the camera preferences as TRUE in config file but it didn’t work as expected. The app ends immediately without any information.
<preference name="CameraUsesGeolocation" value="true" />
In console I see the following error:
[887] <Error>: ImageIO: CGImageSourceCreateWithData data parameter is nil
[887] <Error>: ImageIO: CGImageSourceGetType image source parameter is nil
[887] <Error>: ImageIO: CGImageDestinationAddImageFromSource image destination parameter is nil
[887] <Error>: ImageIO: CGImageDestinationFinalize image destination parameter is nil
My environment is:
iOS 9.3.1
PhoneGap (iOS / Android / Windows)cli-5.4.1 (3.9.2 / 4.1.1 / 3.8.2)
Plugin: cordova-plugin-camera Version 2.1.1

Have anyone idea how to get photos with geo information into the app?
Thanks & Regards


I've found a workaround. I take the photo library instead of the camera and transferred data into the app model. The pictures from the library have all EXIF information (inclusive geolocation data) what I need.

Disadvantage: Each image is stored twice (one into the library and the other one into the app model).
Suggestion from my site: The app works only with native URI. Only before synchronizing the images are converted to BASE64.

My solution (proof of concept) looks like that:

var pictureSource;  //picture source
var destinationType;  //sets the format of returned value
// Wait for device API libraries to load
document.addEventListener("deviceready", onCamaraReady, false);
// device APIs are available
function onCamaraReady() {
  pictureSource = navigator.camera.PictureSourceType;
  destinationType = navigator.camera.DestinationType;
// A button will call this function
function capturePhoto() {
  //  Take picture using device camera and retrieve image as base64-encoded string
  navigator.camera.getPicture(onPhotoDataSuccess, onPhotoFail, {
  correctOrientation: true,
  sourceType: pictureSource.PHOTOLIBRARY, // Take picture from photo library
  destinationType: destinationType.NATIVE_URI
// Called when a photo is successfully retrieved
function onPhotoDataSuccess(imageData) {
// photo convert function
function uri2file(entry) {
// read data from library
function entryPhoto(file) {
  var reader = new FileReader();
  reader.onloadend = function(evt) {
  // Add converted photo to model
  newImage = {};
  newImage.KUNNR = modeloPageDetail.oData.KUNNR;
  newImage.IMAGE = evt.target.result; // Photo Base64 string
  ModelData.Add(oAdImageList, newImage);
// Called if something bad happens.
function onPhotoFail(message) {
  alert('Failed because: ' + message);
function uriError(error) {
  alert('Error' + error.code);
function entryFail(evt) {
  alert('Err: ' + evt.code);

Kind Regards,


Hi Gerhard,
Thank you very much for sharing this solution with us !  If you do not mind, I would like to also post it in the general forum so it is useful for other developers as well. :)

Kind regards,


Hi Julian!

It's OK from my side. I've an additional hint to this issue, if you are using the phonegap cli. Please use version 4.1.1 from the plugin cordova-plugin-file. With the latest version the BASE64 String is corrupted.

IS_IMAGE-PHOTO is the BASE64 string from the app.

ABAP Coding to decode the photo.

 shift IS_IMAGE-PHOTO up to ',' left.
 shift IS_IMAGE-PHOTO by 1 places left.

 data UTILITY type ref to CL_HTTP_UTILITY.
 create object UTILITY.

data LV_IMGX type XSTRING.

Kind Regards,


Thank you very much, Gerhard!

Login or Signup to post a comment