I have just copied the code on this question and applied my latitude and longitudes. However, the latitudes and longitudes will be dynamic, and the center
of th
First you can create a LatLngBounds object by including all the dynamically generated locations. Use the extend method to include the points. Then you can get the center of the bound using the getCenter method.
UPDATE:
Code:
var bound = new google.maps.LatLngBounds();
for (i = 0; i < locations.length; i++) {
bound.extend( new google.maps.LatLng(locations[i][2], locations[i][3]) );
// OTHER CODE
}
console.log( bound.getCenter() );
Illustration: