Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Google Maps Controls Set

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:


Google Maps - More Control Sets

In addition to the default control sets above, Google also has:

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:

Example

zoomControl

:

true

,

zoomControlOptions

:

{

  style

:

google

.

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:

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 »


Google Maps - Control Set Reference Manual

Google Maps API Reference Manual.