We want something like this leaflet fitBounds in our google maps application. We saw a few examples but it doesn't worked as expected. We tried to make the div as a google maps controller, extend the bounds manually but nothing from that worked...
function zoomToBounds(polygon){
bounds = new google.maps.LatLngBounds();
$.each(polygon, function( key, latLng ) {
bounds.extend(new google.maps.LatLng(latLng.lat, latLng.lng));
});
/////////////////////////////////////////////////////////////
// We saw a solution like this, but the zooming is a problem
//
// Extend bounds with a fake point:
/////////////////////////////////////////////////////////////
/*
if (this.map.getProjection()) {
proj = this.map.getProjection();
latlng = bounds.getSouthWest();
swPoint = proj.fromLatLngToPoint(latlng);
latlng2 = proj.fromPointToLatLng({
x: swPoint.x - 10,
y: swPoint.y
});
bounds.extend(latlng2);
}*/
this.map.fitBounds(bounds);
}