Query Feature and Zoom

3017
12
01-06-2012 02:05 PM
CarlSunderman1
New Contributor II
I've searched here and the rest forums and can't seem to find an answer.

I have a php page that when a value is click, a fancybox iframe opens with data, a floor plan, and a map of the building. i have passed the variable to javascript but am unable to see how to pass the variable to the map to zoom to the feature(QueryTask?). i've tried using query?where= but i seem to be way off. i've looked into the QueryTask, but have been unable to find an example of what i'm trying to accomplish. Does anyone have an example i can look at?
0 Kudos
12 Replies
DavidSpriggs
New Contributor II
The simplest (and fastest) way to get the extent of an array of graphics is to use esri.graphicsExtent:

var Extent = esri.graphicsExtent(FeatureSet.features);


This is a little gem helper function found in the esri namespace:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/namespace_esri.htm#esr...
0 Kudos
ToddMcNeil1
New Contributor
I also have a need to iterate and union the geometry of each feature in my code.  I can iterate through each feature but I am having trouble union-ing the extents.  I basically get the extent of the last feature stored in fullExtent.

 var fullExtent;
    for (var i = 0, il = results.features.length; i < il; i++) {
      fullExtent = results.features.geometry.getExtent();
      fullExtent.union(fullExtent);
    }


Also, I have a need to select these features and display a graphic on the map.  I have a findtask setup but it is only useful for one feature at a time, at least this is what all the sample show.  i have not figured out how to make it work for multiple features.

Todd
0 Kudos
lbowne
by
New Contributor II
THANKS THAT HELPED ME !!!!
0 Kudos