Label Definition
An object that defines the text, appearance, and position of labels for features within a given scale range. A LabelDefinition describes a class of labels.
A collection of label definitions can be attached to a feature data source (example com.arcgismaps.mapping.layers.FeatureLayer). Each LabelDefinition specifies:
Which features are covered by the definition, by applying the LabelDefinition.whereClause SQL constraint
What text should be displayed, based on the individual feature's attributes and the chosen LabelDefinition.expression formula
How the text should appear, using the label definition's com.arcgismaps.mapping.symbology.TextSymbol
Where the text should appear, with respect to its feature, using the LabelDefinition.placement
How to move or avoid other labels or features that would overlap each label
Since
200.1.0
Constructors
Creates a LabelDefinition with the specified LabelExpression and com.arcgismaps.mapping.symbology.TextSymbol. The label expression may be a combination of literal text and attribute values from the feature being labeled. The syntax of the expression is determined by which label expression object is used: ArcadeLabelExpression, SimpleLabelExpression or WebmapLabelExpression. Warning: If the expression attempts to use attributes which don't exist then no label will be produced. This is distinct from the attribute existing but having a null or empty value, which can form part of the produced text label.
Properties
The angular positions and layout directions for labels on or around point feature symbols. This optional object specifies how to position a label following the direction of an angle. The angular position may be different for each feature (driven by one or more feature attributes) or constant for all features (specified by a fixed number).
The strategy for moving labels to avoid overlapping feature, annotation, dimension or graphic symbols or higher priority labels. In 3D LabelDeconflictionStrategy.Static is selected by default. The default is LabelDeconflictionStrategy.Automatic (which will be interpreted as LabelDeconflictionStrategy.Static i.e. use preferred location unless it would overlap an obstacle).
The expression script used to calculate the label text. The expression may be a combination of literal text and attribute values from the feature being labeled. The syntax of the expression is determined by which label expression object is used: ArcadeLabelExpression, SimpleLabelExpression or WebmapLabelExpression.
The strategy for whether other labels are allowed to overlap the boundary of polygon features/graphics being labeled by this LabelDefinition. In 3D scenes, labels will be allowed to overlap the boundaries of polygon features. The default is LabelOverlapStrategy.Automatic, which will give the same behavior as LabelOverlapStrategy.Allow.
The strategy for whether other labels are allowed to overlap the interior of polygon features/graphics being labeled by this LabelDefinition. In 3D scenes, labels will be allowed to overlap the interiors of polygon features. The default is LabelOverlapStrategy.Automatic which will give the same behavior as LabelOverlapStrategy.Allow.
The strategy for how to use the geometry of the feature when calculating the label position. Only applicable to labels for lines or polygons.
The strategy for whether other labels are allowed to overlap labels created by this LabelDefinition. In 3D, labels will not be allowed to overlap other labels. Overlapping labels will not be displayed until the user zooms in further so that the labels don't overlap. The default is LabelOverlapStrategy.Automatic which will give the same behavior as LabelOverlapStrategy.Exclude.
The strategy for whether line features with the same label, and matching end vertices, should be joined before sharing a label. 3D line features will be treated as independent features with their own label. The default is LabelLineConnection.Automatic, which will be interpreted as LabelLineConnection.MinimizeLabels.
The strategy for whether LabelDefinition.placement above or below a line geometry will be interpreted as above or below on the screen
, or with respect to the direction
of line's geometry (that is, the digitization order in which the vertices are listed). If the LabelDefinition.lineOrientation is set to LabelLineOrientation.Screen then LabelDefinition.placement above means the label will be offset perpendicularly from its line segment towards the top of the screen. If the LabelDefinition.lineOrientation is set to LabelLineOrientation.Direction then LabelDefinition.placement above means the label will be offset perpendicularly left from its line segment. If the LabelDefinition.lineOrientation is set to LabelLineOrientation.Unconstrained then the label will be offset perpendicularly to whichever side of the line geometry has space (defaulting to above in the screen
sense). LabelDefinition.placement below would have the corresponding interpretations. The default is LabelLineOrientation.Screen.
The strategy for how many labels should be placed on each polyline or polygon (multi-ring) feature. The default is LabelMultipartStrategy.Automatic.
The distance (in points i.e. 1/72 inches) that text should be moved away from its features. The distance is measured from the point symbol radius or line feature symbology edge. The distance is measured on the screen (i.e. not in the map) in points, comparable to the text font size.
The strategy for whether a label will be visible at scales where the feature is too small for the label to fit. Not supported by 3D scenes. The default is LabelOverrunStrategy.Automatic which will give different behavior depending on the type of feature that the label might overrun.
The preferred position of the text label, with respect to its feature geometry. The default is com.arcgismaps.arcgisservices.LabelingPlacement.Automatic. The effect of this is the same as one of the following, depending on the type of feature geometry:
A value that controls the duplicate thinning radius (in points i.e. 1/72 inches). The distance is measured on the screen (i.e. not in the map) in points, comparable to the text font size. This value is only used if LabelDefinition.removeDuplicatesStrategy is enabled. The default value is 0. This indicates that duplicates should be removed from the entire extent.
The strategy for whether labels are removed if other features have the same text label. This can reduce clutter and free up space. The default is LabelRemoveDuplicatesStrategy.Automatic, which will be interpreted as LabelRemoveDuplicatesStrategy.None indicating that all labels should be shown if possible.
The distance apart (in points i.e. 1/72 inches) that the repetitions should be. In 3D scenes, only one label will be placed per line feature. This value is only used if LabelDefinition.repeatStrategy is enabled. The distance is measured on the screen along the line feature. As the user zooms in closer, two repetitions move further apart on the screen, until there is room for a new repetition between them. The default is 216 points i.e. line labels should be repeated approximately every 3 inches along long features.
The strategy for whether a label should have multiple copies created and placed along or across the same feature. In 3D scenes, only label will be placed per line feature. The default is LabelRepeatStrategy.Automatic.
The strategy for how multi-row (stacked) text should be aligned. Multi-row text labels can be horizontally aligned on the left, right or at its center. This preference can be specified by the com.arcgismaps.mapping.symbology.TextSymbol assigned to the LabelDefinition. By using the LabelDefinition.stackAlignment property, the user can choose to use the com.arcgismaps.mapping.symbology.TextSymbol.horizontalAlignment property for all labels, or can choose to have the most aesthetic alignment calculated case-by-case for each label depending on its placement position around its feature. This is particularly useful for labels of dense point features, where labels may move above, below, left or right of their point symbol, in order to fit on the display.
The strategy for whether a row of text should be broken before or after it exceeds the ideal length. If stacking is turned on, label placement can insert a line break before or after the word that overruns the maximum number of characters per row. Using the LabelStackBreakPosition.Before option means rows will generally be shorter than the LabelDefinition.stackRowLength (although will overrun for individual words larger than this count).
A value that limits the number of characters in a row of stacked text. This length guides the decision on when to break long text strings into separate rows. The line break will be inserted between words, not in the middle of a word, so rows may be longer or shorter than the ideal. Depending on LabelDefinition.stackBreakPosition, the break may be inserted before the breaking word, or after.
The stack separators that should be used for automatic line breaking of label text. Each LabelStackSeparator specifies a code point to be looked for in the text. A code point is often thought of as a single character in the text, but may need several chars in a String to describe it. So each LabelStackSeparator.separator is a String intended to describe one code point.
The strategy for whether the text should be stacked or wrapped, rather than placed as long trailing labels across the map. This property controls whether stacking is allowed, or not, or should be calculated automatically based on feature type. The default is LabelStackStrategy.Automatic, meaning that stacking will be enabled for point and polygon features and disabled for line features.
The layout of the text, which can be either horizontal, straight, perpendicular, or follow the line feature. Optional specification of whether, once the text is positioned, it should be written:
The orientation of the text, which can be either angle direction or screen-oriented. Not supported by 3D scenes. Optional specification of whether text should follow the placement angle direction even if it means being rendered upside-down, or whether text should be flipped through 180 degrees to keep it screen-oriented. This setting will take effect whenever the feature geometry determines that the text is angled upside-down, or if the map is rotated within the screen to make the text upside-down (with respect to the screen). The default is LabelTextOrientation.Automatic, which is interpreted as LabelTextOrientation.Screen.
The text symbol which describes the overall appearance of label text (e.g. font and size). If no LabelDefinition.textSymbol has been set, then no labels can be created.
True if the data source should translate domain identifiers into meanings using a com.arcgismaps.data.CodedValueDomain, false otherwise. For any translation to occur, the data source must have one or more com.arcgismaps.data.CodedValueDomain set up for the attribute fields. The default value is true.
A SQL where clause expression that limits the set of features for which labels will be generated and placed. This is a SQL where clause that can refer to the attributes of the feature. For example: