legend


URI

1. <layer_uri>/legend[.<format>]

2. <layer_uri>/items/{itemID}/legend[.<format>]

Supported methods

GET, HEAD

Parent resource

layer

Introduction

As a child resource of the layer, the legend resource is used to display the layer style in the form of legend. The user can designate the image size of the legend through width and height.

The URI1 can be used to get the legend of the general layer, and the URI2 is used to get the subitems legends like ThemeUnique, ThemeGraph and ThemeRange, where {itemID} is counted from 0, and the desirable maximum is the number of subitems of theme map minus 1.

Supported methods:

Supported output formats: PNG, BMP, GIF, JPG.

GIS Services Resource Hierarchy

resources.htm maps.htm map.htm layer.htm layers.htm

HTTP request methods

Here is an example of performing an HTTP request on the following URI, with rjson as the output format. In the URI, supermapiserver is the name of the server, "WorldMap" is the map name ({mapName}),  Capitals@World is a layer of Map "WorldMap" ({layerName}), Capitals@World@@ WorldMap represents a sublayer of  World layer. Therefore, the URI represents the legend image of the Capitals@World layer.

http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/layers/Capitals@World@@WorldMap/legend.png

GET request

Gets the legend image of the layer.

 Request parameters

A GET request is performed on the legend resource. When getting the legend image of the layer, it can be customized by passing the parameter in URI, or not by passing the parameter.

 Parameters in URI

Name Type Description
width int The width of the symbol picture to be got. Default is 16 pixels.
height int The height of the symbol picture to be got. Default is 16 pixels.

Response structure

The response of the legend resource is image stream, whose format is determined by the suffix of the resource URI.

Example usage

A GET request is performed on the legend resource of Capitals@World (a vector layer of WorldMap): http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/layers/Capitals@World@@WorldMap/legend.png?width=30&height=30, and the layer legend can be got. The returned PNG-format image is as follows:

It is a 30*30 pixel picture. If the picture size is not designated, a 16*16 pixel legend image will be generated by default.

A GET request is performed on http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/layers/Unique ValuesMap@@WorldMap/items/0/legend.png?width=60&height=30, and the legend image of the first subitem of "ThemeUnique" layer can be got.

There are four subitems of "ThemeUnique" layer. When {itemID} is too large, the server will return the error message in json format. Here is an example of performing a GET request on http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/layers/Unique ValuesMap@@WorldMap/items/4/legend.png?width=60&height=30,  and the status code of the acquired HTTP response is 404, and the content of response entity body is as follows:

 {"succeed":false,"error":{"errorMsg":" Index of requested subitem is not in the scope of the subitem set ","code":404}}  

HEAD request

Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content. The meta-information includes the media-type, content-encoding, transfer-encoding, content-length, etc.

The HEAD request helps check the existence of the legend resource and whether it can be accessed by the client. By implementing the HEAD request on the URI, with .<format> appended to the end, we can quickly get to know whether the legend resource supports the representation in <format> or not.

See