Is there a way to identify which ui.Map() instance a widget is located in when using multiple maps in Earth Engine?
For example, I have 2 maps, each having a textbox and a button. When a button is clicked, I want to print contents of a textbox from the same map with printAdjacentTextBoxValue()
callback function. I deliberately use the same function for both buttons in order to use the same logic for multiple maps depending on their context.
This is an example code:
var left_map = ui.Map();
var right_map = ui.Map();
var left_textBox = ui.Textbox({value: 'left one'});
var right_textBox = ui.Textbox({value: 'right one'});
var left_button = ui.Button('click', printAdjacentTextBoxValue);
var right_button = ui.Button('click', printAdjacentTextBoxValue);
// universal function to provide same logic for both maps,
// yeilding potentially different results based on a different state of elements
function printAdjacentTextBoxValue() {
var value;
// get value from a textBox from the same Map
print(vlaue);
}
ui.root.clear();
ui.root.add(left_map);
ui.root.add(right_map);
left_map.add(left_textBox);
right_map.add(right_textBox);
left_map.add(left_button);
right_map.add(right_button);