From a40c14d2e6070972d5af9fb4972ae61f18744a00 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 23 Jul 2013 14:11:50 -0300 Subject: Bounds should be calculated taking all features and not just the last one --- gmap_arcgis.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 7fe4fca..70adb19 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -527,6 +527,7 @@ function gmapArcgis(config) { layer.query(query, function(fset) { var fs = fset.features; + var limit = new google.maps.LatLngBounds(); params.overlay = []; for (i in fs) { @@ -536,11 +537,15 @@ function gmapArcgis(config) { // Fit map to polygon bounds if (params.fitBounds != undefined && params.fitBounds == true) { var bounds = params.overlay[i].getBounds(); - var zoom = self.getZoomByBounds(bounds); - var center = bounds.getCenter(); - self.map.setZoom(zoom); - self.setCenter(center, true); + // Fit map to bounds, old version + //var zoom = self.getZoomByBounds(bounds); + //var center = bounds.getCenter(); + //self.map.setZoom(zoom); + //self.setCenter(center, true); + + // Fit map to bounds, new version + limit.union(bounds); } // Show polygon @@ -553,6 +558,9 @@ function gmapArcgis(config) { }); } + // Fit map to bounds, new version + self.map.fitBounds(limit); + return params.overlay; }); }, -- cgit v1.2.3