- URL:
- https://<mapservice-url>/queryLegends
- Methods:
GET
- Version Introduced:
- 10.7.1
Description
As of 10.7.1, you can perform this operation 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 image
, 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.
New at 10.9
Supports the following new parameters. These parameters are only supported by map services published from ArcGIS Pro.
time
to control whether you want to include or exclude start and end values specified in theRelation time
parameter.
New at 10.8
Supports the following new parameters. These parameters are only supported by map services published from ArcGIS Pro.
clipping
to mask out layers outside of a clip polygon.spatial
to draw or query only features that meet the spatial filter criteria.Filter
Request parameters
Parameter | Details |
---|---|
(Return Visible Only) | If set to Values: |
(Bounding Box) (Required) | Specifies the extent (bounding box) of the exported image. Unless the Syntax
Example
|
(Bounding Box Spatial Reference) | Specifies the spatial reference of the |
(Layers) | Determines which layers appear on the exported map. There are four ways to specify which layers are shown:
Syntax
Example
|
(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 always be honored. Syntax
|
(Image Size) | Specifies the size (width and height) of the exported image in pixels. If the Syntax
Example
|
(Image Spatial Reference) | Specifies 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 |
(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 Syntax
Example
|
(Image Format) | Specifies the format of the exported image. The default format is Values: |
(Background Transparent) | If set to Values: |
(DPI) | Specifies the device resolution of the exported image (dots per inch). If the Example
|
(Time) | Specifies the time instant or time extent of the exported map image. Syntax
Example
|
(Time Relation) | Allows you to control whether to include or exclude features that are at the beginning or the end of a time window. The default value is Values: Examples, used with the time parameter
|
(Layer Time Options) | Specifies the time options per layer. Users can indicate whether the layer should use the time extent specified by the Syntax
Example
|
(Dynamic Layers) | Modifies the layer drawing order, change layer drawing information, and change the layer data source version for this request. New layers (
Syntax
See the Dynamic Layers code block examples section below for examples. |
(Geodatabase Version Name) | Specifies the geodatabase version. Example
Example
|
(Map Scale) | Exports a map image at a specific scale, with the map centered at the center of the specified bounding box ( Syntax
Examples
|
(Rotation) | Exports a map image rotated at a specific angle, with the map centered at the center of the specified bounding box ( Syntax
Examples
|
(Datum Transformations) | Applies one or more datum transformations to the map when For a list of valid datum transformation ID values and well-known ID (WKID) text strings, see Using spatial references. For more information on datum transformation, see the Syntax
Examples
|
(Layer Parameter Values) | Filters 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 is used instead. When a Syntax
|
(Map Range Values) | Filters features in the exported map from all layers that are within the specified range instant or extent. Syntax
Example
|
(Layer Range Values) | Filters 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 is used instead. When a Syntax
Example
|
(Patch Size) | Specifies 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
|
(Clipping) | Added at 10.8. Masks out layers outside of the clip polygon in the exported map. Clipping can mask out any layer type, in other words, feature layers, raster layers, TIN layers, and so on. Optionally, you can use Syntax
Example
|
(Spatial Filter) | Added at 10.8. Filters out features from all feature layers based on the input spatial filter. This parameter is similar to Syntax
Example
|
(Format) | The response format. Only |
Response properties
Property | Details |
---|---|
| The unique order ID number for the layer, as given in the map service resource. |
| The name of the layer. |
| The minimum scale extent for the layer. Where scale is typically expressed as |
| The maximum scale extent for the layer. |
| Provides a representation of each entry in the legend. The following properties are given for each entry:
|
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 https://<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 https://<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"]
}
]
}
]
}