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

550
1
05-17-2011 04:03 PM
Status: Open
HieuHo
by
New Contributor III
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
http://<mapservice-url>/<layerId1>/images/<imageUrl11>

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:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/M...

Cached service:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyBasemap/MapServe...

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

http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/legend
http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/legend

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.
1 Comment
HieuHo
by
Yes, map legend is very important to maps. Without legend, maps might be misleading or not helpful as they should be.