Select to view content in your preferred language

Graphics Layer vs. Feature Layer for Points

4235
5
Jump to solution
05-04-2012 01:17 PM
DanielSanders
Occasional Contributor
I have a map layer with around 2000 points. I need to build a Silverlight mapping application that will allow the user to select various criteria. When the user clicks a button it should display the points which match the selected values. My question is what is the most efficient way to accomplish this? I have thought of two approaches: graphics layer or feature layer.
1. Add a graphics layer to the mapping application that will be cleared each time the user clicks the button. Create a QueryTask to run against the map layer that will select the desired points, loop through the results and add a graphic to the graphics layer for each selected point.

2. Add a feature layer and initially specify a transparent color for the point symbol. When the user clicks the button, loop through the graphics collection of the feature layer and change the symbol color to black or transparent, depending on whether the point matches the selected criteria.

Which of these sounds better, or is there another approach I haven't considered?

Thank you
0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor
I see. If the selection is not based on geometry but rather through a query. I would still recommend FeatureLayer if you plan to use AttachmentEditor, FeatureDataForm, FeatureDataGrid because FeatureLayer keeps service metadata information (i.e. Fields, Domains, etc). It may be a good idea to make it OnDemand mode too if you're only concerned about displaying features within map's current extent. You can still update FeatureLayer.Where clause and call FeatureLayer.Update(), this will re-query the service. If you plan to use Snapshot mode, you may hit service limit but in this case if all features are on the client, you can use Linq query instead to filter the features on the layer. This may help you decide which mode to use: http://help.arcgis.com/en/webapi/silverlight/help/index.html#/Feature_layers/016600000015000000/

View solution in original post

0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
You can use FeatureLayer in SelectionOnly mode. You can try this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerSelection. Selection updates the GraphicCollection of FeatureLayer. This way you need not have all 2000 points in your layer.
0 Kudos
DanielSanders
Occasional Contributor
Thank you for your reply. I see that the example allows the user to select points with the mouse. Is there a way to select points in the feature layer programmatically? In my case, the points represent people. The user will select from an age range drop down menu. For instance, if they select "Under 20", then the application will need to query the layer for all of the points with age less than 20 and display them.

Thank you
0 Kudos
JenniferNery
Esri Regular Contributor
I see. If the selection is not based on geometry but rather through a query. I would still recommend FeatureLayer if you plan to use AttachmentEditor, FeatureDataForm, FeatureDataGrid because FeatureLayer keeps service metadata information (i.e. Fields, Domains, etc). It may be a good idea to make it OnDemand mode too if you're only concerned about displaying features within map's current extent. You can still update FeatureLayer.Where clause and call FeatureLayer.Update(), this will re-query the service. If you plan to use Snapshot mode, you may hit service limit but in this case if all features are on the client, you can use Linq query instead to filter the features on the layer. This may help you decide which mode to use: http://help.arcgis.com/en/webapi/silverlight/help/index.html#/Feature_layers/016600000015000000/
0 Kudos
DanielSanders
Occasional Contributor
Thank you for the suggestions. I see that the FeatureLayer contains a SelectionColor property. Is it possible to specify a Simple Marker Symbol to be used for rendering selected graphics instead of just a color?

I would like to have the feature layer render unselected points in a particular color, but render selected points with one of the animated custom marker symbols in the Symbol Gallery like CustomEnlargeGradientSymbol.
Thanks for your help...
0 Kudos
DanielSanders
Occasional Contributor
I answered my own question  by referring to the Graphics Selection sample....
0 Kudos