Hello. I have a dynamic layer that has some transparent polygons as come from the MXD, The transparency is working perfectly fine in the Portal for ArcGIS, but when using the ArcGIS JavaScript viewer it is showing the polygons filled with solid color. Please help! (The imageTransparecny is set to false).
Solved! Go to Solution.
Osama,
No this is not a bug in the API. The thing is that you are using an ArcGISDynamicMapServiceLayer which is just returned to the API from the server as an image and not individual sublayers. So this means that you can not by default set the transparency for one or more specific sublayer in this map service. But you can go this if your ArcGIS Server is 10.1 or greater by using ImageParameters and LayerDarwingOptions.
Here is the updated Fiddle
Hi Osama,
You will need to set the transparency using the opacity property. Ex:
var layer = new ArcGISDynamicMapServiceLayer(layerUrl, { "opacity": 0.5 });
Thanks Jake for the quick respond. setting the opacity will affect the whole layer. I just need to load the layer as seen in the arcmap.
Using the setVisibility property, you can choose which layers to show with the ArcGISDynamicMapServiceLayer. So, you can add this class twice, one for all the layers that will not be transparent, and another for the one that needs transparency applied.
Take a look at this JS Fiddle for an example.
The problem is that in my case I have all the layers in one service. and I have a large number of layers.
Is there a bug with the Javascript API with layers with transparency?
Osama,
No this is not a bug in the API. The thing is that you are using an ArcGISDynamicMapServiceLayer which is just returned to the API from the server as an image and not individual sublayers. So this means that you can not by default set the transparency for one or more specific sublayer in this map service. But you can go this if your ArcGIS Server is 10.1 or greater by using ImageParameters and LayerDarwingOptions.
Here is the updated Fiddle
Thank you Robert, Using the image Parameters fixed the problem.