AnsweredAssumed Answered

using dot density renderer with dynamic layer

Question asked by dmarquardt on Jun 2, 2014
Latest reply on Jun 23, 2015 by nita14
Hello,

I'm looking to make a dot density map with a DynamicMapServiceLayer (dynamic layer).  While I've seen dynamic layers used in other rendering types (such as Class Breaks), I haven't seen one for dot density (the examples I have seen use a FeatureLayer instead).  I've been testing a potential solution below.  The following script is based on
https://developers.arcgis.com/javascript/jssamples/renderer_dynamic_layer_change_attribute.html.  The only change I made was to swap out the classbreaks function for a dot density function (to create a dot density renderer). My questions are:

Have you seen any examples using a dot density renderer with a dynamic Layer?
The Classbreaks function uses a generateRendererTask when setting up the LayerDrawingOptions.  Does the dot density use the same Task? 


Thank you for your time,

David


 
       function getData() {
          domStyle.set("loading", "visibility", "visible");
          dotDensity();
        }
        
        function dotDensity() {
          selectField = registry.byId("fieldNames").get("value") || "POP2007";
          console.log(selectField);
          var renderer = new DotDensityRenderer({
            fields: [{
              name: selectField,
              color: new Color("#CC8800")
            }],
            dotValue: 3200,
            dotSize: 1
          });
          applyRenderer(renderer);  // this is one part I'm not sure of.  
                                    // do I need to put this in a GenerateRendererTask?
        }
  
        function applyRenderer(renderer) {  
          // dynamic layer stuff
          var optionsArray = [];
          var drawingOptions = new LayerDrawingOptions();
          drawingOptions.renderer = renderer; 
          // set the drawing options for the relevant layer
          // optionsArray index corresponds to layer index in the map service
          optionsArray[2] = drawingOptions;
          app.map.getLayer("us_counties").setLayerDrawingOptions(optionsArray);
          app.map.getLayer("us_counties").show();
          // create the legend if it doesn't exist
          if ( ! app.hasOwnProperty("legend") ) {
            createLegend();
          }
        }

Outcomes