Query Legends

Description

Available starting at 10.7.1, this operation is performed on a map service to return information about the map service's legend by layer. As opposed to the Legend resource, which provides a complete representation of the map legend, this operation allows you to filter the results by specifying parameters.

Each layer's legend information includes the symbol images and labels for each symbol. You can specify an image size for the symbol images. They include the base64-encoded imageData, as well as a URL that can be used to retrieve the image from the server site.

Additional information for each layer, such as the layer ID, name, and scale, is also included.

Most of the available request parameters are also found in the Export Map operation.

NoteNote:

This is a relative URL. It can be dereferenced by accessing the map layer image resource.

Request parameters

JSON parameter

HTML parameter

Details

f

Format

The response format. Only json can be specified for this value.

returnVisibleOnly

Return Visible Only

If set to true, as by default, a legend item class will only appear in the legend if a feature from that item class is included in the current extent.

If set to false, all items in the legend will be included in the operation results. This is the same result as when using the static Legend resource. Because that resource is static, it performs faster than this operation; it's better to use the Legend resource if you want to obtain all legend items.

bbox

Bounding Box

(Required) The extent (bounding box) of the exported image. Unless the bboxSR parameter has been specified, the bbox is assumed to be in the spatial reference of the map.

Syntax: <xmin>, <ymin>, <xmax>, <ymax>

Example: bbox=-104,35.6,-94.32,41

The bbox coordinates should always use a period as the decimal separator, even in countries where traditionally a comma is used.

bboxSR

Bounding Box Spatial Reference

The spatial reference of the bbox.

The spatial reference can be specified as either a well-known ID or as a spatial reference JSON object.

If the bboxSR parameter is not specified, the bbox parameter is assumed to be in the spatial reference of the map.

layers

Layers

Determines which layers appear on the exported map. There are four ways to specify which layers are shown:

  • show: Only the layers specified in this list will be exported.
  • hide: All layers except those specified in this list will be exported.
  • include: In addition to the layers exported by default, the layers specified in this list will be exported.
  • exclude: The layers exported by default excluding those specified in this list will be exported.

Syntax: [show | hide | include | exclude]:layerId1,layerId2

Where layerId1, layerId2 are the layer IDs returned by the map service resource.

Example: layers=show:2,4,7

CautionCaution:

Showing or excluding group layers also shows or excludes all groups and sublayers within the group layer (assuming they draw by default). For example, if you want to show group layer 0 and layer 2 is a sublayer of this group, layer 2 will also display. The same logic applies when excluding a group layer.

layerDefs

Layer Definitions

Allows you to filter the features of individual layers in the exported map by specifying definition expressions for those layers. Definition expressions for a layer that is published with the service will be always honored.

NoteNote:

When filtering the features of individual layers in a mosaic dataset, the client must explicitly specify the definition expression on the parent mosaic dataset layer. The definition expression will not be honored if it is specified on any of the child layers.

Syntax: { "<layerId1>" : "<layerDef1>" , "<layerId2>" : "<layerDef2>" }

Where layerId1, layerId2 are the layer IDs returned by the map service resource.

size

Image Size

The size (width and height) of the exported image in pixels. If the size parameter is not specified, an image with a default size of 400 by 400 pixels will be exported.

Syntax: <width>, <height>

Example: size=600,550

imageSR

Image Spatial Reference

The spatial reference of the exported image.

The spatial reference can be specified as either a well-known ID or as a spatial reference json object.

If the imageSR parameter is not specified, the image will be exported in the spatial reference of the map.

historicMoment

Historic Moment

Returns an output image with features from a specific epoch time. This parameter applies only if the layer is archiving enabled and the supportsQueryWithHistoricMoment property is set to true. This property is provided in the layer resource.

If historicMoment is not specified, the current features are drawn.

Syntax: historicMoment=<Epoch time in milliseconds>

Example: historicMoment=1199145600000

format

Image Format

The format of the exported image. The default format is .png.

Values: png | png8 | png24 | jpg | pdf | bmp | gif | svg | svgz | emf | ps | png32

transparent

Background Transparent

If set to true, the image will be exported with the background color of the map set as its transparent color. The default is false. Only the .png and .gif formats support transparency. Internet Explorer 6 does not display transparency correctly for png24 image formats.

Values: true | false

dpi

DPI

