Control Positioning
Learn how to change control element placement on the map.
We'll cover the following
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 |
| This property places the control towards the top-center of the map. |
| This property places the control in the top-left section of the map, with sub-elements placed towards the top-center. |
| This property places the control in the top-right section of the map, with sub-elements placed towards the top-center. |
| This property places the control in the top-left section of the map, with sub-elements placed below the top-left element. |
| This property places the control in the top-right section of the map, with sub-elements placed below the top-right element. |
| This property places the control at the left side of the map and is centered between the top-left and bottom-left control elements. |
| This property places the control on the left side of the map and is centered between the top-right and bottom-right control elements. |
| This property places the control towards the bottom-left side of the map and above the bottom-left control elements. |
| This property places the control towards the bottom-right side of the map and above the bottom-right control elements. |
| This property places the control towards the bottom-center of the map. |
| 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. |
| 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:
In the JavaScript file above, we change the default positions of the mapTypeControl
, zoomControl
, streetViewControl
controls in lines 7, 11, and 15, respectively.