Showing Drawing Tools on Map in Google Earth Engine – Step-by-Step Guide

google-earth-enginegoogle-earth-engine-javascript-api

I want to display the drawing tools once the Map is cleared. For clearing the root I used these lines

ui.root.clear();
ui.root.add(ui.Map());

To display the drawing tools again I use this line of code

ui.Map.DrawingTools({
  shown: true
})

But drawing tools are not shown.

How do I achieve this?

Best Answer

ui.root.clear destroys the main ui.Map. You've created another Map (not the one that the global variable Map points to), so you need to keep it and reference the new one. Getting the drawingTools object from the map turn it on.

ui.root.clear()
var mymap = ui.Map()
ui.root.add(mymap)

var tools = mymap.drawingTools()
Related Question