The device resolution of the exported image (dots per inch). If the dpi parameter is not specified, an image with a default DPI of 96 will be exported.

Example: dpi=200

time

Time

The time instant or time extent of the exported map image.

Time instant syntax: time=<timeInstant>

Time instant example: time=1199145600000 (1 Jan 2008 00:00:00 GMT)

Time extent syntax: time=<startTime>, <endTime>

Time extent example: time=1199145600000, 1230768000000 (1 Jan 2008 00:00:00 GMT to 1 Jan 2009 00:00:00 GMT)

A null value specified for start time or end time will represent infinity for start or end time, respectively (for example, time=null,1230768000000).

layerTimeOptions

Layer Time Options

The time options per layer. Users can indicate whether the layer should use the time extent specified by the time parameter, whether to draw the layer features cumulatively, and the time offsets for the layer.

Syntax:

{
  "<layerId1>" : {
    //If true, use the time extent specified by the time parameter
    "useTime" : < true | false >,
    //If true, draw all the features from the beginning of time for that data
    "timeDataCumulative" : < true | false >,
    //Time offset for this layer so that it can be overlaid on the top of a previous or future time period
    "timeOffset" : <timeOffset1>,
    "timeOffsetUnits" : "<esriTimeUnitsCenturies | esriTimeUnitsDays | esriTimeUnitsDecades | 
                             esriTimeUnitsHours | esriTimeUnitsMilliseconds | esriTimeUnitsMinutes | 
                             esriTimeUnitsMonths | esriTimeUnitsSeconds | esriTimeUnitsWeeks | esriTimeUnitsYears |
                             esriTimeUnitsUnknown>"
  },
  "<layerId2>" : {
    "useTime" : < true | false >,
    "timeDataCumulative" : < true | false >,
    "timeOffsetOffset" : <timeOffset2>,
    "timeOffsetUnits" : "<timeOffsetUnits2>"
  }
}

Example:

{
  "0" : {
    "useTime" : true,
    "timeDataCumulative" : false,
    "timeOffset" : 1,
    "timeOffsetUnits" : "esriTimeUnitsYears"
  },
  "3" : {
    "useTime" : false
  }
}

dynamicLayers

Dynamic Layers

Use this parameter to modify the layer drawing order, change layer drawing info, and change the layer data source version for this request. New layers (dataLayer) can also be added to the dynamicLayers based on the map service registered workspaces.

The order of the dynamicLayers array defines the layer drawing order. The first element of the dynamicLayers array draws on top of all other layers.

NoteNote:
  • When defining a dynamic layer, if the layer source is of type mapLayer, use the ID in layer resource as the mapLayerId for the dynamic layer.
  • If the layer source is a dataLayer based on a data table (table or queryTable dataSource), set drawingInfo.
  • If the layer source is a workspace layer based on a layer file (.lyrx) generated from ArcGIS Pro, drawingInfo is optional. When drawingInfo is provided, map service ignores the symbology that is stored with the layer file and instead uses the one the user provides.
  • transparency is on a scale of 1 to 100, where 0 is opaque and 100 is 100 percent transparent.
  • Use scaleSymbols to turn off scaling symbols on a layer that reports canScaleSymbols to be true on the layer resource.
  • Use showLabels to turn on or turn off labeling on a layer that has labels (hasLabels set to true on layer resource).
  • To turn on labels on a layer that does not have labels defined on it, set showLabels to true and use labelingInfo to specify labels.
  • Dynamic layers support both the Standard Label Engine and the Maplex Label Engine. The labeling engine used is dependent on the one that was set in the map document used to create the map service.

Syntax:

