Select to view content in your preferred language

Loop over each features of a layer

12-03-2020 09:57 AM
New Contributor III

Hello ArcGIS Community!

I am new to ArcGIS API for javascript. I need to run a loop over each feature of this layer to calculate the sum of attribute "Length_Cal" and display features until the sum is less than 100. All remaining features should be hidden. The loop should run based on the attribute "PCR_NBR" in ascending order. Here is my layer:

var pavement = new FeatureLayer({

Apologies in advance if I am asking/don't know a simple thing.


0 Kudos
2 Replies
MVP Regular Contributor

If I'm understanding your intention correctly, you could query all the features (something like 1=1) then loop through the features in the FeatureSet to display only the ones you want. Here's a sample you could start with.

New Contributor III

Thanks for replying @BlakeTerhune. I am not that familiar with Query, but I will try if that works or not.


0 Kudos