Labeling objects

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 featuresLine featuresPolygon 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
Full supportPartial supportNo support

    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 labelExpression property to adjust the formatting of labels. A label expression is limited to a single line of code.

    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    {
      "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:

    KeywordDescription

    CONCAT

    Concatenate two values.

    Example
    Use dark colors for code blocksCopy
    1
    "\"State: \" CONCAT [State_Name]"

    NEWLINE

    Insert a new line.

    Example
    Use dark colors for code blocksCopy
    1
    "\"State: \" CONCAT NEWLINE CONCAT [State_Name]"

    UCASE([Field])

    Convert string value to uppercase string.

    Example
    Use dark colors for code blocksCopy
    1
    "\"State: \" CONCAT UCASE([State_Name])"

    LCASE([Field])

    Convert string value to lowercase string.

    Example
    Use dark colors for code blocksCopy
    1
    "\"State: \" CONCAT LCASE([State_Name])"

    ROUND([Field], n)

    Round a decimal number to set number of decimals as specified by (n).

    Example
    Use dark colors for code blocksCopy
    1
    "\"Area: \" CONCAT ROUND([Area], 3)"

    FORMATDATETIME([Field], "FormatString")

    Format a date/time value with the specified format (FormatString*). The following keywords are recognized:

    • d—Day of the month
    • ddd—Abbreviated day of the week
    • dddd—Full day of the week
    • M—Month in number
    • MMM—Abbreviated month name
    • MMMM—Full month name
    • y—Two-digit year
    • yyyy—Four-digit year
    • h—Hour in 12-hour format
    • H—Hour in 24-hour format
    • m—Two-digit minute
    • s—Two-digit second
    Example
    Use dark colors for code blocksCopy
    1
    "\"Date Modified: \" CONCAT FORMATDATETIME([modified],\"dddd, MMM d, yyyy\")"
    • 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.

    Use dark colors for code blocksCopy
    1
    [ <labelClass1>, <labelClass2> ]

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.