Description
Text symbols are used to add text on the graphics layer.
Class hierarchy
esri.symbol.Symbol
|_ esri.symbol.TextSymbol
Constructor
Properties
| align |
String
|
The text alignment in relation to the point. See the Constants table for valid values. |
| angle |
Number
|
Text angle. 0 is horizontal and the angle moves clockwise. |
| decoration |
String
|
The decoration on the text. See the Constants table for valid values. |
| font |
Font
|
Font for displaying text. |
| kerning |
Boolean
|
Determines whether to adjust the spacing between characters in the text string. |
| rotated |
Boolean
|
Determines whether every character in the text string is rotated. |
| text |
String
|
Text string for display in the graphics layer. |
| xoffset |
Number
|
The offset on the x-axis in pixels from the point. |
| yoffset |
Number
|
The offset on the y-axis in pixels from the point. |
Constants
| ALIGN_END |
The end of the text string is aligned with the point. |
| ALIGN_MIDDLE |
The center of the text string is aligned with the point. |
| ALIGN_START |
The beginning of the text string is aligned with the point. |
| DECORATION_LINETHROUGH |
Text has a lined striked through it. |
| DECORATION_NONE |
Text has no decoration. |
| DECORATION_OVERLINE |
Text has a line along the top. |
| DECORATION_UNDERLINE |
Text is underlined. |
Methods
Constructor Detail
esri.symbol.TextSymbol(text)
Creates a new TextSymbol object that includes only the text.
Parameters:
|
<String>
text |
Required |
Text string for display in the graphics layer.
|
Code snippets:
Create a new text symbol using the default values for color, size, etc.
new esri.symbol.TextSymbol("Hello World");
Create a new text symbol and set new values for color, weight, font and angle.
var textSymbol = new esri.symbol.TextSymbol("Here be dragons").setColor(
new dojo.Color([128,0,0])).setAlign(esri.symbol.Font.ALIGN_START).setAngle(45).setFont(
new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD)) ;
esri.symbol.TextSymbol(text, font, color)
Creates a new TextSymbol object.
Parameters:
|
<String>
text |
Required |
Text string for display in the graphics layer.
|
|
<Font>
font |
Required |
Font for displaying text.
|
|
<dojo.Color>
color |
Required |
Symbol color, which is based on dojo.Color. Colors can be denoted in the following formats:
- R, G, B:
new dojo.Color([255,0,0])
- R,G,B,A. The "A" value represents transparency where 0.0 is fully transparent and 1.0 has no transparency:
new dojo.Color([255,0,0,0.25])
- Hex string:
new dojo.Color("#C0C0C0")
- Named string:
new dojo.Color("blue")
|
esri.symbol.TextSymbol(json)
Creates a new TextSymbol object using a JSON object.
Parameters:
|
<Object>
json |
Required |
JSON object representing the text symbol.
|
Properties Detail
The text alignment in relation to the point. See the Constants table for valid values.
Default value: ALIGN_MIDDLE
Text angle. 0 is horizontal and the angle moves clockwise.
Default value: 0
The decoration on the text. See the Constants table for valid values.
Default value: DECORATION_NONE
Font for displaying text.
Determines whether to adjust the spacing between characters in the text string.
Known values: true | false
Default value: true
Determines whether every character in the text string is rotated.
Known values: true | false
Default value: false
Text string for display in the graphics layer.
The offset on the x-axis in pixels from the point.
Default value: 0
The offset on the y-axis in pixels from the point.
Default value: 0
Methods Detail
Sets the alignment of the text.
Input Parameters:
|
<String> align |
Required |
The text alignment. See the Constants table for valid values. |
Code snippets:
textSymbol.setAlign(esri.TextSymbol.ALIGN_START);
Sets the angle of the text.
Input Parameters:
|
<Number> angle |
Required |
Angle value between 0 and 359. |
Code snippets:
textSymbol.setAngle(15);
setDecoration(decoration)
Sets the decoration for the text. Many browsers, including Internet Explorer 7, Firefox and Opera 9 do not support the decoration property for text symbols.
Input Parameters:
|
<String> decoration |
Required |
The decoration on the text. See the Constants table for valid values. |
Sets the text font.
Input Parameters:
|
<Font> font |
Required |
Text font. |
Code snippets:
var font = new esri.symbol.Font();
font.setSize("12pt");
font.setWeight(esri.symbol.Font.WEIGHT_BOLD);
textSymbol.setFont(font);
Sets whether to adjust the spacing between characters in the text string.
Input Parameters:
|
<Boolean> kerning |
Required |
Set to true for kerning. |
Sets the x and y offset of the text.
Input Parameters:
|
<Number> x |
Required |
X offset value in pixels. |
|
<Number> y |
Required |
Y offset value in pixels. |
Sets whether every character in the text string is rotated. Many browsers, including Internet Explorer 7, Firefox and Opera 9 do not support rotated for text symbols.
Input Parameters:
|
<Boolean> rotated |
Required |
Set to true to rotate all characters in the string. |
Sets the text string.
Input Parameters:
|
<String> text |
Required |
The text string. |