From 23b2fe7322c049a98a66fa7449f8d142e7db36aa Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 9 Apr 2013 13:03:13 -0300 Subject: Adding fitToBoundsOfQuery method --- gmap_arcgis.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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); + }); + }, } }; -- cgit v1.2.3