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
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); })
Thank you for the help. Turns out that my original method was in fact working ok.