[
  {
    "id": <layerOrTableId>,
    "source": <layer source>,
    "definitionExpression": "<definitionExpression>",
    "drawingInfo": 
    {
      "renderer": <renderer>,
      "transparency": <transparency>,
      "scaleSymbols": <true | false >,
      "showLabels": <true | false >,
      "labelingInfo": <labeling info>
    },
    "layerTimeOptions":
    {
      "useTime" : <true | false>,
      "timeDataCumulative" : <true | false>,
      "timeOffset" : <timeOffset>,
      "timeOffsetUnits" : "<esriTimeUnitsCenturies | esriTimeUnitsDays | esriTimeUnitsDecades | 
                             esriTimeUnitsHours | esriTimeUnitsMilliseconds | esriTimeUnitsMinutes | 
                             esriTimeUnitsMonths | esriTimeUnitsSeconds | esriTimeUnitsWeeks | esriTimeUnitsYears |
                             esriTimeUnitsUnknown>"
    }
  },
  {
    "id": <layerOrTableId>,
    "source": <layer source>,
    "definitionExpression": "<definitionExpression>",
    "drawingInfo": 
    {
      "renderer": <renderer>,
      "transparency": <transparency>,
      "scaleSymbols": <true | false >,
      "showLabels": <true | false >,
      "labelingInfo": <labeling info>
    },
    "layerTimeOptions":
    {
      "useTime" : <true | false>,
      "timeDataCumulative" : <true | false>,
      "timeOffset" : <timeOffset>,
      "timeOffsetUnits" : "<esriTimeUnitsCenturies | esriTimeUnitsDays | esriTimeUnitsDecades | 
                             esriTimeUnitsHours | esriTimeUnitsMilliseconds | esriTimeUnitsMinutes | 
                             esriTimeUnitsMonths | esriTimeUnitsSeconds | esriTimeUnitsWeeks | esriTimeUnitsYears |
                             esriTimeUnitsUnknown>"
    }
  }
]

See the Dynamic Layers code block examples section below for examples.

gdbVersion

Geodatabase Version Name

Use this parameter to specify the geodatabase version.

Syntax: gdbVersion=<geodatabase version>

Example: gdbVersion=sde.USER1

mapScale

Map Scale

Use this parameter to export a map image at a specific scale, with the map centered at the center of the specified bounding box (bbox).

Where scale is typically represented as 1:x, this value is x.

Syntax: mapScale=<scale>

Examples: mapScale=5000000, mapScale=5E6

rotation

Rotation

Use this parameter to export a map image rotated at a specific angle, with the map centered at the center of the specified bounding box (bbox). It could be a positive or negative number.

Syntax: rotation=<degree>

Examples: rotation=45 returns a map image rotated 45 degrees counterclockwise.

datumTransformations

Datum Transformations

Use this parameter to apply one or more datum transformations to the map when imageSR is different than the map service's spatial reference. It is an array of transformation elements.

Transformations specified here are used to project features from layers within a map service to imageSR.

NoteNote:

While specifying transformation, you need to think about which datum transformation is most applicable to project a layer to the imageSR. The sourceSpatialReference property for each a layer resource reports which spatial reference features are stored in the source dataset.

For a list of valid datum transformation ID values and well-known ID (WKID) text strings, see Geographic transformations.

Syntax with WKID: datumTransformations=[wkid1, wkid2]

Examples with WKID: datumTransformations=[1623, 4078] to apply multiple transformations

Syntax with datum: datumTransformations=[{<dt1>}, {<dt2>}]

Examples with datum: datumTransformations=[{"wkid":108889}, {"geoTransforms":[{"wkid":108889,"transformForward":true},{"wkid":1622,"transformForward":false}]}] to apply multiple transformations including a composite transformation

For more information on datum transformation, see the transformation parameter in Project operation.

layerParameterValues

Layer Parameter Values

This parameter allows you to filter the features of individual layers in the exported map by specifying values to an array of preauthored parameterized filters for those layers. When this value is not specified for any parameter in a request, the default value assigned during authoring time is used instead.

When a parameterInfo parameter allows multiple values, you must pass them in an array.

NoteNote:

Check parameterInfos at the layer resources for the available parameterized filters, their default values, and the expected data type.

Syntax:

[
   {
     "<layerId1>" : {
       "<parameterName1>" : <value>,               //when the multipleValues=false in the parameterInfo
       "<parameterName2>" : [<value1> | <value2>]  //when the multipleValues=true in the parameterInfo
     },
     "<layerId2>" : {
       "<parameterName3>" : <value>
    }
  }
]&

Example:

[
   {
     "0" : {
       "floor" : 10,
       "incidentDate" : 1475877014000    //date time value needs to be passed in as epoch value
     },
     "1" : {
       "crimeType" : ["burglary", "theft"]
    }
  }
]&

mapRangeValues

Map Range Values

This parameter allows you to filter features in the exported map from all layers that are within the specified range instant or extent.

NoteNote:

Check rangeInfos at the layer resources for the available ranges.

Syntax:

