Select to view content in your preferred language

Navigate through all the features.

991
5
08-24-2010 04:21 AM
shafitrumboo
Occasional Contributor
In MY SFV, one widget is loaded at application startup (preloaded) . In the init methond of widget I want to navigate through all features of a layer that is added to map as featurelayer

I am able to  get the layer and also able to cast Layer into FeatureLayer.
But featurelay.featureCollection is null.
here is the code
var featurelayer:FeatureLayer;
for each (var layer:Layer in map.layers)
{
if( layer is FeatureLayer)
{
layer.refresh();
var featurelay:FeatureLayer = FeatureLayer(layer);
for each (var gra:Graphic in featurelay.featureCollection.featureSet.features)
{
gra.addEventListener(MouseEvent.MOUSE_OVER, rollOverGraphic);
gra.addEventListener(MouseEvent.ROLL_OUT, rollOutGraphic);
}
}
}
Tags (2)
0 Kudos
5 Replies
DasaPaddock
Esri Regular Contributor
The features can be found in the inherited graphicProvider property.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#graphicProvider

The featureCollection is used when you want to initialize the FeatureLayer with features from outside of ArcGIS Server like in this sample:
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=TemporalRenderer_FeatureCollection
0 Kudos
BjornSvensson
Esri Regular Contributor
FYI: the API Reference for FeatureLayer and FeatureCollection has been updated today to better explain feature collections.  Hopefully the new information will be helpful:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/supportClasses/FeatureCollection.ht...
0 Kudos
shafitrumboo
Occasional Contributor
But still featurelay.graphicProvider doesn't contain any Item. It's length is zero

Please help
0 Kudos
DasaPaddock
Esri Regular Contributor
You may be looking the the graphicProvider before the FeatureLayer has fetched the features from the server. To test this, don't preload the widget and instead open the widget after you see the features in the layer on the map.
0 Kudos
DasaPaddock
Esri Regular Contributor
Another option is to just listen for the inherited graphicAdd event and then add your mouse listeners there.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/GraphicsLayer.html#event:graphicAdd
0 Kudos