aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gmap_arcgis.js21
1 files 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;
});