Loop over each features of a layer

891
2
12-03-2020 09:57 AM
RabinSubedi
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({
        url:
        });
 

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

Thanks!

0 Kudos
2 Replies
BlakeTerhune
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.

RabinSubedi
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