[GIS] Layer vs. Color Transparency with ArcGIS Javascript API

arcgis-javascript-apiarcgis-server

When creating services with ArcGIS Server, I have paid attention to the warning that Layer Transparency will make response time slower and that I should change to color transparency instead so I have been changing it when I "share" the service. Maybe I'm not doing this correctly because I'm not getting the result that I want or maybe I need to ignore the warning.

Currently all my layers are in the same service and I can set opacity to some value 0.5 (and/or can set it individually for different layers e.g. just the layer on top) but the layers on top still cover layers on the bottom. I'd like to see the parcel boundaries underneath the other polygon layers.

mylayer[2].setOpacity(0.1);

Even if I set layer 2 to something almost invisible (like 0.1 as shown in code above; and as rendered below) it covers the parcels underneath (see parcel 0353 in the screenshot below). How should I be doing this instead? Do I need to ignore the warning?

enter image description here

Best Answer

By default, the image format for a dynamic map service is PNG24, which doesn't include an alpha band.

To enable transparency, you will need to pass in some additional options when constructing the dynamic layer in your JavaScript code:

var imageParameters = new ImageParameters();
imageParameters.format = "png32";
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(yourMapServiceURL,{"imageParameters":imageParameters});

edit: There are other image formats that support transparency besides PNG32.