Select to view content in your preferred language

Changing the opacity of sublayers using the legend control

2599
1
05-31-2011 11:06 AM
NANA
by
Emerging Contributor
Hello,

I'm using silverlight api 2.1/ags server 10 and I want to have opacity sliders for the sublayers of my ArcGISDynamicMapServiceLayer .
I've seen related threads like:
http://forums.arcgis.com/threads/20264-set-opacity-of-sub-layer
and
http://forums.arcgis.com/threads/4757-Opacity-for-sublayers
saying it's impossible.

However in your example here:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LegendWithTemplates
there is basically a workaround of referencing all of the sublayers like this:

<esri:FeatureLayer ID="Points of Interest" 
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer/0" />
<esri:FeatureLayer ID="SubLayer2" 
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer/1" />
<esri:FeatureLayer ID="SubLayer3" 
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer/2" />


after that, we can change the LayerIDs property and have it working with opacity sliders.

Is referencing a FeatureLayer that different from referencing an ArcGISDynamicMapServiceLayer?
Do you think that this workaround is fine?
Can you suggest other workarounds:
Anything from other silverlight workarounds, to server object configuration, and even the underlying mxd.
As server side workarounds I don't mean having opacity sliders, but not having of all my layers with opacity 1 - this is my biggest issue.

Thanks a lot.
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
This is currently not supported by the server.

If you look at the following SDK samples:
Opacity affects the layer (not sub layer, this is why it works on FeatureLayer)
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LayerList
Visibility, however can be set on sub layers (if you choose to continue using ArcGISDynamicMapServiceLayer).
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SubLayerList

If the ArcGISDynamicMapServiceLayer.Layers are represented as FeatureLayer, you will have control over Opacity but there are trade-offs in choosing one layer type over the other. The following document might help you decide: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Layer.html
0 Kudos