I have two layers in my GEE and I want to reset one of them base on my selector. I have the code as following:

Map.addLayer(UHIAdded, {opacity: 0.5}, 'layer1');  
Map.addLayer(uhiday, {min: -2.0, max: 3.0, palette: palette, opacity: 0.5}, 'UHI');

And there's the error:

Cannot add an object of type string as a layer.

If I get rid of the [], it will give me the error:

The argument provided to ui.List.reset() must be an array.

How do I specify the layer that I want to reset?

1 Answer 1


Without a working example it will be dificult to help you, below is an example that could help you with the logic of using .reset().

I'm assuming you are trying to use it for building widgets of some sort? It needs to be an ee.Map.Layer I think, before you can reset it:

var one = ui.Map.Layer(ee.Image(1))
var two = ui.Map.Layer(ee.Image(2))

  • Just to expand this a bit. Here is an example that adds two layers to the Map and then replaces one of them with a new layer using reset. Code Editor script Commented Dec 6, 2019 at 18:50
  • ...and at least in these examples, there is no need to cast the ee.Image as a ui.Map.Layer Commented Dec 6, 2019 at 18:56

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.