Google Maps API \ GMap3 Create Boundaries and get center from a polygon
/**
* var 'polygon' created elsewhere
*/
//create bounds
var bounds = new google.maps.LatLngBounds();
var paths = polygon.getPaths();
var path;
for (var p = 0; p < paths.getLength(); p++) {
path = paths.getAt(p);
for (var i = 0; i < path.getLength(); i++) {
bounds.extend(path.getAt(i));
}
}
//get center
bounds.getCenter();