Earth Engine User Interface API
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Earth Engine מספק גישה לווידג'טים של ממשק משתמש (UI) בצד הלקוח באמצעות החבילה ui
. אפשר להשתמש בחבילה ui
כדי ליצור ממשקים גרפיים לסקריפטים של Earth Engine. ממשקי המשתמש האלה יכולים לכלול ווידג'טים פשוטים של קלט, כמו לחצנים ותיבות סימון, ווידג'טים מורכבים יותר כמו תרשימים ומפות, חלוניות לצורך בקרה על הפריסה של ממשק המשתמש ומטפלי אירועים לאינטראקציות בין ווידג'טים של ממשק המשתמש. תוכלו לקרוא על כל הפונקציות של ה-API של ui
בכרטיסייה Docs בצד ימין של עורך הקוד. בדוגמה הבאה נעשה שימוש בחבילה ui
כדי להמחיש פונקציות בסיסיות ליצירת ווידג'ט, להגדרת התנהגות כשהמשתמש לוחץ על הווידג'ט ולהצגת הווידג'ט.
שלום עולם!
הדוגמה הזו מייצגת ממשק משתמש פשוט של לחצן שמוצג במסוף. לחיצה על הלחצן תוביל להדפסת 'Hello, world!' במסוף:
Code Editor (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()
הוא פונקציה אחרת שתופעל בכל פעם שלוחצים על הלחצן. המנגנון הזה של קריאה לפונקציה (פונקציית 'קריאה חוזרת') כשאירוע מתרחש נקרא 'טיפול באירוע', והוא נמצא בשימוש נרחב בספריית ממשק המשתמש. בדוגמה הזו, כשמקישים על הלחצן, הפונקציה מדפיסה את הטקסט 'Hello, world!' במסוף.
יכולת שינוי
הערה: בניגוד לאובייקטים במרחב השמות ee.*
, אובייקטים במרחב השמות ui.*
הם משתנים. כך לא צריך להקצות מחדש את האובייקט למשתנה בכל פעם שמפעילים פונקציית מופע על האובייקט. פשוט קריאה לפונקציה תגרום למוטציה (שינוי) של הווידג'ט. הוספת הקוד הבא לדוגמה הקודמת תוביל לרישום קריאה חוזרת (callback) נוספת לאירוע הלחיצה על הלחצן:
Code Editor (JavaScript)
// Set another callback function on the button.
button.onClick(function() {
print('Oh, yeah!');
});
מעתיקים את הקוד הזה לסוף הדוגמה הקודמת ולוחצים על הפעלה. עכשיו, כשלוחצים על הלחצן, שתי ההודעות מודפסות במסוף.
בדפי ממשק המשתמש תוכלו לקרוא מידע נוסף על פיתוח ממשקי משתמש לסקריפטים של Earth Engine. בדף הווידג'טים מופיע סיור חזותי ומתוארת הפונקציונליות הבסיסית של הווידג'טים בחבילה ui
. בדף Panels and Layouts מתוארים קונטיינרים ופלטפורמות ברמה העליונה שאפשר להשתמש בהם כדי לארגן ולסדר ווידג'טים. בדף 'אירועים' מוסבר איך מגדירים את ההתנהגות ואת האינטראקציה של ווידג'טים בממשק המשתמש.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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."]]