setLayerDrawingOptions is not changing transparency setting

4807
9
04-26-2013 12:11 PM
MasaoMatsuoka
Occasional Contributor
ArcGISDynamicMapServiceLayer's setLayerDrawingOptions is not changing the transparency. It works for the showLabels property, so I think the setup is correct. Has anyone had any success with this?
var drawingOptions = [];
var drawOption = new esri.layers.LayerDrawingOptions();
drawOption.transparency = value / 100; // Not working!! - the value is the value from the slider's onChange event.
drawOption.showLabels = false // This test line works!
drawingOptions[idxLyr] = drawOption;
layer.setLayerDrawingOptions(drawingOptions, false);


ArcGIS Server 10.1 SP1 and JavaScript API 3.2

Thanks for any help.
Masao
Masao Matsuoka
0 Kudos
9 Replies
JohnGravois
Frequent Contributor
you're trying to set the transparency on the entire ArcGISDynamicMapServiceLayer?  have you tried setting its opacity property instead?
0 Kudos
JianHuang
Occasional Contributor III
Please try to set the transparency in the symbol of the renderer.
0 Kudos
MasaoMatsuoka
Occasional Contributor
Thanks, I will try that. So what does drawOption.transparency do for the layer?
Masao Matsuoka
0 Kudos
MasaoMatsuoka
Occasional Contributor
I have set the transparency of the symbol color. But that only makes the color more pale, but not transparent. I also set the LayerDrawingOptions.transparency as well as the 'A' value of the fill symbol color to the same value. But that did not work either. I do not see anywhere else I can set transparency except for the entire map service.
Masao Matsuoka
0 Kudos
MasaoMatsuoka
Occasional Contributor
Additional info:
1) The layer is transparent in the print preview.[ATTACH=CONFIG]24558[/ATTACH]
2) The transparency works within a map service only. I have an aerial image served out of Image Server Extension underneath this layer, and I cannot see the image through the layer.[ATTACH=CONFIG]24559[/ATTACH]
Masao Matsuoka
0 Kudos
MasaoMatsuoka
Occasional Contributor
And make sure to set the image format to PNG32 for the dynamic layer...
layer.setImageFormat('png32');
Masao Matsuoka
0 Kudos
JacksonGilman1
New Contributor III
So what does drawOption.transparency do for the layer?


I'm interested in hearing an answer for this as well.  We have a similar transparency slider scenario.  Our map service is using layer-level transparency (not color-level), and the layer's default transparency is set to 40.  If we were to set drawOption.transparency = 0, the resultant image is correctly opaque, however the colors are faded...leading me to believe the white background is being applied as a mask.

IOW, the Map Service's layer's original transparency setting is not getting entirely overridden when passing a layerDrawingOption.  This is especially apparent when imageFormat is set to 'svg'.  If I make a map export request with the dynamicLayers parameter similar to this:

[
    {
        "id": 0,
        "source": {
            "type": "mapLayer",
            "mapLayerId": 0
        },
        "drawingInfo": {
            "renderer": {
                "type": "simple",
                "label": "",
                "description": "",
                "symbol": {
                    "color": [0, 0, 0, 255],
                    "size": 20,
                    "angle": 0,
                    "xoffset": 0,
                    "yoffset": 0,
                    "type": "esriSMS",
                    "style": "esriSMSCircle",
                    "outline": {
                        "color": [0, 0, 0, 255],
                        "width": 1,
                        "type": "esriSLS",
                        "style": "esriSLSSolid"
                    }
                }
            },
            "transparency": 0,
            "showLabels": false
        },
        "minScale": 5000000,
        "maxScale": 0
    }
]


Note, transparency = 0 and the symbols should be solid black dots.  The svg is this:

<svg version="1.1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="300pt" height="300pt" viewBox="0 0 300 300" xml:space="preserve" enable-background="new 0 0 300 300">
<g color-interpolation="linearRGB" transform="scale(0.75,0.75)">
<g>
 <rect x="0" y="0" width="400" height="400" fill="#FDFDFD" fill-opacity="1" />
</g>
<g id="">
<g opacity="0.6">
<g id="LAYER">



The SVG is still using the layer's original transparency setting of 40 (opacity of 0.6)

We will try the color-level transparency and see if it works better, but binding a slider control to the alpha values of every symbol in a layer's renderer would be rather cumbersome to code, and it would be nicer to have a single transparency value which could be applied for the entire layer.  Has anyone else explored this issue?

Thanks!
0 Kudos
sreeharikottoormadam
New Contributor III

Hi,

ArcGISDynamicMapServiceLayer's setLayerDrawingOptions is changing the transparency? I wanted to change the layer transparency for a particular layer, not the entire dynamic map service layer. I have tried the below code, but not working.

            var optionsArray = [];

            var drawingOptions = new LayerDrawingOptions();

            drawingOptions.transparency = value;    //from a slider

            optionsArray[0] = drawingOptions;

            myLayer.setLayerDrawingOptions(optionsArray);

Thanks

0 Kudos
BrandonFlessner
Occasional Contributor

I also had to enable support for dynamic layer on the map service in ArcGIS Server as well as set the image format to PNG32 for the dynamic layer.

0 Kudos