I need to loop through features with already applied layer definition.
That means not to do additional query from a server, but get a FeatureSet from the client if possible.
Any help would be appreciated.
If the layer is added to the map as a FeatureLayer then yes you can just get the features on the client. If the layer you are interested in is a layer from a ArcGISDynamicMapServiceLayer then the client has no information about individual features it only has an image of the mapservice from the server.
Thank you for your response.
How we do it with FeatureLayer? What mode we need to use?
If the layer is added to the map as a FeatureLayer then you can get the graphics that the FeatureLayer has using the graphics property on the FeatureLayer class.
Thank you for the response.
I see that "graphics" property has length 0.
So, what I need to do to properly loop through?
Additional question: how to loop through all features in current extent (features that currently visible on a map)?
The only reason I can think that the FeatureLayer.graphics would be a zero length is that you are checking the length of the graphics before the layer is finished loading. Make sure you call the FeatureLayer.graphics after the load event for the FeatureLayer has fired.
To get the graphics that are only in the maps visible extent you will have to do a query on the FL using that maps extent property.
Thank you very much!
Maybe the issue - the mode we use.
What mode should be fro this
It depends on your needs:
In on-demand mode, the feature layer retrieves features from the server when needed. This is based on the requirements defined in the following properties:
In selection mode, features are retrieved from the server only when they are selected. Features are available on the client only while they are selected. To work with selected features:
When editing feature layers in selection mode, you will need to add the map service associated with the feature service to the map as a dynamic map service. If you do not have the map service added as a dynamic map service then the changes will not be visible because once the edits are complete the feature is no longer selected.
It just does not work!! Should the feature layer be VISIBLE?
No, visibility is not required, but like Robert said you must wait until the features are completely loaded and the definition query set. I've tested the principle of iterating through the featurelayer graphics and it works. For my test example the MODE_ONDEMAND was used.
Retrieving data ...