Display images from virtual column

Hi!

I am currently working on an App to file and archive incidents, where an automation creates a PNG with a map showing where exactly this incident happened. For this I used the following code:

 

function generateMapImg(coordinatesLat, coordinatesLong, title) {
  var lat = parseFloat(coordinatesLat); //coordinatesLat is a String
  var long = parseFloat(coordinatesLong); //coordinatesLong is a String

  const map = Maps.newStaticMap()
  .setCenter(lat, long)
  .setSize(600, 400)
  .setZoom(18)
  .setMapType(Maps.StaticMap.Type.SATELLITE)
  .addMarker(lat, long)
  .getBlob();

  var curFolder = DriveApp.getFolderById('folderID');
  var curFile = curFolder.createFile(map);
  var fileRename = curFile.makeCopy(title + ".png");
  curFile.setTrashed(true);

}

 I tested the code and it works just fine. Now here comes my problem:

In order to test the code, I created a file (map.png) and added it to the folder without renaming it. Then I created a Virtual Column for these images so I can add the images to a PDF report later on.

This is my definition/formula for the column:

Name: Karte

Formular: CONCATENATE("folderID", [Title], ".png")

The formular does not seem to work; However, when I change it to CONCATENATE("folderID", โ€œmapโ€, ".png"), it shows the initial image, even after deleting it from the folder in question.

Can somebody tell me why this is? And how to fix it?

Thank you in advance

 

Note: I replaced the actual ID with the placeholder folderID

Solved Solved
0 1 366
1 ACCEPTED SOLUTION

The folder holding the images would have to be at the same level as the gsheet. Then the relative path would be "foldername/filename.png", not the folder ID.

View solution in original post

1 REPLY 1

The folder holding the images would have to be at the same level as the gsheet. Then the relative path would be "foldername/filename.png", not the folder ID.

Top Labels in this Space