Home  >  Article  >  Web Front-end  >  How to Control Viewable Area and Zoom Level in Google Maps v3?

How to Control Viewable Area and Zoom Level in Google Maps v3?

Linda Hamilton
Linda HamiltonOriginal
2024-10-18 19:57:03436browse

How to Control Viewable Area and Zoom Level in Google Maps v3?

Controlling Viewable Area and Zoom Level in Google Maps v3

To restrict the viewable area in Google Maps v3, you can set the map's bounds using the setOptions() method. For example, to limit the view to a specific country:

map.setOptions({
  bounds: {
    north: 50,
    south: 20,
    west: -100,
    east: -50
  }
});

Restricting the zoom level can be achieved through options or event handling. To limit the zoom level using setOptions():

var zoomOptions = {
  minZoom: 6,
  maxZoom: 9
};
map.setOptions(zoomOptions);

Alternatively, you can use the zoom_changed event to dynamically check and reset the zoom level when it exceeds the specified limits.

The above is the detailed content of How to Control Viewable Area and Zoom Level in Google Maps v3?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn