Index: js/marker.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/js/marker.js,v
retrieving revision 1.4
diff -u -p -r1.4 marker.js
--- js/marker.js	11 Feb 2009 19:12:12 -0000	1.4
+++ js/marker.js	15 Apr 2009 11:24:00 -0000
@@ -89,7 +89,13 @@ Drupal.gmap.addHandler('gmap', function 
     // If we are autozooming, set the map center at this time.
     if (obj.vars.behavior.autozoom) {
       if (!obj.bounds.isEmpty()) {
-        obj.map.setCenter(obj.bounds.getCenter(), Math.min(obj.map.getBoundsZoomLevel(obj.bounds), obj.vars.maxzoom));
+        var SW = obj.bounds.getSouthWest();
+        var NE = obj.bounds.getNorthEast();
+        var height = NE.lat() - SW.lat();
+        var width = NE.lng() - SW.lng();
+        // Set a 5% margin for left, right, and bottom, but 10% margin for top as markers are tall and need extra space
+        var marginBounds = new GLatLngBounds(new GLatLng(SW.lat() - 0.05*height, SW.lng() - 0.05*width), new GLatLng(NE.lat() + 0.10*height, NE.lng() + 0.05*width) );
+        obj.map.setCenter(marginBounds.getCenter(), Math.min(obj.map.getBoundsZoomLevel(marginBounds), obj.vars.maxzoom));
       }
     }
   });
