Get Legend for a Named Map
Description
Returns the complete legend of a named map by specifying the named map, the swatch size, and mime type of the legends. The legend is returned as single swatch rows, including a base 64 encoded image (or URL) and text description, that make up a complete legend. For each layer in the named map, zero, one, or more legend entries will be returned.
ACL Authorization Flow
To get the complete legend of a named map, the user (or the role they belong to) needs EXECUTE permission on the Named table.
HTTP GET URL Format
The following format is used for HTTP GET requests:
HTTP GET /maps/map name/legend.type;w=width;h=height;t=image type;
[r=resolution]?[inlineSwatch=boolean]&[ignoreLegendRowOverrideVisibility=boolean]
Parameters
For information about the parameter types listed below, see Request URL Data Types.
Parameter | Type | Required | Description |
---|---|---|---|
map name | String | yes | The name of the map to return the legend. The map is specified by a regex for the named map to render based on the location of the named map in the repository. The name of the named map is defined between the /maps portion of the URL and the /legend.legend type portion of the URL. For example, to render a named map located at /earth/Europe in the repository, the following URL would be used: http://hostname:port/rest/Spatial/The name of the map to return the legend.MappingService
/maps/earth/Europe/legend.png;...
|
type | String | yes | The type of information to return the legend (for example, JSON) |
w=width | Integer | yes | Width of the individual legend swatch in pixels |
h=height | Integer | yes | Height of the individual legend swatch in pixels |
t=image type | String | yes | The type of images to return for the legend swatches (for example, gif or png) |
r=resolution | Integer | no | The DPI resolution of the legend swatches as an integer. DPI measures the resolution of images in dots per inch (the number of individual dots that can be placed within the span of one linear inch). If not specified then assumes server default. |
inlineSwatch=boolean | Boolean | no | Determines if the swatch images are returned as data or URL to the image location on the server. By default all swatch images are returned as Base64-encoded images in the JSON response (inlineSwatch=true). To return swatch image URLs to the images located on the server, specify inlineSwatch=false. |
ignoreLegendRowOverrideVisibility=boolean | Boolean | no | Ignores the LegendRowOverride visibility setting in a named resource and returns all legends. |
Returns
Returns an array of String values returned in a JSON response object that represent all the legend swatches for the named map. For each layer in the named map, zero, one, or more legend entries will be returned.
The following response is one swatch description for a single layer in the named map. The image is returned as the default Base64-encoded image.
{
"LegendResponse": [
{
"layerName": "World Capitals",
"rows": [ {
"description": "Point",
"swatch": "data:image/png,iVBORw0KGgoAAAANS...Y7+FTjG4YRZmUapmYLgAAnL52mL+8YEIAAAAASUVORK5CYII="
}],
"title": "World Capitals",
"type": "CARTOGRAPHIC"
}
]
}
The following response is the same swatch as above; however, a URL to the generated swatch image is returned (setting the inlineSwatch parameter to false).
{
"LegendResponse": [
{
"layerName": "World Capitals",
"rows": [ {
"description": "Point",
"swatch": "http://hostname:port/MappingService/services/rest/maps/Samples/NamedMaps/MapWithLayer/
legends/0/rows/0/swatch/16x32.png"
}],
"title": "World Capitals",
"type": "CARTOGRAPHIC"
}
]
}
Example
Return the legend (swatches and information) for the MapWithLayer named map, located in the /Samples/NamedMaps directory in the repository, in JSON format. The swatches will be 32 x 16, in PNG format, and returned as Base64-encoded images.
http://hostname:port/rest/Spatial/MappingService/maps/Samples/NamedMaps/MapWithLayer/
legends.json;w=16;h=32;t=png
Return the legend (swatches and information) for the MapWithLayer named map, located in the /Samples/NamedMaps directory in the repository, in JSON format. The swatches will be 32 x 32, in gif format, and returned as URLs to the images located on the server.
http://hostname:port/rest/Spatial/MappingService/maps/Samples/NamedMaps/MapWithLayer/
legends.json;w=32;h=32;t=gif?inlineSwatch=false