Select to view content in your preferred language

Get Layer Legends for Rest service

1971
9
07-27-2010 10:04 PM
AnurithaPathireddy
Emerging Contributor
Hi, How can I get all the legends of the Layers for the Map using silverlight.

I coudn't understand Sample that was given in esri forums
http://resources.esri.com/arcgisserver/apis/silverlight/index.cfm?fa=codeGalleryDetails&scriptID=168...



please help me finding alternative solution for it.
0 Kudos
9 Replies
AnurithaPathireddy
Emerging Contributor
I have found the Solution for My Problem with the thread
http://forums.esri.com/Thread.asp?c=213&f=2455&t=289070

But the Only thing I need is How Can I turn on and Off the Layers with this Solution?
0 Kudos
JenniferNery
Esri Regular Contributor
You can set the Visibility property of the layer and before adding the legend, check if the layer is Visible.

Jennifer
0 Kudos
LisaChesley
Emerging Contributor
Good afternoon!

Are you looking for a way to turn the individual sublayers within a layer on and off?  I have created a control myself that does that.  It goes through each dynamic layer added to the map and creates a legend for that layer, while allowing you to control the transperency of the whole layer, and the visiblity of the various sublayers.  As an added bonus, it also prints.  Please find solution attached.

Note - you will have to compile the unzipped solution, as I deleted the .xap and all the debug files to make the zip file small enough to post.

Note also that this uses the original SOAP method outlined by Morten in the thread you link to, and not the newer REST service.  I'm still trying to figure out how to do what I've already done with that service (although if someone has already got something like this working, I'd love to see it.).

If you have any questions, please let me know!

Lisa Chesley
0 Kudos
AnurithaPathireddy
Emerging Contributor
Hi, Thank you for Responding....

Visual studio Version I am Using is 2008. and also Silverlight version 3.0... So I am Not able to build the Solution..... and also... ArcGIS API for Silverlight is 1.2 So If I Use Tiled Map Service I can't get Layers for the Tiled Map. Can u Please give me any alternative Solution?
0 Kudos
LisaChesley
Emerging Contributor
Good morning!

Sadly, I do not have access to the Silverlight API v1.2 anymore, but I still have VS 2008 and Silverlight 3, so I remade as much of the project as I could.  Attached is a VS 2008 solution with the SOAP service that gets the legend and the custom control that builds the legend for each dynamic layer (it only works for dynamic layers, not tiled ones).

What you will need to do is open the solution, add the ESRI references to the CustomControls project (the layersPlusLegend user control will also require a reference to the ESRI client dll), and add a project that references the CustomControls project.  In your MainPage.xaml, add a map with at least one dynamic service layer on it, and a stack panel called spLegend.  In the initialized event of the dynamic layer, place this code:

ArcGISDynamicMapServiceLayer dynamicServiceLayer = sender as ArcGISDynamicMapServiceLayer;
dynamicServiceLayer.Opacity = 0;
spLegend.Children.Add(new CustomControls.layersPlusLegend(dynamicServiceLayer));      

Hope that helps!

Lisa
0 Kudos
AnurithaPathireddy
Emerging Contributor
Hi Lisa,

Thank you for giving me the solution. That helped me Solving the Problem to turn on /off Layers on the Map using Soap Url.


Can any One Please tell me How Can I Export the Selected Features to Shapefile using Silverlight.......... Do I need to Use Arc Objects for it or any other Solution in silverlight.....



Anuritha.....
0 Kudos
DominiqueBroux
Esri Frequent Contributor

Can any One Please tell me How Can I Export the Selected Features to Shapefile using Silverlight.......... Do I need to Use Arc Objects for it or any other Solution in silverlight.....

There is no way to create shapefile with Silverlight.
The easiest way is probably to use a GP tool.
0 Kudos
AnurithaPathireddy
Emerging Contributor
Can u Please  suggest me the solution How I can achieve this... by GeoProcessor Tool...?
Any web Service is equired for exporting?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I don't think you need a web service. A GP service should work.

The closest sample you can look at is http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ClipFeatures

The input of the tool is a GPFeatureRecordSetLayer which contains the input features (only one is this sample).
After execution, the output is another GPFeatureRecordSetLayer with the clipped counties.
In your case, you would need a zip file containing the shapefile files.

Note that the GP tool used in the sample (http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/USA_Data_ClipTools/GPServer/ClipCounties?...) returns the shapefile as output (parameter output_zip). This output is not used by the code but it could be helpful if you want to make some tests.

About how to write the GP tool itself, I can give you some pointers:
- Threads talking about the GP parameters http://forums.arcgis.com/threads/9001-Clip-and-ship-geoprocessing-service-to-be-utilized-in-silverli...
- FeatureClass to Shapefile tool : http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00120000003m000000.htm
- Dataextraction toolset for server: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/An_overview_of_the_Data_Extraction_too...:

Hope this help.
0 Kudos