公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
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 (世界標準時間)。"],[[["\u003cp\u003eModifies the Google Maps basemap by setting the map type, providing custom styles, and controlling available map types.\u003c/p\u003e\n"],["\u003cp\u003eAccepts parameters to change the basemap's appearance or resets to the default Google Maps style when called without parameters.\u003c/p\u003e\n"],["\u003cp\u003eOffers flexibility in styling through custom MapTypeStyle objects and allows for selection from standard Google Maps API map types or custom styles.\u003c/p\u003e\n"],["\u003cp\u003eUses the \u003ccode\u003esetOptions()\u003c/code\u003e method with arguments for mapTypeId, styles, and types to implement the modifications.\u003c/p\u003e\n"],["\u003cp\u003eReturns the ui.Map object after applying the specified options.\u003c/p\u003e\n"]]],["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"],null,["# Map.setOptions\n\n\u003cbr /\u003e\n\nModifies the Google Maps basemap. Allows for:\n\n\u003cbr /\u003e\n\n1) Setting the current MapType. 2) Providing custom styles for the basemap (MapTypeStyles). 3) Setting the list of available mapTypesIds for the basemap.\n\nIf called with no parameters, resets the map type to the google default.\n\nReturns the map.\n\n| Usage | Returns |\n|----------------------------------------------------------|---------|\n| `Map.setOptions(`*mapTypeId* `, `*styles* `, `*types*`)` | ui.Map |\n\n| Argument | Type | Details |\n|-------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mapTypeId` | String, optional | A mapTypeId to set the basemap to. Can be one of \"ROADMAP\", \"SATELLITE\", \"HYBRID\" or \"TERRAIN\" to select one of the standard Google Maps API map types, or one of the keys specified in the opt_styles dictionary. If left as null and only 1 style is specified in opt_styles, that style will be used. |\n| `styles` | Object, optional | A dictionary of custom MapTypeStyle objects keyed with a name that will appear in the map's Map Type Controls. See: https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyle |\n| `types` | List\\\u003cString\\\u003e, optional | A list of mapTypeIds to make available. If omitted, but opt_styles is specified, appends all of the style keys to the standard Google Maps API map types. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Types\nMap.setOptions('HYBRID');\nMap.setOptions('ROADMAP');\nMap.setOptions('SATELLITE');\nMap.setOptions('TERRAIN');\n```"]]