"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Control Viewable Area and Zoom Level in Google Maps v3?

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

Published on 2024-11-24
Browse:520

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.

Release Statement This article is reprinted at: 1729252515 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3