From 256b7f489e24ba84b66638ba048b1b4fa4aeea33 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 23 Jul 2013 17:56:02 -0300 Subject: Joining the two fitBounds implementations at showPolygonFromQuery() --- gmap_arcgis.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 7d87820..018e470 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -536,6 +536,7 @@ function gmapArcgis(config) { // Show a polygon resulting from the given query showPolygonFromQuery: function(params) { var self = this; + var limit = null; var layer = new gmaps.ags.Layer(params.uri); var query = { returnGeometry: true, @@ -546,7 +547,6 @@ function gmapArcgis(config) { }; layer.query(query, function(fset) { - var limit; var fs = fset.features; params.overlay = []; @@ -558,14 +558,8 @@ function gmapArcgis(config) { if (params.fitBounds != undefined && params.fitBounds == true) { var bounds = params.overlay[i].getBounds(); - // 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 - if (limit.union == undefined) { + // Join bounds together + if (limit === null) { limit = bounds; } else { @@ -583,8 +577,13 @@ function gmapArcgis(config) { }); } - // Fit map to bounds, new version - self.map.fitBounds(limit); + // Fit map to limits + if (params.fitBounds != undefined && params.fitBounds == true) { + var zoom = self.getZoomByBounds(limit); + var center = limit.getCenter(); + self.map.setZoom(zoom); + self.setCenter(center, true); + } return params.overlay; }); -- cgit v1.2.3