FRAMES | NO FRAMES Description | Parameters | Examples | Response
Legend

This is an archive of a previous version of the ArcGIS REST API. The current version can be found at http://resources.arcgis.com/en/help/arcgis-rest-api/

URL http://<mapservice-url>/legend
Parent Resource Map Service

Description

The legend resource represents a map service's legend. It returns the legend information for all layers in the service. Each layer's legend information includes the symbol images and labels for each symbol. Each symbol is an image of size 20 x 20 pixels at 96 DPI. Additional information for each layer such as the layer ID, name, and min and max scales are also included.

The legend symbols include the base64 encoded imageData as well as a url that could be used to retrieve the image from the server. Note that this is a relative URL. It can be dereferenced by accessing the map layer image resource.

Resource Hierarchy

Legend

Parameters

Parameter Details
f Description: The response format. The default response format is html.

Values: html | json

Example Usage

Example 1: TODO

JSON Response Syntax

{
  "layers": [
    {
      "layerId": <layerId1>,
      "layerName": "<layerName1>",
      "layerType" : "<layerType1>",
      "minScale": <minScale1>,
      "maxScale": <maxScale1>,
      "legend": [
        {
          "label": "<label11>",
          "url" : "<imageUrl11>", //Relative URL. Access using http://<mapservice-url>/<layerId1>/images/<imageUrl11>
          "imageData" : "<base64EncodedImageData11>", 
          "contentType" : "<contentType11>"
        },
        {
          "label": "<label12>",
          "url" : "<imageUrl12>",
          "imageData" : "<base64EncodedImageData12>", 
          "contentType" : "<contentType12>"
        }
      ]
    },
    {
      "layerId": <layerId2>,
      "layerName": "<layerName2>",
      "layerType" : "<layerType2>",
      "minScale": <minScale2>,
      "maxScale": <maxScale2>,
      "legend": [
        {
          "label": "<label21>",
          "url" : "<imageUrl21>", //Relative URL. Access using http://<mapservice-url>/<layerId2>/images/<imageUrl21>
          "imageData" : "<base64EncodedImageData21>", 
          "contentType" : "<contentType21>"
        },
        {
          "label": "<label22>",
          "url" : "<imageUrl22>",
          "imageData" : "<base64EncodedImageData22>", 
          "contentType" : "<contentType22>"
        }
      ]
    }
  ]
}

JSON Response Example

{
  "layers": [
    {
      "layerId": 0,
      "layerName": "Approved Development Plans",
      "layerType" : "Feature Layer",
      "minScale": 0,
      "maxScale": 0,
      "legend": [
        {
          "label": "Approved",
          "url" : "471E7E31", //Access using http://<mapservice-url>/0/images/471E7E31
          "imageData" : "iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAMNJREFUSIntlcENwyAMRZ+lSMyQFcI8rJA50jWyQuahKzCDT+6h0EuL1BA1iip8Qg/Ex99fYuCkGv5bKK0EcB40YgSE7bnTxsa58LeOnMd0QhwGXkxB3L0w0IDxPaMqpBFxjLMuaSVmRjurWIcRDHxaiWZuEbRcEhpZpSNhE9O81GiMN5E0ZRt2M0iVjshek8UkTQfZy8JqGHYP/rJhODD4T6wehtbB9zD0MPQwlOphaAxD/uPLK7Z8MB5gFet+WKcJPQDx29XkRhqr/AAAAABJRU5ErkJggg==", 
          "contentType" : "image/png"
        }
      ]
    },
    {
      "layerId": 1,
      "layerName": "Paving Projects",
      "layerType" : "Feature Layer",
      "minScale": 0,
      "maxScale": 0,
      "legend": [
        {
          "label": "Pending Projects",
          "url" : "866880A0", //Access using http://<mapservice-url>/1/images/866880A0
          "imageData" : "iVBORw0KGgoAAAANSUhEUgAAAFQAAABUCAYAAAAcaxDBAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAM9JREFUeJzt0EEJADAMwMA96l/zTBwUSk5ByLxQsx1wTUOxhmINxRqKNRRrKNZQrKFYQ7GGYg3FGoo1FGso1lCsoVhDsYZiDcUaijUUayjWUKyhWEOxhmINxRqKNRRrKNZQrKFYQ7GGYg3FGoo1FGso1lCsoVhDsYZiDcUaijUUayjWUKyhWEOxhmINxRqKNRRrKNZQrKFYQ7GGYg3FGoo1FGso1lCsoVhDsYZiDcUaijUUayjWUKyhWEOxhmINxRqKNRRrKNZQrKFYQ7GGYh/hIwFRFpnZNAAAAABJRU5ErkJggg==", 
          "contentType" : "image/png"
        },
        {
          "label": "Approved Projects",
          "url" : "471E7E31", 
          "imageData" : "iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAMNJREFUSIntlcENwyAMRZ+lSMyQFcI8rJA50jWyQuahKzCDT+6h0EuL1BA1iip8Qg/Ex99fYuCkGv5bKK0EcB40YgSE7bnTxsa58LeOnMd0QhwGXkxB3L0w0IDxPaMqpBFxjLMuaSVmRjurWIcRDHxaiWZuEbRcEhpZpSNhE9O81GiMN5E0ZRt2M0iVjshek8UkTQfZy8JqGHYP/rJhODD4T6wehtbB9zD0MPQwlOphaAxD/uPLK7Z8MB5gFet+WKcJPQDx29XkRhqr/AAAAABJRU5ErkJggg==", 
          "contentType" : "image/png"
        }
      ]
    }
  ]
}