konstantinbueschel
10/27/2015 - 3:18 PM

Google MAP API v3: Center & Zoom on displayed markers Source: http://stackoverflow.com/a/2819013

Google MAP API v3: Center & Zoom on displayed markers

Source: http://stackoverflow.com/a/2819013

// map: an instance of GMap3
// latlng: an array of instances of GLatLng
var mapBounds = new google.maps.LatLngBounds();

latlng.each(function(n) {
  
  mapBounds.extend(n);
  
  return;
});

map.setCenter(mapBounds.getCenter());
map.fitBounds(mapBounds);