AnsweredAssumed Answered

Returning results from queryFeatures?

Question asked by ibroad on Oct 11, 2018
Latest reply on Oct 12, 2018 by rscheitlin

I want to reuse a bit of code that intersects features with a polygon and returns the intersected features, but I'm not positive how to do it.


on(dom.byId("Button"), "click", function() {
     var points = intersectPoints();
    // Do something with points

function intersectPoints() {
     var pointsQuery = new Query();

     pointsQuery.geometry = polygonSketchViewModel.graphic.geometry.extent;
     pointsQuery.outFields = ["*"];
     pointsQuery.spatialRelationship = "intersects";

     var points = layers.findSublayerById(5);

     return points.queryFeatures(pointsQuery)


How do I return data to the points variable? I've tried different places with return and tried using await, but I either get nothing or errors. Any tips? I'm using 4.x.