Google Maps Controls Set
A Google Map - default control set settings:
Google Maps - default control set settings:
When using a standard Google Map, its default settings are as follows:
- .Zoom - displays a slider to control the Zoom level of the map
- .Pan - displays a saucer-like control on the map, click the four corners to pan the map
- .MapType - allows users to switch between map types (roadmap and satellite)
- .StreetView - displayed as a street view person icon, which can be dragged to a point on the map to open street view
Google Maps - More Control Sets
In addition to the default control sets above, Google also has:
- .Scale - displays the map scale bar
- .Rotate - displays a small circular icon that can rotate the map
- .Overview Map - view the map from a wide-area perspective
When creating a map, you can specify which control sets are displayed by setting options or change the map settings options by calling setOptions().
Google Maps - Disable Default Control Set
You may want to be able to disable the default control set.
To disable the default control set, set the map's disableDefaultUI property to true:
Example
disableDefaultUI:true
Try it »
Google Maps - Enable All Control Sets
Some control sets are displayed on the map by default, while others are not, unless you set them.
Set the control to true to make it visible - set the control to false to hide it.
The following example enables all controls:
Example
panControl:true,
zoomControl:true,
mapTypeControl:true,
scaleControl:true,
streetViewControl:true,
overviewMapControl:true,
rotateControl:true
Try it »
Google Maps - Modify Control Set
Some map controls are configurable. Change the control set by specifying the control options field.
For example, to modify the Zoom control options, specify them in zoomControlOptions. zoomControlOptions contains the following 3 options:
- google.maps.ZoomControlStyle.SMALL - displays a minimized zoom control
- google.maps.ZoomControlStyle.LARGE - displays the standard zoom slider control
- google.maps.ZoomControlStyle.DEFAULT - selects the most appropriate control based on device and map size
Example
zoomControl
:
true
,
zoomControlOptions
:
{
style
:
.
maps
.
ZoomControlStyle
.
SMALL
}
Try it »
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, used to display a set of controls as buttons in a horizontal bar as shown in Google Maps.
- google.maps.MapTypeControlStyle.DROPDOWN_MENU, used to display a single button control so you can select the map type from a drop-down menu.
- google.maps.MapTypeControlStyle.DEFAULT, used to display "default" behavior, which depends on screen size and may change in future versions of the API.
Example
mapTypeControl:true,
mapTypeControlOptions: {
style:google.maps.MapTypeControlStyle.DROPDOWN_MENU
}
Try it »
You can also use the ControlPosition property to specify the position of the control:
Example
mapTypeControl:true,
mapTypeControlOptions: {
style:google.maps.MapTypeControlStyle.DROPDOWN_MENU,
position:google.maps.ControlPosition.TOP_CENTER
}
Try it »
Google Maps - Custom Control Set
Create a custom control that returns to London, used for click events: (if the map is dragged):
Example
controlDiv.style.padding = '5px';
var controlUI = document.createElement('div');
controlUI.style.backgroundColor = 'yellow';
controlUI.style.border='1px solid';
controlUI.style.cursor = 'pointer';
controlUI.style.textAlign = 'center';
controlUI.title = 'Set map to London';
controlDiv.appendChild(controlUI);
var controlText = document.createElement('div');
controlText.style.fontFamily='Arial,sans-serif';
controlText.style.fontSize='12px';
controlText.style.paddingLeft = '4px';
controlText.style.paddingRight = '4px';
controlText.innerHTML = 'Home'
controlUI.appendChild(controlText);
Try it »