公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
Map.setOptions
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
修改 Google 地圖基本地圖。可執行下列操作:
1) 設定目前的 MapType。2) 為基本地圖提供自訂樣式 (MapTypeStyles)。3) 設定基本地圖可用的 mapTypesIds 清單。
如果呼叫時未提供任何參數,地圖類型會重設為 Google 預設值。
傳回地圖。
| 用量 | 傳回 |
|---|
Map.setOptions(mapTypeId, styles, types) | ui.Map |
| 引數 | 類型 | 詳細資料 |
|---|
mapTypeId | 字串 (選用) | 用於設定基本地圖的 mapTypeId。可以是「ROADMAP」、「SATELLITE」、「HYBRID」或「TERRAIN」,用來選取標準 Google Maps API 地圖類型,也可以是 opt_styles 字典中指定的其中一個鍵。如果保留為空值,且 opt_styles 中只指定 1 種樣式,系統就會使用該樣式。 |
styles | 物件 (選用) | 自訂 MapTypeStyle 物件的字典,以會顯示在地圖 Map Type Controls 中的名稱做為鍵。請參閱:https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyle |
types | List<String> (選用) | 要提供的 mapTypeIds 清單。如果省略這個參數,但指定了 opt_styles,則會將所有樣式鍵附加至標準 Google Maps API 地圖類型。 |
範例
程式碼編輯器 (JavaScript)
// Types
Map.setOptions('HYBRID');
Map.setOptions('ROADMAP');
Map.setOptions('SATELLITE');
Map.setOptions('TERRAIN');
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],["This function, `Map.setOptions()`, modifies the Google Maps basemap. It can set the `mapTypeId` to \"ROADMAP,\" \"SATELLITE,\" \"HYBRID,\" or \"TERRAIN,\" or to a custom style from the `styles` dictionary. Custom styles (`styles`) are defined as `MapTypeStyle` objects. The available `mapTypeIds` displayed in the basemap can be defined in `types`. If called without arguments, the function reverts to the default Google map type. It returns the modified `ui.Map` object.\n"]]