change renderer for dynamic map service

504
2
11-19-2013 04:49 PM
FangmingDu
New Contributor III
Hello Everyone and ESRI,

I'm trying to change the symbology of a dynamic map layer. It already has the GenerateRendererTask enabled.

And actually, I got the renderer object back from GenerateRendererTask, but the color of the map does not change...

In the renderer object, there is one field "_symbols", it has all the class breaks and symbol object (including color,style,type). I applied this renderer object to the dynamic map layer using following code

app.map.getLayer("som_map").setLayerDrawingOptions(optionsArray);
app.map.getLayer("som_map").show();



Does anyone have any ideas about this?
What else I need to check? or Is there any way I can troublshoooooting this?

UPDATE:
Compared to the renderer object from (http://developers.arcgis.com/en/javascript/sandbox/sandbox.html?sample=renderer_dynamic_layer_change...) which works,
I found in my renderer object, it does not have the field "_inherited"...which seems to have a few functions inside. That is probably the problem. But I have no idea about why this happened?????????
0 Kudos
2 Replies
BjornSvensson
Esri Regular Contributor
What else I need to check? or Is there any way I can troublshoooooting this?


What version is your server?
"The GenerateRendererTask is available for map service or tables that support the generateDataClasses operation (version 10.1 or greater)."
https://developers.arcgis.com/en/javascript/jsapi/generaterenderertask.html
0 Kudos
FangmingDu
New Contributor III
Hello,

Thanks for the reply. I'm using ArcGIS server 10.1. I'm pretty sure it supports generate renderer task, because I can even see it while accessing from http://192.168.2.5:6080/arcgis/rest/services/fangming/SOM_DynamicMap/MapServer/0

I'm using the same code in Javascript from the sample.
var classDef = new ClassBreaksDefinition();
   classDef.classificationField = "attr1";
      classDef.classificationMethod = "natural-breaks"; // always natural breaks
      classDef.breakCount = 5; // always five classes
      classDef.baseSymbol = app.sfs;
  
      var colorRamp = new AlgorithmicColorRamp();
      colorRamp.fromColor = new Color.fromHex("#ffffcc");
      colorRamp.toColor = new Color.fromHex("#006837");
      colorRamp.algorithm = "hsv"; // options are:  "cie-lab", "hsv", "lab-lch"
      
      classDef.baseSymbol = new SimpleFillSymbol("solid", null, null);
      classDef.colorRamp = colorRamp;
  
      var params = new GenerateRendererParameters();
      params.classificationDefinition = classDef;
      console.dir("classDef");
      console.dir(classDef);
      var generateRenderer = new GenerateRendererTask("http://192.168.2.5:6080/arcgis/rest/services/fangming/SOM_DynamicMap/MapServer/0");
      generateRenderer.execute(params, applyRenderer, errorHandler);

    function applyRenderer(renderer) { 

        console.dir(JSON.stringify(renderer));
         
          var optionsArray = [];
          var drawingOptions = new LayerDrawingOptions();
          drawingOptions.renderer = renderer; 
          optionsArray[2] = drawingOptions;
          
          
          basemap.setLayerDrawingOptions(optionsArray);
          basemap.show();
 }


Then I printed out the renderer object as following:
{"breaks":[[0.00215526,0.0100578],[0.0100578,0.0181308],[0.0181308,0.0302279],[0.0302279,0.0463656],[0.0463656,0.0627432]],"_symbols":{"0.00215526-0.0100578":{"type":"simplefillsymbol","style":"solid","color":{"r":255,"g":255,"b":204,"a":1}},"0.0100578-0.0181308":{"type":"simplefillsymbol","style":"solid","color":{"r":184,"g":217,"b":130,"a":1}},"0.0181308-0.0302279":{"type":"simplefillsymbol","style":"solid","color":{"r":97,"g":179,"b":72,"a":1}},"0.0302279-0.0463656":{"type":"simplefillsymbol","style":"solid","color":{"r":28,"g":142,"b":45,"a":1}},"0.0463656-0.0627432":{"type":"simplefillsymbol","style":"solid","color":{"r":0,"g":104,"b":55,"a":1}}},"infos":[{"classMaxValue":0.0100578,"label":"0.00216 - 0.01006","description":"","symbol":{"type":"simplefillsymbol","style":"solid","color":{"r":255,"g":255,"b":204,"a":1}},"minValue":0.00215526,"maxValue":0.0100578},{"classMaxValue":0.0181308,"label":"0.01007 - 0.01813","description":"","symbol":{"type":"simplefillsymbol","style":"solid","color":{"r":184,"g":217,"b":130,"a":1}},"minValue":0.0100578,"maxValue":0.0181308},{"classMaxValue":0.0302279,"label":"0.01814 - 0.03023","description":"","symbol":{"type":"simplefillsymbol","style":"solid","color":{"r":97,"g":179,"b":72,"a":1}},"minValue":0.0181308,"maxValue":0.0302279},{"classMaxValue":0.0463656,"label":"0.03024 - 0.04637","description":"","symbol":{"type":"simplefillsymbol","style":"solid","color":{"r":28,"g":142,"b":45,"a":1}},"minValue":0.0302279,"maxValue":0.0463656},{"classMaxValue":0.0627432,"label":"0.04638 - 0.06274","description":"","symbol":{"type":"simplefillsymbol","style":"solid","color":{"r":0,"g":104,"b":55,"a":1}},"minValue":0.0463656,"maxValue":0.0627432}],"attributeField":"attr1","classificationMethod":"natural-breaks","isMaxInclusive":true}
0 Kudos