require(["esri/layers/support/LabelClass"], function(LabelClass) { /* code goes here */ });
Class: esri/layers/support/LabelClass
Inheritance: LabelClass Accessor
Since: ArcGIS API for JavaScript 4.0

Defines label expressions, symbols, scale ranges, label priorities, and sets of label placement options for different groups of labels on a layer.

Known Limitations

There is no support for labeling in 2D. Labeling is only supported in 3D SceneViews.

See also:

Constructors

new LabelClass(properties)

Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummary
String

The name of the class.

more details
more details
String

Defines the content of label text for MapImageLayer.

more details
more details
Object

Defines the content of label text for FeatureLayer.

more details
more details
String

The position of the label.

more details
more details
Number

The maximum scale to show labels.

more details
more details
Number

The minimum scale to show labels.

more details
more details
TextSymbol | LabelSymbol3D

Defines the symbol used for rendering the label.

more details
more details
Boolean

Indicates whether to use domain names if the fields in the labelExpression or labelExpressionInfo have domains.

more details
more details
String

A SQL where clause used to determine the features to which the label class should be applied.

more details
more details

Property Details

declaredClassStringreadonly

The name of the class. The declared class name is formatted as esri.folder.className.

labelExpressionString

Defines the content of label text for MapImageLayer. If working with FeatureLayer, use labelExpressionInfo instead.

Attribute values may be included in labels using SQL syntax. To include an attribute value in a label, wrap the name of the field in square brackets []. See the example snippet below.

Example:
// For Spokane County, WA, label will display: "Spokane County, Washington"
labelClass.labelExpression = '[COUNTY_NAME] CONCAT " County, " CONCAT [STATE_NAME]';

labelExpressionInfoObject

Defines the content of label text for FeatureLayer. If working with MapImageLayer, use labelExpression instead.

Attribute values may be included in label expressions. To include an attribute value in a label, wrap the name of the field in curly braces. See the example snippet below.

Property:
value String
optional

The expression defining the content of the label text.

Example:
// For Spokane County, WA, label will display: "Spokane County, Washington"
labelClass.labelExpressionInfo = {
  value: "{COUNTY_NAME} County, {STATE_NAME}"
};

labelPlacementString

The position of the label. Known values are based on the feature type. This property requires a value for labels to be visible.

Known Values (Points): above-center | above-left | above-right | below-center | below-left | below-right | center-center | center-left | center-right

Known Values (Polylines): above-after | above-along | above-before | above-start | above-end | below-after | below-along | below-before | below-start | below-end | center-after | center-along | center-before | center-start | center-end

Known Values (Polygons): always-horizontal

Known Limitations

Currently, if the label has a line callout then only "above-center" is supported.

Example:
labelClass.labelPlacement = "above-right";

maxScaleNumber

The maximum scale to show labels. The value of maxScale should always be less than the value of minScale. If the value is 0, then the label's visibility isn't dependent on maximum scale.

Default Value: 0

minScaleNumber

The minimum scale to show labels. The value of minScale should always be greater than the value of maxScale. If the value of this property is 0, then the visibility of labels isn't dependent on minimum scale.

Default Value: 0

Defines the symbol used for rendering the label.

useCodedValuesBoolean

Indicates whether to use domain names if the fields in the labelExpression or labelExpressionInfo have domains.

whereString

A SQL where clause used to determine the features to which the label class should be applied. When specified, only features evaluating to true based on this expression will be labeled.

Example:
labelClass.where = "CITYNAME = 'Redlands'";

Method Overview

NameReturn TypeSummary
LabelClass

Creates a deep clone of the LabelClass.

more details
more details
*

Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform.

more details
more details
Object

Converts an instance of this class to its ArcGIS Portal JSON representation.

more details
more details

Method Details

clone(){LabelClass}

Creates a deep clone of the LabelClass.

Returns:
TypeDescription
LabelClassA deep clone of the object that invoked this method.
Example:
// Creates a deep clone of the graphic's first symbol layer
var label = layer.labelingInfo[0].clone();

fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. 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.

Parameter:
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns:
TypeDescription
*Returns a new instance of this class.

toJSON(){Object}

Converts an instance of this class to its ArcGIS Portal JSON representation. See the Using fromJSON() topic in the Guide for more information.

Returns:
TypeDescription
ObjectThe ArcGIS Portal JSON representation of an instance of this class.

API Reference search results

NameTypeModule

There were no match results from your search criteria.