0

I would like to reset a GEE App to its initial state. That includes removing the added Layers and geometries and clear the user entered values (textboxes,...). The App has a Map and Panel with some widgets. Basically I'm looking for the same behavior as refreshing the web-browser. I tried to add a ui.Button as follow:

var refreshButton = ui.Button({
  label: 'Reset App!',
  onClick: function() {
  //what to put here??
  }
});

I tried the Map.clear() and Panel.clear()but that is not the behavior I need. Any ideas ? thanks

1 Answer 1

1

Something like this?

var oldMap = ui.root.widgets().get(0)

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

newMap.add(ui.Button('Reset', function () {
  ui.root.clear()
  ui.root.add(oldMap)
}))

https://code.earthengine.google.com/737f135b65d72a24089ea51cdd1c4d19

1
  • Hi Daniel, how should be the code for only refreshing the app at the initial stage? Thanks! Commented Aug 30, 2020 at 18:27

Your Answer

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

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