Class: TextSymbolE-mail This Topic Printable Version Give Us Feedback

Description

Text symbols are used to add text on the graphics layer.

Class hierarchy

esri.symbol.Symbol
  |_ esri.symbol.TextSymbol

Constructor

Constructor Description
esri.symbol.TextSymbol(text) Creates a new TextSymbol object that includes only the text.
esri.symbol.TextSymbol(text, font, color) Creates a new TextSymbol object.
esri.symbol.TextSymbol(json) Creates a new TextSymbol object using a JSON object.

Properties

Property Type Description
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

Constant Description
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

Method Return Value Description
setAlign(align) TextSymbol Sets the alignment of the text.
setAngle(angle) TextSymbol Sets the angle of the text.
setDecoration(decoration) TextSymbol 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.
setFont(font) TextSymbol Sets the text font.
setKerning(kerning) TextSymbol Sets whether to adjust the spacing between characters in the text string.
setOffset(x, y) TextSymbol Sets the x and y offset of the text.
setRotated(rotated) TextSymbol 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.
setText(text) TextSymbol Sets the text string.
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

<String> align

The text alignment in relation to the point. See the Constants table for valid values.
Default value: ALIGN_MIDDLE
See also:
setAlign  

<Number> angle

Text angle. 0 is horizontal and the angle moves clockwise.
Default value: 0
See also:
setAngle  

<String> decoration

The decoration on the text. See the Constants table for valid values.
Default value: DECORATION_NONE
See also:
setDecoration  

<Font> font

Font for displaying text.
See also:
setFont  

<Boolean> kerning

Determines whether to adjust the spacing between characters in the text string.
Known values: true | false
Default value: true
See also:
setKerning  

<Boolean> rotated

Determines whether every character in the text string is rotated.
Known values: true | false
Default value: false
See also:
setRotated  

<String> text

Text string for display in the graphics layer.
See also:
setText  

<Number> xoffset

The offset on the x-axis in pixels from the point.
Default value: 0
See also:
setOffset  

<Number> yoffset

The offset on the y-axis in pixels from the point.
Default value: 0
See also:
setOffset  
Methods Detail

setAlign(align)

Sets the alignment of the text.
Return value: TextSymbol
Input Parameters:
<String> align Required The text alignment. See the Constants table for valid values.
Code snippets:
textSymbol.setAlign(esri.TextSymbol.ALIGN_START);

See also:
align  

setAngle(angle)

Sets the angle of the text.
Return value: TextSymbol
Input Parameters:
<Number> angle Required Angle value between 0 and 359.
Code snippets:
textSymbol.setAngle(15);

See also:
angle  

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.
Return value: TextSymbol
Input Parameters:
<String> decoration Required The decoration on the text. See the Constants table for valid values.
See also:
decoration  

setFont(font)

Sets the text font.
Return value: TextSymbol
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);  

See also:
font  

setKerning(kerning)

Sets whether to adjust the spacing between characters in the text string.
Return value: TextSymbol
Input Parameters:
<Boolean> kerning Required Set to true for kerning.
See also:
kerning  

setOffset(x, y)

Sets the x and y offset of the text.
Return value: TextSymbol
Input Parameters:
<Number> x Required X offset value in pixels.
<Number> y Required Y offset value in pixels.
See also:
xoffset   yoffset  

setRotated(rotated)

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.
Return value: TextSymbol
Input Parameters:
<Boolean> rotated Required Set to true to rotate all characters in the string.
See also:
rotated  

setText(text)

Sets the text string.
Return value: TextSymbol
Input Parameters:
<String> text Required The text string.
See also:
text