お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
ui.Panel.style
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ウィジェットのスタイル ActiveDictionary を返します。この値を変更して、ウィジェットのスタイルを更新できます。
CSS のプロパティと同様に動作するプロパティ:
- height、maxHeight、minHeight(例: '100px')
- width、maxWidth、minWidth(例: '100px')
- パディング、マージン(例: '4px 4px 4px 4px' または単に '4px')
- color、backgroundColor(例:「red」または「#FF0000」)
- 枠線(例: '1px solid black')
- borderColor(例: 'red black blue #FF0000')
- borderRadius(例: '10px')
- borderStyle(例: 'solid dashed none dotted')
- borderWidth(例: '1px 0px 1px 0px')
- fontSize(例: '24px')
- fontStyle(例: 太字)
- fontWeight(例: 太字、100)
- fontFamily(例: monospace、serif)
- textAlign(例: 'left'、'center')
- textDecoration(例: underline、line-through)
- whiteSpace(例: nowrap、pre)
- 表示(true または false)
サポートされているカスタム レイアウト プロパティ(ui.Panel.Layout のドキュメントを参照):
- ストレッチ(「horizontal」、「vertical」、「both」)
- position('top-right'、'top-center'、'top-left'、'bottom-right'、...)
用途 | 戻り値 |
---|
Panel.style() | ui.data.ActiveDictionary |
引数 | タイプ | 詳細 |
---|
this: ui.widget | ui.Widget | ui.Widget インスタンス。 |
例
コードエディタ(JavaScript)
// Define a UI widget and add it to the map.
var widget = ui.Panel({style: {width: '400px', height: '200px'}});
Map.add(widget);
// View the UI widget's style properties; an ActiveDictionary.
print(widget.style());
// ActiveDictionaries are mutable; set a style property.
widget.style().set('backgroundColor', 'lightgray');
print(widget.style());
// Define the UI widget's style ActiveDictionary as a variable.
var widgetStyle = widget.style();
print(widgetStyle);
// Set the UI widget's style properties from the ActiveDictionary variable.
widgetStyle.set({border: '5px solid darkgray'});
print(widgetStyle);
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 2025-07-25 UTC。"],[[["\u003cp\u003e\u003ccode\u003ewidget.style()\u003c/code\u003e returns an ActiveDictionary that can be used to get and set the widget's style properties, similar to CSS.\u003c/p\u003e\n"],["\u003cp\u003eMany standard CSS properties like \u003ccode\u003ewidth\u003c/code\u003e, \u003ccode\u003eheight\u003c/code\u003e, \u003ccode\u003ecolor\u003c/code\u003e, \u003ccode\u003efontSize\u003c/code\u003e, etc., are supported for styling widgets.\u003c/p\u003e\n"],["\u003cp\u003eCustom layout properties like \u003ccode\u003estretch\u003c/code\u003e and \u003ccode\u003eposition\u003c/code\u003e are available for advanced layout control within UI panels.\u003c/p\u003e\n"],["\u003cp\u003eThe ActiveDictionary returned by \u003ccode\u003ewidget.style()\u003c/code\u003e is mutable, allowing for dynamic updates to the widget's appearance.\u003c/p\u003e\n"],["\u003cp\u003eYou can directly modify the style properties using the ActiveDictionary's \u003ccode\u003eset\u003c/code\u003e method or by assigning a new style object.\u003c/p\u003e\n"]]],["The `widget.style()` method returns an `ActiveDictionary` that represents a widget's style properties, allowing modifications to the widget's appearance. Modifiable properties include dimensions (height, width), spacing (padding, margin), colors (color, backgroundColor), text attributes (font, size, alignment, decoration), border, visibility, and white space handling. Custom layout properties like 'stretch' and 'position' are also supported. The `ActiveDictionary` can be updated using `set()` and then applied to the widget.\n"],null,["# ui.Panel.style\n\n\u003cbr /\u003e\n\nReturns the widget's style ActiveDictionary, which can be modified to update the widget's styles.\n\n\u003cbr /\u003e\n\nProperties which behave like their CSS counterparts:\n\n- height, maxHeight, minHeight (e.g. '100px')\n\n- width, maxWidth, minWidth (e.g. '100px')\n\n- padding, margin (e.g. '4px 4px 4px 4px' or simply '4px')\n\n- color, backgroundColor (e.g. 'red' or '#FF0000')\n\n- border (e.g. '1px solid black')\n\n- borderColor (e.g. 'red black blue #FF0000')\n\n- borderRadius (e.g. '10px')\n\n- borderStyle (e.g. 'solid dashed none dotted')\n\n- borderWidth (e.g. '1px 0px 1px 0px')\n\n- fontSize (e.g. '24px')\n\n- fontStyle (e.g. 'italic')\n\n- fontWeight (e.g. 'bold' or '100')\n\n- fontFamily (e.g. 'monospace' or 'serif')\n\n- textAlign (e.g. 'left' or 'center')\n\n- textDecoration (e.g. 'underline' or 'line-through')\n\n- whiteSpace (e.g. 'nowrap' or 'pre')\n\n- shown (true or false)\n\nSupported custom layout properties (see ui.Panel.Layout documentation):\n\n- stretch ('horizontal', 'vertical', 'both')\n\n- position ('top-right', 'top-center', 'top-left', 'bottom-right', ...)\n\n| Usage | Returns |\n|-----------------|--------------------------|\n| Panel.style`()` | ui.data.ActiveDictionary |\n\n| Argument | Type | Details |\n|-------------------|-----------|-------------------------|\n| this: `ui.widget` | ui.Widget | The ui.Widget instance. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Define a UI widget and add it to the map.\nvar widget = ui.Panel({style: {width: '400px', height: '200px'}});\nMap.add(widget);\n\n// View the UI widget's style properties; an ActiveDictionary.\nprint(widget.style());\n\n// ActiveDictionaries are mutable; set a style property.\nwidget.style().set('backgroundColor', 'lightgray');\nprint(widget.style());\n\n// Define the UI widget's style ActiveDictionary as a variable.\nvar widgetStyle = widget.style();\nprint(widgetStyle);\n\n// Set the UI widget's style properties from the ActiveDictionary variable.\nwidgetStyle.set({border: '5px solid darkgray'});\nprint(widgetStyle);\n```"]]