Home > Web Front-end > JS Tutorial > body text

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

Linda Hamilton
Release: 2024-10-18 19:57:03
Original
435 people have browsed it

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
  }
});
Copy after login

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);
Copy after login

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!

source:php
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!