Google Maps Control Options
Default Control Options for Google Maps:
Google Maps - Default Control Options:
When using a standard Google Map, its default settings include:
- .Zoom - Displays a slider to control the map's zoom level.
- .PPan - Displays a bowl-shaped control on the map, clicking the four corners pans the map.
- .MapType - Allows users to switch between map types (roadmap and satellite).
- .StreetView - Displays a Street View pegman icon that can be dragged to a point on the map to open Street View.
Google Maps - Additional Control Options
In addition to the default control options, Google also offers:
- .Scale - Displays the map scale.
- .Rotate - Displays a small circular icon that can rotate the map.
- .Overview Map - Provides a wide-angle view of the map.
You can specify which control options to display when creating a map by setting options or by calling setOptions() to change the map's settings.
Google Maps - Disabling Default Control Options
You may want to disable the default control options.
To disable the default control options, set the map's disableDefaultUI property to true:
Example
Google Maps - Enabling All Control Options
Some control options are displayed by default on the map, while others are not unless you set them.
Set controls to true to make them visible - set controls to false to hide them.
The following example enables all controls:
Example
Google Maps - Modifying Control Options
Some map controls are configurable. Change control options by specifying control option fields.
For example, modify the Zoom control options in zoomControlOptions. zoomControlOptions includes the following three options:
- .google.maps.ZoomControlStyle.SMALL - Displays a minimized zoom control.
- .google.maps.ZoomControlStyle.LARGE - Displays a standard zoom slider control.
- .google.maps.ZoomControlStyle.DEFAULT - Selects the most appropriate control based on device and map size.
Example
Note: If you need to modify a control, first enable the control (set it to true).
Another control is the MapType control.
The MapType control can be displayed as one of the following style options:
- google.maps.MapTypeControlStyle.HORIZONTAL_BAR, for displaying a set of controls in a horizontal bar as buttons as shown in Google Maps.
- google.maps.MapTypeControlStyle.DROPDOWN_MENU, for displaying a single button control to select a map type from a dropdown menu.
- google.maps.MapTypeControlStyle.DEFAULT, for displaying the "default" behavior, which depends on screen size and may change in future versions of the API.
Example
Similarly, you can use the ControlPosition property to specify the position of controls:
Example
Google Maps - Custom Control Options
Create a custom control that returns to London on click event (if the map is dragged):