Select to view content in your preferred language

Labeling Features dynamically?

1041
8
03-31-2011 10:49 PM
UlfGrimhardt
Deactivated User
Hi

I have an Silverlight App with lots of Point Features in my map. Now i would like to be able to label some of the features (selected by query) dynamically with some attributes. I dont want to use the Tooltip, instead each Point should be labeld with a specific Text. The Problem is, that i dont want to label attributes from the FeatureClass but Values from a SQLServer Database. Is that possible?

I use ArcGIS Server 9.3.1.

Thanks in advance!
0 Kudos
8 Replies
JenniferNery
Esri Regular Contributor
Can you use a TextSymbol or a MarkerSymbol with TextBlock to display the attribute value?
0 Kudos
UlfGrimhardt
Deactivated User
I tried that but if i use TextSymbols in my FeatureLayer, i couldnt get different Attributes for each Point in my map. I always got the same Symbol for every Point.

I dont know how to tell the FeatureLayer that it gets different Values for each Point.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You can either create one symbol by graphic (this thread may be helpful)
or you can bind the Text property to the attribute so you need only one symbol for all graphics:

 
<Grid.Resources>
<esriSymbols:TextSymbol x:Key="LegendTextSymbol">
                <esriSymbols:TextSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Border Padding="10,5,10,5" Background="White" BorderBrush="Black">
                            <TextBlock 
                                FontSize="{Binding Symbol.Size}" 
                                Text="{Binding Attributes[NameOfTheAttributeUsedForLabeling]}" 
                                Foreground="Blue"
                                FontFamily="{Binding Symbol.FontFamily}"
                                HorizontalAlignment="Center" />
                        </Border>
                    </ControlTemplate>
                </esriSymbols:TextSymbol.ControlTemplate>
            </esriSymbols:TextSymbol>
</Grid.Resources>
0 Kudos
UlfGrimhardt
Deactivated User
Is this possible with Attributes which i get from a SQLServer Database and not Attributes of an FeatureClass?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
This is possible as soon as you symbolize graphics having theirs attributes populated.
THe attributes can come from a SQL server database.
0 Kudos
UlfGrimhardt
Deactivated User
What exactly is meant by "populated attributes". I really have Problems getting this to work,....
0 Kudos
DominiqueBroux
Esri Frequent Contributor
How are you creating your graphics objects?

If you are using a FeatureLayer, the attributes will be populated automatically as soon as you set the OutFields property.

If you are creating the graphics by yourself, you have to populate the Attributes dictionary by code.
0 Kudos
UlfGrimhardt
Deactivated User
Hi

I create a FeatureLayer by Code and by using the WHERE Clause i add Graphics to it

            l = new FeatureLayer();
            l.OutFields.Add("NHN"); 
            l.ID = "MyFeatureLayer";
            l.FeatureSymbol = TS;
            l.Url = "http://testestest";

l.Where = "Pointnumber"
                testmap.Layers.Add(l);


Another way i use is the results of Find and Identify-Tasks.
In my SQL Server Database i have a Field called "NHN" and "Pointnumber".
In my FeatureClass i also have the field "Pointnumber". Using the Pointnumber-Fields i get the Connection between SQL and FeatureClass.
0 Kudos