FRAMES | NO FRAMES
Labeling Objects

Overview

This document discusses the JSON labeling objects as returned by the REST API.

The following objects are discussed here:

Label Placement

Label placement is represented as a literal string. It specifies the placement of the label with respect to that of its feature. Below is a list of label placement values categorized by the geometry type of the feature.

Label Placement Values For Point Features
esriServerPointLabelPlacementAboveCenter esriServerPointLabelPlacementAboveLeft esriServerPointLabelPlacementAboveRight
esriServerPointLabelPlacementBelowCenter esriServerPointLabelPlacementBelowLeft esriServerPointLabelPlacementBelowRight
esriServerPointLabelPlacementCenterCenter esriServerPointLabelPlacementCenterLeft esriServerPointLabelPlacementCenterRight
Label Placement Values For Line Features
esriServerLinePlacementAboveAfter esriServerLinePlacementAboveAlong esriServerLinePlacementAboveBefore
esriServerLinePlacementAboveStart esriServerLinePlacementAboveEnd  
esriServerLinePlacementBelowAfter esriServerLinePlacementBelowAlong esriServerLinePlacementBelowBefore
esriServerLinePlacementBelowStart esriServerLinePlacementBelowEnd  
esriServerLinePlacementCenterAfter esriServerLinePlacementCenterAlong esriServerLinePlacementCenterBefore
esriServerLinePlacementCenterStart esriServerLinePlacementCenterEnd  
Label Placement Values For Polygon Features
esriServerPolygonPlacementAlwaysHorizontal    

Label Class

A label class specifies the label definition for a given scale range.

New in 10.1

Note:

JSON Syntax

{
  "labelPlacement" : "<labelPlacement>",
  "labelExpression" : "<labelExpression>",
  "useCodedValues": <true | false>
  "symbol" : "<textSymbol>",
  "minScale" : <minScale>,
  "maxScale" : <maxScale>,
  "where" : "<where clause>"
}

JSON Example

 {
    "labelPlacement": "esriServerPointLabelPlacementAboveRight",
    "labelExpression": "[NAME]",
    "useCodedValues": false,
    "symbol": {
     "type": "esriTS",
     "color": [38,115,0,255],
     "backgroundColor": null,
     "borderLineColor": null,
     "verticalAlignment": "bottom",
     "horizontalAlignment": "left",
     "rightToLeft": false,
     "angle": 0,
     "xoffset": 0,
     "yoffset": 0,
     "kerning": true,
     "font": {
      "family": "Arial",
      "size": 11,
      "style": "normal",
      "weight": "bold",
      "decoration": "none"
     }
    },
    "minScale": 0,
    "maxScale": 0,
    "where" : "NAME LIKE 'A%'" //label only those feature where name begins with A
  }

Labeling Info

The labeling info object specifies the label definition for a layer. It is expressed as an array of label classes.

JSON Syntax

[ <labelClass1>, <labelClass2> ]

JSON Example

  [
   {
    "labelPlacement": "esriServerPolygonPlacementAlwaysHorizontal",
    "labelExpression": "[TAG]",
    "useCodedValues": false,
    "symbol": {
     "type": "esriTS",
     "color": [78,78,78,255],
     "backgroundColor": null,
     "borderLineColor": null,
     "verticalAlignment": "bottom",
     "horizontalAlignment": "left",
     "rightToLeft": false,
     "angle": 0,
     "xoffset": 0,
     "yoffset": 0,
     "font": {
      "family": "Arial",
      "size": 12,
      "style": "normal",
      "weight": "bold",
      "decoration": "none"
     }
    },
    "minScale": 1999,
    "maxScale": 0,
    "where": ""
   },
   {
    "labelPlacement": "esriServerPolygonPlacementAlwaysHorizontal",
    "labelExpression": "[TAG]",
    "useCodedValues": true,
    "symbol": {
     "type": "esriTS",
     "color": [78,78,78,255],
     "backgroundColor": null,
     "borderLineColor": null,
     "verticalAlignment": "bottom",
     "horizontalAlignment": "left",
     "rightToLeft": false,
     "angle": 0,
     "xoffset": 0,
     "yoffset": 0,
     "font": {
      "family": "Arial",
      "size": 12,
      "style": "normal",
      "weight": "bold",
      "decoration": "none"
     }
    },
    "minScale": 0,
    "maxScale": 7100,
    "where": ""
   }
  ]