Legend swatch images for Cached Map Service should be pre-generated and saved under cache folder

Idea created by hho-esristaff Employee on May 17, 2011
    Currently, at 10.0 SP1, support for a Map Service Legend child resource was added. Map legend can be request via ArcGIS Server REST API using the syntax like this http://services.arcgisonline.com/ArcGIS/SDK/REST/mapserver.html"DK/REST/mapserver.html" target="_blank"><mapservice-url>/legend

    Legend swatch image for each layer can be accessed directly using the URL syntax

    However, when a legend request is sent to the Server, the server will query the map document (MXD or MSD) to generate the Legend image. This should be no problem for dynamic service and regular cached map services such as

    Dynamic service:

    Cached service:

    However, after the cache is created, the best practice for maintaining cached services is to remove some or all of the laters from the source map docuemnt, leaving just one simple or dummy layer in the map document to maintain the coordinate system and extent as discussed here.

    This will be a problem for ArcGIS Online services hosted on ArcGIS.com because legend response will be blank like this


    My idea is once the cache is generated, the associated legend image and/or swatches should be created and saved in the same cache folder (same as conf.xml file) for example c:\arcgisserver\arcgiscache\<Map_Service_Name>\Layers\ The rest handler should be able to process the legend request and go to arcgiscache folder to retrieve the legend swatches/images.

    This way, when layers are removed from the source map document, legend is still working for these cached map services.