Overview
This topic discusses the JSON representation of labeling objects.
The following objects are discussed:
- Label placement
- Label class
- Labeling info
Label placement
Label placement is represented as a literal string. It specifies the placement of the label with respect to that of its feature. The following table lists label placement values categorized by the geometry type of the feature:
Point features | Line features | Polygon features | |
---|---|---|---|
esriServerPointLabelPlacementAboveCenter | |||
esriServerPointLabelPlacementAboveLeft | |||
esriServerPointLabelPlacementAboveRight | |||
esriServerPointLabelPlacementBelowCenter | |||
esriServerPointLabelPlacementBelowLeft | |||
esriServerPointLabelPlacementBelowRight | |||
esriServerPointLabelPlacementCenterCenter | |||
esriServerPointLabelPlacementCenterLeft | |||
esriServerPointLabelPlacementCenterRight | |||
esriServerLinePlacementAboveAfter | |||
esriServerLinePlacementAboveAlong | |||
esriServerLinePlacementAboveBefore | |||
esriServerLinePlacementAboveStart | |||
esriServerLinePlacementAboveEnd | |||
esriServerLinePlacementBelowAfter | |||
esriServerLinePlacementBelowAlong | |||
esriServerLinePlacementBelowBefore | |||
esriServerLinePlacementBelowStart | |||
esriServerLinePlacementBelowEnd | |||
esriServerLinePlacementCenterAfter | |||
esriServerLinePlacementCenterAlong | |||
esriServerLinePlacementCenterBefore | |||
esriServerLinePlacementCenterStart | |||
esriServerLinePlacementCenterEnd | |||
esriServerPolygonPlacementAlwaysHorizontal |
Label class
A label class specifies the label definition for a given scale range.
This uses the where
property to determine the features that are labeled with the label class that contains it. As well, this also uses the label
property to adjust the formatting of labels. A label expression is limited to a single line of code.
{
"labelPlacement": "<labelPlacement>",
"labelExpression": "<labelExpression>",
"useCodedValues": <true | false>
"symbol": "<textSymbol>",
"minScale": <minScale>,
"maxScale": <maxScale>,
"where": "<where clause>"
}
Apart from specifying a string value or an attribute field value, the following keywords are supported:
Keyword | Description |
---|---|
| Concatenate two values. Example
|
| Insert a new line. Example
|
| Convert string value to uppercase string. Example
|
| Convert string value to lowercase string. Example
|
| Round a decimal number to set number of decimals as specified by (n). Example
|
| Format a date/time value with the specified format (FormatString*). The following keywords are recognized:
Example
|
- FormatString also supports a full range of Python date/time formats.
Labeling info
The labeling info object specifies the label definition for a layer. It is expressed as an array of label classes.
[ <labelClass1>, <labelClass2> ]