event
事件由用户与小部件的交互或对小部件的编程更改触发。要在事件发生时执行某些操作,请使用onClick()
(ui.Map
或 ui.Button
) 或onChange()
(其他所有内容)在小部件上注册回调函数。您还可以在构造函数中指定回调。事件回调的参数因小部件和事件类型而异。例如,ui.Textbox
将当前输入的字符串值传递给它的 'click' 事件回调函数。检查文档选项卡中的 API 参考,了解传递给每个小部件回调函数的参数类型。
以下示例演示源自指定要显示的图像的单个用户操作的多个事件。当用户选择一个图像时,另一个选择小部件会更新为图像的波段并显示地图中的第一个波段:
函数:
ui.Select(items, placeholder, value, onChange, disabled, style)
A printable select menu with a callback.
Arguments:
items (List<Object>, optional):
The list of options to add to the select. Defaults to an empty array.
placeholder (String, optional):
The placeholder shown when no value is selected. Defaults to "Select a value...".
value (String, optional):
The select's value. Defaults to null.
onChange (Function, optional):
The callback to fire when an item is selected. The callback is passed the currently selected value and the select widget.
disabled (Boolean, optional):
Whether the select is disabled. Defaults to false.
style (Object, optional):
An object of allowed CSS styles with their values to be set for this widget. See style() documentation.
Returns: ui.Select
evaluate(callback)
Asynchronously retrieves the value of this object from the server and passes it to the provided callback function.
Arguments:
this:computedobject (ComputedObject):
The ComputedObject instance.
callback (Function):
A function of the form function(success, failure), called when the server returns an answer. If the request succeeded, the success argument contains the evaluated result. If the request failed, the failure argument will contains an error message.
代码:
这是srtm的高程影像: