公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ui.Map.setLocked
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
限制地圖的平移和縮放功能。
- 如要同時鎖定平移和縮放,請將 locked 設為 true,其他則不變。
- 如要允許平移並限制最小和最大縮放等級,請將 locked 設為 false,並提供 minZoom 和 maxZoom 參數。
- 如要禁止平移並限制最小和最大縮放等級,請將 locked 設為 true,並提供 minZoom 和 maxZoom 參數。
- 如要將地圖重設為預設值,請將 locked 設為 false,其他則不變。
用量 | 傳回 |
---|
Map.setLocked(locked, minZoom, maxZoom) | |
引數 | 類型 | 詳細資料 |
---|
這個:ui.map | ui.Map | ui.Map 執行個體。 |
locked | 布林值 | 地圖是否應鎖定。 |
minZoom | 號碼 (選填) | (選用) 地圖的最小縮放等級,介於 0 到 24 之間,含首尾兩值。 |
maxZoom | 號碼 (選填) | (選用) 地圖的最大縮放比例,介於 0 到 24,含首尾兩值。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eMap.setLocked()\u003c/code\u003e controls the panning and zooming behavior of the map.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003elocked\u003c/code\u003e to \u003ccode\u003etrue\u003c/code\u003e restricts panning and, optionally, allows setting zoom limits with \u003ccode\u003eminZoom\u003c/code\u003e and \u003ccode\u003emaxZoom\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003elocked\u003c/code\u003e to \u003ccode\u003efalse\u003c/code\u003e with no other parameters resets the map to default behavior.\u003c/p\u003e\n"],["\u003cp\u003eProviding \u003ccode\u003eminZoom\u003c/code\u003e and/or \u003ccode\u003emaxZoom\u003c/code\u003e along with \u003ccode\u003elocked\u003c/code\u003e sets zoom limitations, while the presence or absence of \u003ccode\u003elocked\u003c/code\u003e dictates panning restrictions.\u003c/p\u003e\n"]]],[],null,["# ui.Map.setLocked\n\n\u003cbr /\u003e\n\nLimits panning and zooming on the map.\n\n\u003cbr /\u003e\n\n- To lock both panning and zooming, set locked to true and nothing else.\n\n- To allow panning and limit the min and max zoom, set locked to false and supply the minZoom and maxZoom parameters.\n\n- To disallow panning and limit min and max zoom, set locked to true and supply the minZoom and maxZoom parameters.\n\n- To reset the map to default, set locked to false and nothing else.\n\n| Usage | Returns |\n|----------------------------------------------------|---------|\n| Map.setLocked`(locked, `*minZoom* `, `*maxZoom*`)` | |\n\n| Argument | Type | Details |\n|----------------|------------------|-----------------------------------------------------------------------|\n| this: `ui.map` | ui.Map | The ui.Map instance. |\n| `locked` | Boolean | Whether the map should be locked or not. |\n| `minZoom` | Number, optional | (optional) The minimum zoom for the map, between 0 and 24, inclusive. |\n| `maxZoom` | Number, optional | (optional) The maximum zoom for the map, between 0 and 24, inclusive. |"]]