Index: sites/default/modules/community/gmap/js/marker.js =================================================================== --- sites/default/modules/community/gmap/js/marker.js (revision 8475) +++ sites/default/modules/community/gmap/js/marker.js (revision 8476) @@ -12,7 +12,9 @@ obj.bind('init', function () { if (obj.vars.behavior.autozoom) { - obj.bounds = new GLatLngBounds(); + if (!obj.bounds) { + obj.bounds = new GLatLngBounds(); + } } }); Index: sites/default/modules/community/gmap/js/gmap_shapes.js =================================================================== --- sites/default/modules/community/gmap/js/gmap_shapes.js (revision 8475) +++ sites/default/modules/community/gmap/js/gmap_shapes.js (revision 8476) @@ -10,13 +10,15 @@ Drupal.gmap.addHandler('gmap', function (elem) { var obj = this; -/* + obj.bind('init',function() { if (obj.vars.behavior.autozoom) { - obj.bounds = new GLatLngBounds(new GLatLng(obj.vars.latitude,obj.vars.longitude),new GLatLng(obj.vars.latitude,obj.vars.longitude)); + if (!obj.bounds) { + obj.bounds = new GLatLngBounds(); + } } }); -*/ + obj.bind('prepareshape', function (shape) { var pa, cargs, style; //var m = new GMarker(new GLatLng(marker.latitude,marker.longitude),marker.opts); @@ -136,6 +138,10 @@ } obj.vars.shapes.push(shape); obj.map.addOverlay(shape.shape); + if (obj.vars.behavior.autozoom) { + obj.bounds.extend(shape.shape.getBounds().getSouthWest()); + obj.bounds.extend(shape.shape.getBounds().getNorthEast()); + } if (obj.vars.behavior.clickableshapes) { GEvent.addListener(shape.shape, 'click', function () { @@ -148,6 +154,15 @@ obj.map.removeOverlay(shape.shape); }); + obj.bind('shapesready', 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)); + } + } + }); + obj.bind('clearshapes', function () { if (obj.vars.shapes) { $.each(obj.vars.shapes, function (i, n) {