var imageParams = new esri.layers.ImageParameters(); imageParams.layerIds = [2]; imageParams.transparent = true; imageParams.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW; var options = { imageParameters: imageParams, opacity: 0.5, disableClientCaching: true }; var oblLayer = new esri.layers.ArcGISDynamicMapServiceLayer(gaiis_features_baseurl + "/MapServer"); var optionsArray = []; var drawingOptions = new esri.layers.LayerDrawingOptions(); optionsArray[2] = drawingOptions; oblLayer.setLayerDrawingOptions(optionsArray); map.addLayer(oblLayer);
Where are you setting the renderer for the layer? Take a look at the samples, which show how to set it.
var symbol = new esri.symbol.SimpleFillSymbol(); symbol.setColor(new dojo.Color([150, 150, 150, 0.5])); oblRenderer = new esri.renderer.ClassBreaksRenderer(symbol, getValue); drawingOptions.renderer = oblRenderer;
oblLayer.setRenderer(oblRenderer);
var oblLayer = new esri.layers.ArcGISDynamicMapServiceLayer(gaiis_features_baseurl + "/MapServer",options);
oblLayer.setVisibleLayers([2])
In order to set the layer renderer you must have that layer only set as visible.
In your code you are creating the imageparameters but not passing your options variable while creating your dynamic layer.var oblLayer = new esri.layers.ArcGISDynamicMapServiceLayer(gaiis_features_baseurl + "/MapServer",options);
If you don't want to pass the imageparameters then you must call setVisibleLayers([2]) function on your dynamic layeroblLayer.setVisibleLayers([2])
function initAnalyze() { var imageParams = new esri.layers.ImageParameters(); imageParams.layerIds = [2]; imageParams.transparent = true; imageParams.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW; var options = { imageParameters: imageParams, opacity: 0.5, disableClientCaching: true, id: "oblLayer" }; var oblLayer = new esri.layers.ArcGISDynamicMapServiceLayer(gaiis_features_baseurl + "/MapServer",options); /* oblLayer.setVisibleLayers([2]); oblLayer.setOpacity(0.3); */ var symbol = new esri.symbol.SimpleFillSymbol(); symbol.setColor(new dojo.Color([150, 150, 150, 0.5])); oblRenderer = new esri.renderer.ClassBreaksRenderer(symbol, getValue); var optionsArray = []; var drawingOptions = new esri.layers.LayerDrawingOptions(); //drawingOptions.renderer = oblRenderer; optionsArray[2] = drawingOptions; map.addLayer(oblLayer); map.setLevel(7); dojo.connect(map,"onClick",function(a){ tmp(); }); }; function tmp() { var o=[]; var a=new esri.layers.LayerDrawingOptions(); o[2]=a; map.getLayer("oblLayer").setLayerDrawingOptions(o); map.getLayer("oblLayer").refresh(); } function getValue(id) { return 5; }
Just check this way by adding your layer as FeatureLayer in this sample if it is working
To set transparency for an individual layer, I had to enable support for dynamic layer on the map service in ArcGIS Server, set the image format to PNG32 for the dynamic layer --> layer.setImageFormat('png32');