公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ui.root.onResize
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
註冊在指令碼啟動時及瀏覽器視窗大小變更時觸發的回呼。系統會將物件傳遞至這個函式,其中包含布林值欄位「is_mobile」、「is_tablet」、「is_desktop」、「is_portrait」和「is_landscape」,以及數值欄位「width」和「height」。
這些欄位會指出使用者的裝置是行動裝置、平板電腦還是桌機、裝置螢幕方向 (直向或橫向),以及視窗的寬度和高度 (單位為像素)。前往 https://material.io/resources/devices/,查看裝置指標的「寬度和高度 (dp)」部分。
用量 | 傳回 |
---|
ui.root.onResize(callback) | |
引數 | 類型 | 詳細資料 |
---|
callback | 函式 | 視窗大小調整完畢後要觸發的回呼。回呼會傳遞含有裝置資訊的物件。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eTriggers a provided function when the webpage loads or the browser window is resized.\u003c/p\u003e\n"],["\u003cp\u003eProvides details about the device used, such as whether it is a mobile, tablet, or desktop, its orientation (portrait or landscape), and the window's dimensions in pixels.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes boolean fields ("is_mobile", "is_tablet", "is_desktop", "is_portrait", "is_landscape") and numeric fields ("width", "height") within a passed object to convey device information.\u003c/p\u003e\n"],["\u003cp\u003eCan be implemented using \u003ccode\u003eui.root.onResize(callback)\u003c/code\u003e, where \u003ccode\u003ecallback\u003c/code\u003e represents the function to be executed.\u003c/p\u003e\n"]]],[],null,["# ui.root.onResize\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the script starts and whenever the browser window size changes. It will be passed an object with boolean fields \"is_mobile\", \"is_tablet\", \"is_desktop\", \"is_portrait\" and \"is_landscape\", and numeric fields \"width\" and \"height\".\n\n\u003cbr /\u003e\n\nThese fields indicate whether a user's device is mobile, tablet or desktop, the device orientation (portrait or landscape), and the width and height of the window in pixels. See the Width and Height (dp) section of device metrics at https://material.io/resources/devices/.\n\n| Usage | Returns |\n|------------------------------|---------|\n| `ui.root.onResize(callback)` | |\n\n| Argument | Type | Details |\n|------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | Function | The callback to fire after the window has been resized. The callback is passed an object with the information of the device. |"]]