aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gmap_arcgis.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index 77e0465..35cb70e 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -430,6 +430,29 @@ function gmapArcgis(config) {
}
return 0;
- }
+ },
+
+ // Center and zoom map to fit the polygon resulting from a query
+ fitToBoundsOfQuery: function(params) {
+ var self = this;
+ var layer = new gmaps.ags.Layer(params.uri);
+ var query = {
+ returnGeometry: true,
+ geometryType: 'esriGeometryPolygon',
+ where: params.where,
+ outFields: '*',
+ };
+
+ layer.query(query, function(fset) {
+ var fs = fset.features;
+ var feature = fs[0];
+ var bounds = feature.geometry[0].getBounds();
+ var zoom = self.getZoomByBounds(bounds);
+ var center = bounds.getCenter();
+
+ self.map.setZoom(zoom);
+ self.map.setCenter(center);
+ });
+ },
}
};