公告:所有在
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 对象字典,以将显示在地图的地图类型控件中的名称为键。请参阅:https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyle |
types | List<String>,可选 | 要提供的 mapTypeId 的列表。如果省略,但指定了 opt_styles,则会将所有样式键附加到标准 Google Maps API 地图类型。 |
示例
代码编辑器 (JavaScript)
// Types
Map.setOptions('HYBRID');
Map.setOptions('ROADMAP');
Map.setOptions('SATELLITE');
Map.setOptions('TERRAIN');
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):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```"]]