I'm using this solution to get the extent of a query. It brings every feature geometry back to the client where I then calculate the extent of all the individual geometries. Since these can be polyline and polygon features this is a very expensive process. Is there a way to form the query so only the extent is returned?

    app.filter.on("zoom-to-features", () => {
    console.log("set map extent to include all annotations matching this criteria");
        .map(l => {
            var query = new EsriQuery();
            query.returnGeometry = true;
            query.outFields = [];
            query.where = where;
            return l.queryFeatures(query);
        })).then(results => {
            var features = <Array<{ features: Array<esri.Graphic> }>><any>results;
            var extents = features.map(result =>
                    .map(f => common.GeoUtil.getExtent(f.geometry))
                    .reduce((a, b) => a ? a.union(b) : b, null));

            var extent = extents.reduce((a, b) => a ? b ? a.union(b) : a : b, null);
            extent && app.map.setExtent(extent);


sounds like you want to be using graphicsUtils.graphicsExtent()


since my original post, it has also become possible both in ArcGIS Online hosted feature services and ArcGIS Server 10.3.1 to query explicitly for the extent of features by setting the new parameter returnExtentOnly to true

you can see an example in action here

  • Good point but that still required the geometries to be loaded on the client. – ca0v Mar 8 '14 at 14:22
  • thanks for the classification. I don't think you can form an ArcGIS Server query that returns only the extent of the matching features. – John Gravois Mar 9 '14 at 18:21

I suggest doing the graphicUtils.graphicsExtent(), but set a high maxAllowableOffset in your query. This will tremendously decrease server response time.


Consider either the queryExtent method of FeatureLayer or the executeForExtent method of queryTask.

  • Can you please edit your answer and expand with a bit more information on how and where to use your suggested solution? – Midavalo Sep 15 '16 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.