Map.setOptions

  • Modifies the Google Maps basemap by setting the map type, providing custom styles, and controlling available map types.

  • Accepts parameters to change the basemap's appearance or resets to the default Google Maps style when called without parameters.

  • Offers flexibility in styling through custom MapTypeStyle objects and allows for selection from standard Google Maps API map types or custom styles.

  • Uses the setOptions() method with arguments for mapTypeId, styles, and types to implement the modifications.

  • Returns the ui.Map object after applying the specified options.

Modifies the Google Maps basemap. Allows for:

1) Setting the current MapType. 2) Providing custom styles for the basemap (MapTypeStyles). 3) Setting the list of available mapTypesIds for the basemap.

If called with no parameters, resets the map type to the google default.

Returns the map.

UsageReturns
Map.setOptions(mapTypeId, styles, types)ui.Map
ArgumentTypeDetails
mapTypeIdString, optionalA 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.
stylesObject, optionalA 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
typesList<String>, optionalA 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.

Examples

Code Editor (JavaScript)

// Types
Map.setOptions('HYBRID');
Map.setOptions('ROADMAP');
Map.setOptions('SATELLITE');
Map.setOptions('TERRAIN');