1

Everything was going well with the app, except for this part, and after hours and hours of investigations, I couldn't find the reason for this apparently simple problem. Why the new points are not being added to the existing geometry? Apparently they are, but the download function is not behaving as a callback function. The link is returning an annoying empty csv instead of the new drawn points.

Any ideas here?

Code here

I bet it is something wrong in the callback function for the download button

function downloadGeo() {
  var featureCollection = ee.FeatureCollection([geometry]);
  var dbt = featureCollection.getDownloadURL({format:'csv',filename:'coordinates'});
  urlLabel.setUrl(dbt);
  urlLabel.style().set({shown: true});
}

1 Answer 1

3

Yes, the error is in the function above. You forgot to collect the geometries drawn. You were printing geometry which is (always) an empty object.

Use this function instead:

function downloadGeo() {
  var drawnGeometry = drawingTools.layers().get(0).getEeObject() // collect all drawn geometries
  var featureCollection = ee.FeatureCollection([drawnGeometry]);
  var dbt = featureCollection.getDownloadURL({format:'csv',filename:'coordinates'});
  urlLabel.setUrl(dbt);
  urlLabel.style().set({shown: true});
  print(drawnGeometry)
}

Link to corrected code.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.