お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
Earth Engine User Interface API
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Earth Engine は、ui
パッケージを介してクライアントサイドのユーザー インターフェース(UI)ウィジェットにアクセスできます。ui
パッケージを使用して、Earth Engine スクリプトのグラフィカル インターフェースを構築します。これらのインターフェースには、ボタンやチェックボックスなどのシンプルな入力ウィジェット、グラフや地図などの複雑なウィジェット、UI のレイアウトを制御するパネル、UI ウィジェット間のインタラクションのイベント ハンドラを含めることができます。コードエディタの左側にある [ドキュメント] タブで、ui
API のすべての機能を確認します。次の例では、ui
パッケージを使用して、ウィジェットの作成、ユーザーがウィジェットをクリックしたとき動作の定義、ウィジェットの表示の基本的な関数を示します。
Hello, world!
この例は、コンソールに表示されるボタンのシンプルな UI を表しています。ボタンをクリックすると、コンソールに「Hello, world!」と出力されます。
コードエディタ(JavaScript)
// Make a button widget.
var button = ui.Button('Click me!');
// Set a callback function to run when the
// button is clicked.
button.onClick(function() {
print('Hello, world!');
});
// Display the button in the console.
print(button);
まず、ボタンはラベルという単一の引数で作成されます。次に、ボタンの onClick()
関数が呼び出されます。onClick()
への引数は、ボタンがクリックされるたびに実行される別の関数です。イベントが発生したときに呼び出される関数(「コールバック」関数)のメカニズムは「イベント ハンドラ」と呼ばれ、UI ライブラリで広く使用されています。この例では、ボタンがクリックされると、関数は「Hello, world!」をコンソールに出力します。
可変性
ee.*
Namespace 内のオブジェクトとは異なり、ui.*
Namespace 内のオブジェクトは変更可能です。そのため、オブジェクトでインスタンス関数を呼び出すたびに、オブジェクトを変数に再割り当てする必要はありません。関数を呼び出すだけで、ウィジェットが変更されます。次のコードを前の例に追加すると、ボタンのクリック イベントに別のコールバックが登録されます。
コードエディタ(JavaScript)
// Set another callback function on the button.
button.onClick(function() {
print('Oh, yeah!');
});
このコードを前の例の末尾にコピーし、[実行] をクリックします。これで、ボタンをクリックすると、両方のメッセージがコンソールに出力されます。
Earth Engine スクリプトの UI の作成について詳しくは、UI のページをご覧ください。ウィジェット ページでは、ui
パッケージのウィジェットの基本機能について、視覚的なツアーと説明を提供しています。[パネルとレイアウト] ページでは、ウィジェットの整理と配置に使用できる最上位のコンテナとレイアウトについて説明します。[イベント ページ] には、UI 内のウィジェットの動作と操作の構成に関する詳細情報が記載されています。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-28 UTC。
[null,null,["最終更新日 2025-07-28 UTC。"],[[["\u003cp\u003eEarth Engine's \u003ccode\u003eui\u003c/code\u003e package enables the creation of interactive graphical user interfaces (GUIs) for your Earth Engine scripts, incorporating various widgets like buttons, charts, and maps.\u003c/p\u003e\n"],["\u003cp\u003eUI widgets are mutable, allowing modification by directly calling their instance functions without reassignment.\u003c/p\u003e\n"],["\u003cp\u003eEvent handlers, such as \u003ccode\u003eonClick()\u003c/code\u003e, are utilized to define widget behavior in response to user interactions.\u003c/p\u003e\n"],["\u003cp\u003eThe provided example demonstrates a simple button that prints a message to the console when clicked.\u003c/p\u003e\n"],["\u003cp\u003eComprehensive documentation on UI widgets, panels, layouts, and events is accessible through Earth Engine's guide pages.\u003c/p\u003e\n"]]],[],null,["# Earth Engine User Interface API\n\nEarth Engine provides access to client-side user interface (UI) widgets through the\n`ui` package. Use the `ui` package to construct graphical\ninterfaces for your Earth Engine scripts. These interfaces can include simple input\nwidgets like buttons and checkboxes, more complex widgets like charts and maps, panels\nto control the layout of the UI, and event handlers for interactions between UI\nwidgets. Explore the full functionality of the `ui` API in the\n**Docs** tab on the left side of the Code Editor. The following example uses\nthe `ui` package to illustrate basic functions for making a widget, defining\nbehavior for when the user clicks the widget, and displaying the widget.\n\nHello, world!\n-------------\n\nThis example represents a simple UI of a button displayed in the console. Clicking the\nbutton results in 'Hello, world!' getting printed to the console:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Make a button widget.\nvar button = ui.Button('Click me!');\n\n// Set a callback function to run when the\n// button is clicked.\nbutton.onClick(function() {\n print('Hello, world!');\n});\n\n// Display the button in the console.\nprint(button);\n```\n\nObserve that first, the button is created with a single argument: its label. Next,\nthe button's `onClick()` function is called. The argument to\n`onClick()` is another function that will get run whenever the button is\nclicked. This mechanism of a function to be called (a \"callback\" function) when an\nevent happens is called an \"event handler\" and is used widely in the UI library. In this\nexample, when the button is clicked, the function prints 'Hello, world!' to the console.\n\nMutability\n----------\n\nNote that unlike objects in the `ee.*` namespace, objects within the\n`ui.*` namespace are mutable. So you don't need to reassign the object to a\nvariable every time you call an instance function on the object. Simply calling the\nfunction will mutate (change) the widget. Appending the following code to the previous\nexample results in registering another callback for the button's click event:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Set another callback function on the button.\nbutton.onClick(function() {\n print('Oh, yeah!');\n});\n```\n\nCopy this code to the end of the previous example and click **Run**. Now\nwhen you click the button, both messages are printed to the console.\n\nUse the UI pages to learn more about building UIs for your Earth Engine scripts. The\n[Widgets page](/earth-engine/guides/ui_widgets) provides a visual tour and describes basic\nfunctionality of the widgets in the `ui` package. The [Panels\nand Layouts page](/earth-engine/guides/ui_panels) describes top-level containers and layouts you can use to organize\nand arrange widgets. The [Events page](/earth-engine/guides/ui_events) has details on configuring\nthe behavior and interaction of widgets in your UI."]]