Select to view content in your preferred language

Loop through FeatureLayer setDefinitionExpression results

1644
3
03-18-2013 11:12 AM
p_thibault
Emerging Contributor
I am using a FeatureServer service with the FeatureLayer set to MODE_SNAPSHOT.   After doing a setdefinitionsexpression, the map updates itself to only show those features.

However, I now want to be able to loop through these newly identified features and label each one with some custom text.

My question is how does one loop through them?


.....
featureLayerpoint = new esri.layers.FeatureLayer("http://xyz/webadaptor_test/rest/services/TIPdataonly/FeatureServer/0", {         
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,         
infoTemplate: popupTemplate,        
outFields: ["*"]
  });
......
map.addLayer(featureLayerpoint);  
.....
featureLayerpoint.setDefinitionExpression(setdefinitionstring);

AT this point the map is updated.....how do I now work with the contents of the featureLayerpoint?
0 Kudos
3 Replies
StephenLead
Honored Contributor
featureLayerpoint.graphics will give you a pointer to the features in that layer. See http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/featurelayer.html#FeatureLayer/graphics
0 Kudos
MattLane
Frequent Contributor
Also, is there a reason you don't set the definition expression before adding it to the map?

You'll probably want to work with the data in the layer within the map's onLayerAdd event. If you try immediately after the map.addLayer then you won't get anything.
0 Kudos
p_thibault
Emerging Contributor
the set definition is done afterward to allow the users to "sort" through data and see only their matches.  So with a drop down menu they can find all the point that are related to certain government departments.  This part works well.


I still can not find a way to loop through the contents of featurePointlayer. 

I should be able to with the graphic... when I do a tooltip evt on them, I can retrieve the attributes...

var tipContent = "<b>PIN</b>: " + evt.graphic.attributes.PIN ;

I am just having a very brain-dead moment!
0 Kudos