diff options
author | Silvio <silvio@socioambiental.org> | 2013-07-23 14:11:50 -0300 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2013-07-23 14:11:50 -0300 |
commit | a40c14d2e6070972d5af9fb4972ae61f18744a00 (patch) | |
tree | e3e06eb942f4161dec70712ec35f32f298113561 | |
parent | 4ba0173083ec60cfdf546ba0a9d79a49ddcfc464 (diff) | |
download | gmap_arcgis_js-a40c14d2e6070972d5af9fb4972ae61f18744a00.tar.gz gmap_arcgis_js-a40c14d2e6070972d5af9fb4972ae61f18744a00.tar.bz2 |
Bounds should be calculated taking all features and not just the last one
-rw-r--r-- | gmap_arcgis.js | 16 |
1 files 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; }); }, |