Control Positioning

Learn how to change control element placement on the map.

Change the control position

To change the position of most controls on the map, we will modify the position property within the MapOptions object using google.maps.ControlPosition. Here’s an example of position the zoom control to the top-center of the map:

new google.maps.Map(document.getElementById("map"), {
        ...
	zoomControlOptions: {
		position: google.maps.ControlPosition.TOP_CENTER,
	},
});

The position property doesn’t fix the location of the control. Instead, it intelligently positions the control around existing control elements.

Supported control positions

The following control positions are supported by the Google Maps API:

Position Name

Description

TOP_CENTER

This property places the control towards the top-center of the map.

TOP_LEFT

This property places the control in the top-left section of the map, with sub-elements placed towards the top-center.

TOP_RIGHT

This property places the control in the top-right section of the map, with sub-elements placed towards the top-center.

LEFT_TOP

This property places the control in the top-left section of the map, with sub-elements placed below the top-left element.

RIGHT_TOP

This property places the control in the top-right section of the map, with sub-elements placed below the top-right element.

LEFT_CENTER

This property places the control at the left side of the map and is centered between the top-left and bottom-left control elements.

RIGHT_CENTER

This property places the control on the left side of the map and is centered between the top-right and bottom-right control elements.

LEFT_BOTTOM

This property places the control towards the bottom-left side of the map and above the bottom-left control elements.

RIGHT_BOTTOM

This property places the control towards the bottom-right side of the map and above the bottom-right control elements.

BOTTOM_CENTER

This property places the control towards the bottom-center of the map.

BOTTOM_LEFT

This property places the control towards the bottom-left section of the map, and the control’s sub-elements flow to the bottom-center element.

BOTTOM_RIGHT

This property places the control towards the bottom-right section of the map and the control’s sub-elements flow to the bottom-center element.

Code example

Here’s an example of a map with changes in the positions of the map type, zoom, and Street View controls:

Console
Control positioning

In the JavaScript file above, we change the default positions of the mapTypeControl, zoomControl, streetViewControl controls in lines 7, 11, and 15, respectively.