aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-04-09 13:03:13 -0300
committerSilvio <silvio@socioambiental.org>2013-04-09 13:03:13 -0300
commit23b2fe7322c049a98a66fa7449f8d142e7db36aa (patch)
treeb7a28c0f6f9f24f022e2ca8d18472ff3f2bf287d
parent68e9b33e0c1c6b6ecdcba0b7c75dffa50618b01a (diff)
downloadgmap_arcgis_js-23b2fe7322c049a98a66fa7449f8d142e7db36aa.tar.gz
gmap_arcgis_js-23b2fe7322c049a98a66fa7449f8d142e7db36aa.tar.bz2
Adding fitToBoundsOfQuery method
-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);
+ });
+ },
}
};