ESM: import TextSymbol from "@arcgis/core/symbols/TextSymbol.js";
CDN: const TextSymbol = await $arcgis.import("@arcgis/core/symbols/TextSymbol.js");
Class: @arcgis/core/symbols/TextSymbol
Since: ArcGIS Maps SDK for JavaScript 4.0
Property Overview Any properties can be set, retrieved or listened to. See the Watch for changes topic.Show inherited properties Hide inherited properties
Property DetailsThe angle of the text. 0
is horizontal and the angle moves clockwise.
Known Limitations
This property is currently not supported in 3D SceneViews.
Example
const textSymbol = {
type: "text", // autocasts as new TextSymbol()
angle: 90,
color: "green",
font: {
// autocast as new Font()
family: "Just Another Hand",
size: 12
},
haloColor: "black",
haloSize: 1,
horizontalAlignment: "right",
verticalAlignment: "bottom"
};
The background color of the label's bounding box.
Known Limitations
This property is currently not supported when labelling a FeatureLayer polyline with a "curved" labelPosition.
The border color of the label's bounding box.
Known Limitations
This property is currently not supported when labelling a FeatureLayer polyline with a "curved" labelPosition.
The border size or width of the label's bounding box.
Known Limitations
This property is currently not supported when labelling a FeatureLayer polyline with a "curved" labelPosition.
The color of the symbol. This can be autocast with an array of rgb(a) values, named string, hex string or an hsl(a) string, an object with r
, g
, b
, and a
properties, or a Color object.
Examples
// CSS color string
symbol.color = "dodgerblue";
// HEX string
symbol.color = "#33cc33";
// array of RGBA values
symbol.color = [51, 204, 51, 0.3];
// object with rgba properties
symbol.color = {
r: 51,
g: 51,
b: 204,
a: 0.7
};
Inherited
Property declaredClass Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.
The name of the class. The declared class name is formatted as esri.folder.className
.
The Font used to style the text. This property allows the developer to set the font's family, decoration, size, style, and weight properties.
See the Labeling guide page for more information and known limitations.
Example
let textSymbol = {
type: "text", // autocasts as new TextSymbol()
text: "Science of Where",
font: { // autocasts as new Font()
family: "Merriweather",
size: 12,
style: "italic",
weight: "bold"
}
};
The color of the text symbol's halo. To include a halo in the TextSymbol, you must also set the size of the halo in haloSize.
Known Limitations
Examples
// CSS color string
symbol.haloColor = "dodgerblue";
// HEX string
symbol.haloColor = "#33cc33";
// array of RGBA values
symbol.haloColor = [51, 204, 51, 0.3];
// object with rgba properties
symbol.haloColor = {
r: 51,
g: 51,
b: 204,
a: 0.7
};
The size in points of the text symbol's halo. This value may be autocast with a string expressing size in points or pixels (e.g. 12px
). To include a halo in the TextSymbol, you must also set the color of the halo in haloColor.
Known Limitations
Examples
// haloSize in points
symbol.haloSize = 1;
// haloSize in pixels
symbol.haloSize = "2px";
// haloSize in points
symbol.haloSize = "1pt";
horizontalAlignment String
Adjusts the horizontal alignment of the text in multi-lines.
Known Limitations
horizontalAlignment
for labels is inferred from the labelPlacement value.Possible Values:"left" |"right" |"center"
Determines whether to adjust the spacing between characters in the text string.
lineHeight Number
Since: ArcGIS Maps SDK for JavaScript 4.15 TextSymbol since 4.0, lineHeight added at 4.15.
The height of the space between each line of text. Only applies to multiline text.
This property can be considered as a multiplier of the default value of 1.0 (e.g. a value of 2.0 will be two times the height of the default height). The range of possible values is: 0.1 - 4.0. If a value of 0 is specified, the default value of 1.0 will be used.
Example
const textSymbol = {
type: "text", // autocasts as new TextSymbol()
color: "blue",
haloColor: "white",
haloSize: 1,
lineHeight: 1.5
};
Since: ArcGIS Maps SDK for JavaScript 4.15 TextSymbol since 4.0, lineWidth added at 4.15.
The maximum length in points for each line of text. This value may be autocast with a string expressing size in points or pixels (e.g. 72px
).
The default value is 192 points. The range of possible values is: 32px - 512px.
If text extends farther than the lineWidth
value, then the line will break at the whitespace before the text that extends past the limit if possible, and a new line will be created.
Known Limitations
Example
const textSymbol = {
type: "text", // autocasts as new TextSymbol()
color: "blue",
haloColor: "white",
haloSize: 1,
lineWidth: 200
};
Determines whether every character in the text string is rotated.
Known Limitations
This property is currently not supported in 3D SceneViews.
The text string to display in the view. Long text strings will be split into multiple lines. The length of the line is controlled by the lineWidth property. To manually create a new line, use the \n
escape character.
Known Limitations
This property only applies when TextSymbol is used to define the symbol property of a Graphic, and not for labeling purposes.
Examples
symbol.text = "You are here";
symbol.text = "Wish you were \n here";
verticalAlignment String
Adjusts the vertical alignment of the text.
Known Limitations
verticalAlignment
for labels is inferred from the labelPlacement value.Possible Values:"baseline" |"top" |"middle" |"bottom"
The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. 12px
).
Known Limitations
This property is currently not supported in 3D SceneViews.
Examples
// xoffset in points
symbol.xoffset = 3;
// xoffset in pixels
symbol.xoffset = "6px";
// xoffset in points
symbol.xoffset = "3pt";
The offset on the y-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. 12px
).
Known Limitations
This property is currently not supported in 3D SceneViews.
Examples
// yoffset in points
symbol.yoffset = 3;
// yoffset in pixels
symbol.yoffset = "6px";
// yoffset in points
symbol.yoffset = "3pt";
Show inherited methods Hide inherited methods
Method DetailsInherited
Method addHandles(handleOrHandles, groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles
const handle = reactiveUtils.when(
() => !view.updating,
() => {
wkidSelect.disabled = false;
},
{ once: true }
);
this.addHandles(handle);
// Destroy the object
this.destroy();
Parameters
Handles marked for removal once the object is destroyed.
groupKey *
optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
Creates a deep clone of the symbol.
Returns
Type Description TextSymbol A deep clone of the object that invoked this method.Example
// Creates a deep clone of the graphic's symbol
let symLyr = graphic.symbol.clone();
Inherited
Method fromJSON(json){* |null |undefined}static
Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.
Returns
Type Description * | null | undefined Returns a new instance of this class.Inherited
Method hasHandles(groupKey){Boolean}
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.
Returns true if a named group of handles exist.
Parameter
groupKey *
optionalA group key.
Returns
Type Description Boolean Returnstrue
if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
obj.removeHandles("watch-view-updates");
}
Inherited
Method removeHandles(groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.
Removes a group of handles owned by the object.
Parameter
groupKey *
optionalA group key or an array or collection of group keys to remove.
Example
obj.removeHandles(); // removes handles from default group
obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4