# new Text(opts)
Initialization object
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
opts |
object
|
Options |
||
font |
string
|
<optional> |
Font style as CSS 'font' value, see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is '10px sans-serif' |
|
maxAngle |
number
|
<optional> |
Math.PI/4 | When |
offsetX |
number
|
<optional> |
0 | Horizontal text offset in pixels. A positive will shift the text right. |
offsetY |
number
|
<optional> |
0 | Vertical text offset in pixels. A positive will shift the text down. |
overflow |
boolean
|
<optional> |
false | For polygon labels or when |
placement |
string
|
<optional> |
'point' | Text placement. |
scale |
number
|
<optional> |
Scale. |
|
rotateWithView |
boolean
|
<optional> |
false | Whether to rotate the text with the view. |
rotation |
number
|
<optional> |
0 | Rotation in radians (positive rotation clockwise). |
text |
string
|
<optional> |
Text content. |
|
textAlign |
string
|
<optional> |
Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'.
Default is 'center' for |
|
textBaseline |
string
|
<optional> |
'middle' | Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic', 'hanging', 'ideographic'. |
fill |
Fill
|
<optional> |
Fill style. If none is provided, we'll use a dark fill-style (#333). |
|
stroke |
Stroke
|
<optional> |
Stroke style. |
|
backgroundFill |
Fill
|
<optional> |
Fill style for the text background when |
|
backgroundStroke |
Stroke
|
<optional> |
Stroke style for the text background when |
|
padding |
Array.<number>
|
<optional> |
[0, 0, 0, 0] | Padding in pixels around the text for decluttering and background. The order of
values in the array is |
- Tutorials: