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.
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