Hi Chris,
I am having the same issue with trying to set transparency for an individual layer within a dynamic map service even after I set the image format to png32.
Do you think you might be able to show me your relevant code that you got working? Here is my failed attempt:
baseAll = new ArcGISDynamicMapServiceLayer(urlBaseAll, {});
baseAll.id = "baseAll";
//set up drawing options to make species range transparent
var optionsArray = [];
var drawingOptions = new LayerDrawingOptions();
drawingOptions.transparency = 60;
optionsArray[8] = drawingOptions;
baseAll.setImageFormat('png32');
baseAll.setLayerDrawingOptions(optionsArray);
Any help would be greatly appreciated.
Thanks.
Jason
Hi Jason,
I would, except I honestly don't remember if I ever got it to work and no
longer have the services I was playing with running. If I remember right, I
was putting together a proof-of-concept for something, but it didn't end up
going anywhere. I've been working on completely unrelated (and funded)
projects ever since and haven't gotten back to anything related to ArcGIS
Server. Sorry about that!
Chris
I had same issue and concur with the solution: setting the imageFormat to 'png32' was the key issue. My service was returning 'png8' images by default - which does not seem to support transparency for this API. Below is my code.
// Code is TypeScripty
// Specified map service has 4 layers
this.myDataLayer = new ArcGISDynamicMapServiceLayer(`${mapServiceUrl}${mapServicePath}/MapServer/`, { "visible": true, "id": "My_Data"} );
let layerDrawingOptions: LayerDrawingOptions[]= [];
let drawingOption2 = new LayerDrawingOptions();
// Set 10 percent transparency for layers 0 and 1
drawingOption2.transparency = 10;
layerDrawingOptions[0] = drawingOption2;
layerDrawingOptions[1] = drawingOption2;
// Set 50 percent transparency for layers 2 and 3
let drawingOption = new LayerDrawingOptions();
drawingOption.transparency = 50;
layerDrawingOptions[2] = drawingOption;
layerDrawingOptions[3] = drawingOption;
this.myDataLayer.setLayerDrawingOptions(layerDrawingOptions);
// The following line is required or transparency setting does not work! Default 'png8' does not support transparency.
this.myDataLayer.setImageFormat("png32");
this.map.addLayer(this.myDataLayer);