opacity slider for individual layers within one map service

3544
6
11-09-2011 05:22 PM
RhysDonoghue
New Contributor
I'm doing something that I would have thought should be quite simple.  I have a table of contents with checkboxes to turn layers on and off.  All of the layers are coming from only one dynamic map service.  I am making the layers visible/invisible by using an ArrayCollection like this:

<esri:Map>
     <esri:ArcGISDynamicMapServiceLayer id="dynamicCensusBlockPoints"
         url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer">
         <esri:visibleLayers>
             <mx:ArrayCollection>
                 <mx:Number>0</mx:Number> <!-- Show census block points only -->
             </mx:ArrayCollection>
         </esri:visibleLayers>
     </esri:ArcGISDynamicMapServiceLayer>
</esri:Map>

(from http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/com/esri/ags/layers/ArcGISDynamicMa...
)

I am populating the ArrayCollection via ActionScript.  Everything is working properly, however now I want to add in an opacity slider for each layer.  Obviously it is easy enough to change the layer opacity for the whole map service but I want to do it for individual layers.  I can create the opacity sliders against each layer easy enough but I can't figure out how to get the opacity property in the ArrayCollection.  Worst case scenario, I have two options 1: tell the client they cannot have opacity sliders on the layers, or 2: I repeat the dynamic map service 12 times for each of my 12 layers, set the visible layers for each of the map services to only one for each map service, and apply the opacity to each map service.  Surely it can be done easier than this though.  Anyone have any ideas?
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
Rhys,

  Don't waste any more of your time on this as currently setting the opacity of individual layer in a map service is NOT possible. To understand why you have to understand how ArcGIS Server handles requests from the client. Currently the request is made and the request can specify which layers are to be turned on or off but the map service does not have any method to expose the opacity of an individual layer, the request is processed and an image is returned (i.e. a JPG or PNG, etc not individual layers that can be adjusted). In ArcGIS Server 10.1 you are suppose to be able to have more control of the returned data (i.e. you can change the symbology of a feature before it is returned).
0 Kudos
RhysDonoghue
New Contributor
thanks Robert

My next question then is if I keep all of the 12 layers we want in the same dynamic service but repeat the service 12 times in my code with a different layer visible in each repeat, then will this cause performance issues, i.e. will it be much slower having the map service repeated 12 times than having it only once? 

I look forward to hearing from you.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Rhys,

    It will definitely have an impact on performance so you need to decide if it is worth the trade off.
0 Kudos
HessCorporation
New Contributor
I used to split my map services in the app as discussed, so just a warning that it totally throws off any service stats. If you have a service with 10 layers that are referenced individually each site hit results in 10 service hits, this happens whether the layer is set to visible or not - some stats can be adjusted but many can't.

I had to accept the loss in functionality as i need accurate performance stats, the performance loss wasn't bad at all though, i certainly never had any complaints from users.
0 Kudos
RhysDonoghue
New Contributor
great thanks Robert.  I will advise our client it is a bad idea
0 Kudos
waelgomaa
New Contributor

Hey ,

i have suggestion ,

don't add the map service as a map services but add each layer as a featurelayer then you can control it

0 Kudos