Zoom to species polygons (multiple records for one species)

1057
2
08-10-2016 12:37 AM
MarkBalman
Occasional Contributor

I have a layer of species polygons and want to zoom to a specific query where a species can have multiple range parts e.g. breeding and non breeding. I can get it to work if I dissolve the two ranges into one record but struggling to work out how to zoom

0 Kudos
2 Replies
FC_Basson
MVP Regular Contributor

If you are using a FeatureLayer, you can use the queryExtent (FeatureLayer | API Reference | ArcGIS API for JavaScript 3.17 ) or queryFeatures (FeatureLayer | API Reference | ArcGIS API for JavaScript 3.17 ) functions to determine the extent of the features based on an attribute query.

Something like:

var query = new esri.tasks.Query();  
query.where = "TYPE = 'breeding'"  
featureLayer.queryExtent(query,function(result){  
  map.setExtent(result.extent);  
}) 
MarkBalman
Occasional Contributor

Thank you for the help. Turns out that my original method was in fact working ok.

0 Kudos