Select to view content in your preferred language

Getting custom legend info.

2096
5
12-14-2011 06:49 AM
jonataspovoas
Regular Contributor
Hi,

I'm doing a Silvelight application, and in it I need to get the info about the legend of the map, so I can add it on a printing funtionality. I know that the esri legend class gets it from the rest service (something like http://server/ArcGIS/rest/services/Folder/Service/MapServer/legend) but i don't know how to get this list myself, and i need to get a specific list of items from it (the ones been used - the info about what's shown on the map - at the moment the user clicks the print button).

Does anyone know how to do it?
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
Are you talking about this Print sample? http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#ExportWebMap.

This sample use our Legend control http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#LegendWithTemplates. The legend displays symbols from layer renderer. If you modify this sample to apply a different renderer to the FeatureLayer, this will be used by Legend control. If you want to get to the service-defined renderer, when the layer is initialized, you can check LayerInfo.Renderer.
0 Kudos
jonataspovoas
Regular Contributor
Are you talking about this Print sample? http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#ExportWebMap.


I hadn't seen this sample. Also, I couldn't make it work, when i click at the button nothing happens...

This sample use our Legend control http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#LegendWithTemplates. The legend displays symbols from layer renderer. If you modify this sample to apply a different renderer to the FeatureLayer, this will be used by Legend control. If you want to get to the service-defined renderer, when the layer is initialized, you can check LayerInfo.Renderer.


About the Legend, I need this information, to show on the page.

Something like this:

0 Kudos
DominiqueBroux
Esri Frequent Contributor
If, for any reason, you need to get the list of legend infos out of the legend control, you can use the QueryLegendInfos method that exist on all layer supporting the legend.
That being said, for your sample, you should be able to use the legend control and to retemplate it to get the expected result (for example with a WrapPanel, there is a sample here : http://www.arcgis.com/home/item.html?id=c673bf3e983b418495eeb0f45bb44c68)
0 Kudos
jonataspovoas
Regular Contributor
If, for any reason, you need to get the list of legend infos out of the legend control, you can use the QueryLegendInfos method that exist on all layer supporting the legend.
That being said, for your sample, you should be able to use the legend control and to retemplate it to get the expected result (for example with a WrapPanel, there is a sample here : http://www.arcgis.com/home/item.html?id=c673bf3e983b418495eeb0f45bb44c68)


Hi,

The QueryLegendInfos method do work, but it brings every legend, without the scale filter. This problem i'm already working on, but even with my code to control it, different layers may have, in my case, the same the same info, like Ocean and state limits, and that info is been shown many times in the wrappanel. Is there any way to work that around?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I am still thinking that you should use the legend control that will manage the scale visibility for you, else you have to do it by yourself : each LayerLegendInfo has a MaximumScale and a MinimumScale that you can use to get a visibility depending on the map scale.
0 Kudos