[
  {
    "name" : "<rangeName1>",           //range id
    "value"   : <value> |               //single value or 
                [ <value1>, <value2> ] //a value-range 
                     // null is allowed in value-range case -- that means infinity
                     // e.g. [null, 1500] means all features with values <= 1500
                     // [1000, null] means all features with values >= 1000

  },
  {
    "name" : "<rangeName2>",
    "value" : <value> |  [ <value3>, <value4> ]
  }
]&

Example:

[{
  "name" : "salinity",
  "value" : 5            //a range instant (or single) value passed

 }, {
  "name" : "elevation",
  "value" : [1000, 1500] //a range extent is passed

}]

layerRangeValues

Layer Range Values

This parameter allows you to filter the features of individual layers in the exported map by specifying values to an array of preauthored parameterized filters for those layers. When this value is not specified for any parameter in a request, the default value assigned during authoring time is used instead.

When a parameterInfo parameter allows multiple values, you must pass them in an array.

NoteNote:

Check parameterInfos at the layer resources for the available parameterized filters, their default values, and the expected data type.

Syntax:

[
   {
     "<layerId1>" : {
       "<parameterName1>" : <value>,               //when the multipleValues=false in the parameterInfo
       "<parameterName2>" : [<value1> | <value2>]  //when the multipleValues=true in the parameterInfo
     },
     "<layerId2>" : {
       "<parameterName3>" : <value>
    }
  }
]&

Example:

[
   {
     "0" : {
       "floor" : 10,
       "incidentDate" : 1475877014000    //date time value needs to be passed in as epoch value
     },
     "1" : {
       "crimeType" : ["burglary", "theft"]
    }
  }
]&

patchSize

Patch Size

The dimensions of the exported image for each symbol in the legend. This is specified in device-independent units of points (1 inch = 72 points). If this parameter is not specified, the default size of 15 by 15 points (20 by 20 pixels at 96 DPI) will be exported.

Note that this property has no effect on the point or marker legend patches, as those depend on the actual marker size in the legend.

Syntax: <width>, <height>

Response properties

Property

Details

layerId

The unique order ID number for the layer, as given in the map service resource.

layerName

The name of the layer.

minScale

The minimum scale extent for the layer. Where scale is typically expressed as 1:x, this value is x.

maxScale

The maximum scale extent for the layer.

legend

Provides a representation of each entry in the legend. The following properties are given for each entry:

  • label
  • url
  • imageData
  • contentType
  • height
  • width
  • values

JSON Response syntax

{
  "layers": [
    {
      "layerId": <layerId1>,
      "layerName": "<layerName1>",
      "layerType" : "<layerType1>",
      "minScale": <minScale1>,
      "maxScale": <maxScale1>,
      "legend": [
        {
          "label": "<label11>",
          "url" : "<imageUrl11>", //Relative URL for static layers and full URL for dynamic layers. Access relative URL using http://<mapservice-url>/<layerId1>/images/<imageUrl11>
          "imageData" : "<base64EncodedImageData11>", 
          "contentType" : "<contentType11>",
          "height": <height>,
          "width": <width>,
          "values": [<maximum value1>] //In case of classBreaks renderer values will contain classMaxValue
        },
        {
          "label": "<label12>",
          "url" : "<imageUrl12>",
          "imageData" : "<base64EncodedImageData12>", 
          "contentType" : "<contentType12>",
          "height": <height>,
          "width": <width>,
          "values": [<maximum value2>]
        }
      ]
    },
    {
      "layerId": <layerId2>,
      "layerName": "<layerName2>",
      "layerType" : "<layerType2>",
      "minScale": <minScale2>,
      "maxScale": <maxScale2>,
      "legend": [
        {
          "label": "<label21>",
          "url" : "<imageUrl21>", //Relative URL for static layers and full URL for dynamic layers. Access relative URL using http://<mapservice-url>/<layerId2>/images/<imageUrl21>
          "imageData" : "<base64EncodedImageData21>", 
          "contentType" : "<contentType21>",
          "height": <height>,
          "width": <width>,
          "values": ["uniqueValue1"] //In case of uniqueValue renderer values, this will contain ungrouped unique values.
        },
        {
          "label": "<label22>",
          "url" : "<imageUrl22>",
          "imageData" : "<base64EncodedImageData22>", 
          "contentType" : "<contentType22>",
          "height": <height>,
          "width": <width>,
          "values": ["uniqueValue2", "uniqueValue3"]
        }
      ]
    }
  ]
}

JSON Response example