Select to view content in your preferred language

LayerDrawingOptions does not working

3235
7
06-13-2013 10:27 AM
EvgenyYakubov
Emerging Contributor
Good day everybody!
I have a service working on ArcGIS for Server 10.1.
I trying to use LayerDrawingOptions (javascript api 3.5):
    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);


I not see the layer oblLayer!
If to comment string optionsArray[2] = drawingOptions; or oblLayer.setLayerDrawingOptions(optionsArray); - everythings working fine and i see all layers.
I not see any errors in firebug!
Help please.
Thank you.
0 Kudos
7 Replies
KenBuja
MVP Esteemed Contributor
Where are you setting the renderer for the layer? Take a look at the samples, which show how to set it.
0 Kudos
EvgenyYakubov
Emerging Contributor
Where are you setting the renderer for the layer? Take a look at the samples, which show how to set it.


This very simple example: first time, I trying without renderer, but then I tried with renderer - it does not working too!

To start renderer I making this code:
    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;

It does not work.

But renderer working with FeatureLayer (rendering VERY slow - a lot of big polygons) :
oblLayer.setRenderer(oblRenderer);  
0 Kudos
VinayBansal
Frequent Contributor
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 layer

oblLayer.setVisibleLayers([2]) 
0 Kudos
EvgenyYakubov
Emerging Contributor
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 layer

oblLayer.setVisibleLayers([2]) 


I'm sorry, I forgot to insert full line into my code tags.
I tried this way too. Does not working.
Last trying was this code:
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;
}


I'm loading map, everythings fine.
Then I clicking on the map and if I scrolling map, then oblLayer not drawing...
You can to see it here:
[ATTACH=CONFIG]25265[/ATTACH]
0 Kudos
VinayBansal
Frequent Contributor
Just check this way by adding your layer as FeatureLayer in this sample if it is working

http://developers.arcgis.com/en/javascript/jssamples/renderer_class_breaks.html
0 Kudos
EvgenyYakubov
Emerging Contributor
Just check this way by adding your layer as FeatureLayer in this sample if it is working

Renderer with featureLayer working good, but very slow.
Now I trying to upgrade ArcGIS server to 10.1 service pack 1. I am not sure about license and esri's support, but i'll try...
0 Kudos
BrandonFlessner
Frequent Contributor

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');

0 Kudos