Yes, it is possible to adjust the zoom level after using the fitBounds method in Google Maps API v3. You can use the setZoom method to set the new zoom level. For example:
// Create a new map
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: {lat: 37.7749, lng: -122.4194}
});
// Create a LatLngBounds object
var bounds = new google.maps.LatLngBounds();
// Extend the bounds to include multiple locations
bounds.extend(new google.maps.LatLng(37.7749, -122.4194));
bounds.extend(new google.maps.LatLng(37.7749, -122.4195));
bounds.extend(new google.maps.LatLng(37.7748, -122.4194));
bounds.extend(new google.maps.LatLng(37.7748, -122.4195));
// Fit the map to the bounds
map.fitBounds(bounds);
// Set a new zoom level
map.setZoom(12);
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-14 11:00:00 +0000
Seen: 8 times
Last updated: Aug 10 '21
How can I modify the default font, scale, and zoom of the Spyder editor?
How can DIVs be aligned on top of each other in CSS irrespective of the zoom level?
On an iPhone in Safari, certain font sizes appear to be magnified.
How does the page alignment get disrupted when the zoom is out?
Can the output of Wkhtmltopdf be adjusted to fit the entire width of the page?