Earth Engine は、共有コンピューティング リソースを保護し、すべてのユーザーに信頼性の高いパフォーマンスを提供するために、
非商用割り当て階層を導入しています。すべての非商用プロジェクトは、
2026 年 4 月 27 日までに割り当て階層を選択する必要があります。選択しない場合は、デフォルトでコミュニティ階層が使用されます。階層の割り当ては、
2026 年 4 月 27 日に(階層の選択日に関係なく)すべてのプロジェクトで有効になります。
詳細
ui.root.setKeyHandler
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
事前定義されていないキーを使用して、keydown イベント ハンドラをルートパネルに設定します。ハンドラは、ユーザーがバインドされたキーコマンドを押したときに 1 回だけ起動されます。同じキーが、設定された最新のハンドラ セットにバインドされます。
| 用途 | 戻り値 |
|---|
ui.root.setKeyHandler(keyCode, handler, description) | |
| 引数 | タイプ | 詳細 |
|---|
keyCode | List[ui.Key]|ui.Key | キーコードまたはキーコードの配列。たとえば、ui.Key.A や [ui.Key.SHIFT, ui.Key.A] などです。 |
handler | 関数 | キーコマンドのハンドラ。 |
description | 文字列、省略可 | このキーコマンドの説明。説明はショートカット メニューに表示されます。 |
例
コードエディタ(JavaScript)
// Replace the default UI widgets with a few custom widgets.
// Print "Shift A" to the console when Shift+A is pressed.
ui.root.setKeyHandler(
[ui.Key.SHIFT, ui.Key.A],
function() {
print('Shift A');
},
'A simple print'
);
// Create a solid black image.
var blackImage = ee.Image(1).visualize({palette: ['black']});
// Create a Layer object so we can easily manipulate its properties.
var blackLayer = ui.Map.Layer(blackImage, {}, 'Black Overlay', true);
// Add the layer to the Map.
Map.layers().add(blackLayer);
// Pressing the "b" key will toggle the layer on and off.
ui.root.setKeyHandler(ui.Key.B, function() {
// Get the current visibility state.
var isShown = blackLayer.getShown();
// Set the visibility to the opposite of the current state.
blackLayer.setShown(!isShown);
// Print the status to the console.
print('Black layer visible: ' + !isShown);
}, 'Toggle black layer');
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2026-03-27 UTC。
[null,null,["最終更新日 2026-03-27 UTC。"],[],["The `setKeyHandler` function binds a key command to a handler function on the root panel. It accepts a key code (or array of codes), a handler function, and an optional description. When the bound key is pressed, the handler is executed once. Only the most recently assigned handler for a specific key will be triggered. Key codes can be individual (e.g., `ui.Key.A`) or combined (e.g., `[ui.Key.SHIFT, ui.Key.A]`). The description is used in the Shortcuts Menu.\n"]]