Controlling Zoom and Pan Stay organized with collections Save and categorize content based on your preferences.
Page Summary
This documentation explains how to control user interactions, such as zoom and pan, on Google Maps using options like
gestureHandling,minZoom,maxZoom, andrestriction.The
gestureHandlingoption allows you to manage how the map responds to scroll events and touch gestures, with options likecooperative,greedy,auto, andnone.You can completely disable panning and zooming by setting
gestureHandlingto "none" andzoomControlto false.The
restriction,minZoom, andmaxZoomoptions can be used to limit the map's viewable area and zoom levels, providing further control over user interaction.
Overview
The usage of a map on a web page may require specific options to control the way users interact with the map to zoom and pan. These options, such asgestureHandling,minZoom,maxZoom andrestriction, are defined within theMapOptions interface.
Default Behavior
The following map demonstrates the default behavior for map interactions with a map instantiated with only thezoom andcenter options defined.
The code for this map is below.
TypeScript
newgoogle.maps.Map(document.getElementById("map")!,{zoom,center,});
JavaScript
newgoogle.maps.Map(document.getElementById("map"),{zoom,center,});
Controlling Gesture Handling
When a user scrolls a page that contains a map, the scrolling action canunintentionally cause the map to zoom. This behavior can be controlled using thegestureHandling map option.
gestureHandling:cooperative
The map below uses thegestureHandling option settocooperative, allowing the user to scroll the page normally, without zoomingor panning the map. Users can zoom the map by clicking the zoom controls. Theycan also zoom and pan by using two-finger movements on the map for touchscreendevices.
The code for this map is below.
TypeScript
newgoogle.maps.Map(document.getElementById("map")!,{zoom,center,gestureHandling:"cooperative",});
JavaScript
newgoogle.maps.Map(document.getElementById("map"),{zoom,center,gestureHandling:"cooperative",});
gestureHandling:auto
The map at the top of the page without thegestureHandling option has the samebehavior as the preceding map withgestureHandlingset tocooperative because all of the maps on this page are within an<iframe>. The defaultgestureHandling valueauto switches betweengreedy andcooperative based upon whether the map iscontained within an<iframe>.
Map contained within<iframe> | Behavior |
|---|---|
| yes | cooperative |
| no | greedy |
gestureHandling:greedy
A map withgestureHandling set togreedy isbelow. This map reacts to all touch gestures and scroll events unlikecooperative.
gestureHandling:none
ThegestureHandling option can also be set tonone to disable gestures on the map.
gestureHandling option does not apply to the Street View service.Disabling Pan and Zoom
To entirely disable the ability to pan and zoom the map, two options,gestureHandling andzoomControl, must be included.
TypeScript
newgoogle.maps.Map(document.getElementById("map")!,{zoom,center,gestureHandling:"none",zoomControl:false,});
JavaScript
newgoogle.maps.Map(document.getElementById("map"),{zoom,center,gestureHandling:"none",zoomControl:false,});
The map below demonstrates the combination ofgestureHandling andzoomControl in the code above.
Restricting Map Bounds and Zoom
It may be desireable to allow gestures and zoom controls but restrict the map toa particular bounds or a minimum and maximum zoom. To accomplish this you mayset therestriction,minZoom,andmaxZoom options. The following code and mapdemonstrate these options.
TypeScript
newgoogle.maps.Map(document.getElementById("map")!,{zoom,center,minZoom:zoom-3,maxZoom:zoom+3,restriction:{latLngBounds:{north:-10,south:-40,east:160,west:100,},},});
JavaScript
newgoogle.maps.Map(document.getElementById("map"),{zoom,center,minZoom:zoom-3,maxZoom:zoom+3,restriction:{latLngBounds:{north:-10,south:-40,east:160,west:100,},},});
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.