Need some help understanding how to use textAttribute with TextSymbol

831
3
Jump to solution
10-03-2012 05:36 AM
JasonCantrell
Deactivated User
I need some help understanding how to use the "textAttribute" attribute of TextSymbol.  I am using a composite symbol, SimpleMarkerSymbol and TextSymbol, and I want the TextSymbol to display custom text for each map point.  I was thinking of using the uid attribute of graphic (graphic.uid) to store the custom text but I'm not sure how to tie that attribute to the textAttribute.

The sample isn't very helpful for this.  In the example, the textAttribute is displaying the CITY_NAME from the featureLayer, but I'm not sure where that data comes from.

Any suggestions or clarifications would be greatly appreciated.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DasaPaddock
Esri Regular Contributor
0 Kudos
3 Replies
IvanBespalov
Frequent Contributor
From reference:
The textAttribute is the string representing the attribute of the graphic that should populate the "text" content.
... I want the TextSymbol to display custom text for each map point...

use textFunction
public function myTextFunction(point:MapPoint, attributes:Object):String
{
    var label:String = StringUtil.substitute("X: {0}, Y:{1}", point.x, point.y);
    return label;
}
...
<esri:TextSymbol background="true"
                        backgroundColor="0xFFFFFF"
                        border="true"
                        ...
                        textFunction="myTextFunction">
                        <flash:TextFormat bold="true" size="16"/>
</esri:TextSymbol>
0 Kudos
JasonCantrell
Deactivated User
Thanks for the quick reply!

I tried out the code you suggested and got the following error on the line with the StringUtil.substitute: "1137:Incorrect number of arguments. Expected no more than 2."

Should I be using com.esri.ags.utils.StringUtil or mx.utils.StringUtil?
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos