Select to view content in your preferred language

JSAPI is not honoring transparency setting in map service

769
4
02-28-2013 07:12 AM
DonnyVelazquez
Frequent Contributor
I have a map service with a dynamic layer that has a transparency set to 50 on it.
When its brought into ArcMap the transparency is honored but when brought
in using JSAPI it doesn't honor it. I'm using version 3.3.

Is there a fix for this?
0 Kudos
4 Replies
MarcusBush
Emerging Contributor
When I've had this issue, I have made sure to set an image parameter to PNG 32 on the layer that I need transparencies on:

    var imgParams = new esri.layers.ImageParameters();
    imgParams.format = "PNG32";

    var exampleLayer = new esri.layers.ArcGISTiledMapServiceLayer(
          "http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer",
    { id: testLayerID, imageParameters: imgParams, visible: true });
0 Kudos
YvanBérard
Regular Contributor
I had this problem and i sent a ticket to ESRI.

I had two layers, one a tiledservice (MrSID imagery) and a dynamicservice of polygons.

The inside of the polygons were empty but when adding the polygon over the tiled service, the transparency and the antialiasing weren't working at all. But when we set the image format to png 32 of the dynamicservice with your trick, it all work fine.

But, if you check the documentation in the API, it says that you need to use the function setImageFormat or the pass the parameter imageFormat in the creation of you TiledService, but it won't work. But with your trick, it works very well.
0 Kudos
by Anonymous User
Not applicable
Actually....this works well too:


var imgParams = new esri.layers.ImageParameters;
imgParams.format = "PNG24";

var yourMap = new esri.layers.ArcGISDynamicMapServiceLayer("http://yourURL/ArcGIS/rest/services/yourMapService/MapServer", {"opacity":0.6, "imageparameters": imgParams});
0 Kudos
ShawnCarson
Regular Contributor
Thanks Marcus & Gibby. Your solutions worked for me.

FYI: If you use a esri.layers.FeatureLayer it seems to respect the opacity no need to set an image parameter....
0 Kudos