I am querying Esri REST endpoint to get features from a dataset, but how can I further query the resultset that comes back without making a call back out to the server?

I make an initial js call very broad so that I get all of the features I could possibly need. Then on that data set, in JavaScript, I want to make a sub query

Do I use Esri syntax against the local dataset somehow? Or is there a JavaScript query language? Or do I blindly loop over the dataset?

  • 1
    Once you've made a request to ArcGIS Server, you have a JSON object containing the matching features. If you wish to sub-set those features without a further query to the server, you'll probably need to write a function to iterate through all of the results, and keep the features that you wish to retain while ignoring the others. – Stephen Lead Jan 10 '18 at 17:22

You can further filter your collection of feature results using JavaScript. Suppose you want to filter the features based on an field called TYPE. Use the filter() method like so:

filteredFeatures = features.filter(function(x) { return x.attributes['TYPE'] == '2';});
  • 1
    that was what i wound up doing James, thanks for the tip. seems that the esri query task should just take a local dataset instead of a rest endpoint if you have it already. – VBAHole Jan 10 '18 at 21:01

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.