AnsweredAssumed Answered

featureLayer.queryFeatures order by closest first?

Question asked by shakiltmbc on Nov 9, 2018
Latest reply on Nov 9, 2018 by rscheitlin

I have a function that queries features that appear within a buffer around a given point on a feature layer.

function queryLayer(layer, buffer, point){
  var query = layer.createQuery();
  query.geometry = buffer;
  query.spatialRelationship = "intersects";
  layer.queryFeatures(query).then(function(results){
    console.log(results.features);
  });
}

I know that 

query.orderByFields = "..."

exists but I'm not sure how to go about using it. Is there a good way I can use the point variable to say "order by closest to this point"?

Outcomes