when we load a new map, we need to reset the zoom of the map if the markers are outside the view port that we currently have. So this code takes care of that
1 2 bounds = new GLatLngBounds 3 points.each(function(point){ 4 bounds.extend(point) 5 }) 6 map.setZoom(map.getBoundsZoomLevel(bounds))