Select to view content in your preferred language

How can I label features rendered in a feature layer?

3462
4
09-09-2010 12:27 PM
JordanParmer
Emerging Contributor
I'm using a FeatureLayer to render polygons on a Silverlight map.  I need to label each polygon with an attribute from the underlying feature class.  I know a DynamicMapServiceLayer supports labeling from the server, but I don't want to use a DynamicMapServiceLayer.  I can't figure out how to label a FeatureLayer since the Silverlight client handles the drawing. 

I tried modifying the symbology, but couldn't figure out how to get both a text symbol and fill symbol together.  Next, I looked at manually specifying a ControlTemplate for the symbol.  I could get the text to display, but not the fill on the polygon shape.

Ideas?
0 Kudos
4 Replies
by Anonymous User
Not applicable
The best solution is to publish a service with your labels annotated as you like, then turn them on and off as needed. However, if your stuck you can check out this sample.  It shows how to work with TextSymbols which you can assign to your graphics in the GraphicsCollection.  From FeatureLayer you can get a GraphicsCollection.  I have not tried this but it's something to attempt if you cannot add another layer containing annotations.

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AddGraphics
http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay...

Doug Carroll, ESRI Support Services SDK Team
http://support.esri.com/
0 Kudos
JordanParmer
Emerging Contributor
Thanks!  I'll experiment with both of those and see what works.
0 Kudos
MustafaOgurlu
Deactivated User
That's not useful.

Labels must be shown on map with FeatureLayer. So that I can open or close the label form legend.

But there is not support for this.
0 Kudos
SanajyJadhav
Deactivated User
One approach could be as below.

1. Use geometry service to get label points for the desired features.
2. Use text graphics at these points.This text would take on value based on some field.

HTH.
0 Kudos