How do I set the zoom level to show all the markers on Google Maps?
In my Google Map there are different markers in different positions. I want to set google map zoo
set the Google Map zoom level to show all the markers?
var markers = [markerObj1, markerObj2, markerObj3];
var newBoundary = new google.maps.LatLngBounds();
for(index in markers){
var position = markers[index].position;
newBoundary.extend(position);
}
map.fitBounds(newBoundary);
The code above will automaticlly center and zoom your map so that all markers are visible.