Zoom and center a GMap according to its markers is not working? Zooming and positioning the map to the center was not working in (Google map)
So we come up with small change in the code by adding time delay to it, then it was started working, may be it will use for someone.
  (fitbounds method googlemap api v3  for drupal 7 gmap) 

jQuery(document).ready(function() {
  // time delay for the maps to initialize.
  setTimeout(function() {

// Loop through all gmap instances.
jQuery(".gmap").each(function() {

  // Get a map reference using the element ID.
  gmapID = jQuery(this).attr("id");
  var gmap = Drupal.gmap.getMap(gmapID).map;

  // Ensure map exists.
  if (gmap) {
    alert(gmap.toSource());
    // Create a new map boundary.
    var bounds = new google.maps.LatLngBounds();
    // Iterate though the current maps marker collection.
    jQuery.each(gmap.markers, function(index) {
      // Find the current markers position (latitude, longitude).
      var data = gmap.markers[index];
      var pos = data.getPosition();

      // Extend the new boundary so the new marker/pin will be in view.
      bounds.extend(new google.maps.LatLng(pos.lat(), pos.lng()));
    });
    // Set the current maps bounding box to our new defined boundary.
    gmap.fitBounds(bounds);
  }
  else {
    // GMap was not initialised in time.
  }

});

 }, 100);
});


This is what the code We added time delay on top of it. https://stackoverflow.com/questions/3520810/zoom-and-center-a-google-map-according-to-its-markers-javascript-api-v3
Instead of a delay, wait for a map loaded event. I could not find a direct one so used a mutation event. 

MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

var observer = new MutationObserver(function(mutations, observer) {
  var target_id = mutations[0].target.id;
  var map = Drupal.gmap.getMap(target_id).map;
  if (typeof map != 'undefined') {
    var initialLocation = new google.maps.LatLng(old_lat, old_lon);
    map.setCenter(initialLocation);
    // map.vars.zoom
    map.setZoom(12);
  }
});

jQuery(".gmap").each(function() {
  var gmapID = jQuery(this).attr("id");

  observer.observe($("#" + gmapID)[0], {
    subtree: false,
    attributes: true
  });
});


Subtree = false should mean that once the map is loaded this doesn't get triggered again. Add another test if needed.