Select to view content in your preferred language

using dot density renderer with dynamic layer

4069
4
06-02-2014 11:54 AM
DavidMarquardt
Deactivated User
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();
          }
        }
0 Kudos
4 Replies
nita14
by
Frequent Contributor

implement FeatureLayer instead of Dynamic Map Service Layer.

Below you find my code:

var postalDemoRen = new DotDensityRenderer({
  fields: [{
   name: "field_name",
   color: new Color([52, 114, 53])
  }],
  dotValue: 10,
  dotSize: 2
   });
var postalDemo = new FeatureLayer(".../MapServer/107",{
  mode: FeatureLayer.MODE_ONDEMAND,
  outFields: ["*"]
  });

  postalDemo.setRenderer(postalDemoRen);

Regards,

Adm

DavidMarquardt
Deactivated User

Adam,

Thanks so much!  I'm specifically looking to use it with dynamic map service, because I usually am working with many records (300 + county polygons). These tend to slow down or become unusable as a feature service.

David

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kelly Hutchins​ Can you confirm if the DotDensity renderer is a supported renderer for use with dynamic layers?

0 Kudos
nita14
by
Frequent Contributor

As far as I know, DotDensity and ScaleDependentRenderer are not supported for Dynamic Map Services.

It slows dawn, because the app actually download the requested data. I think you have two options:

     - simplify cunties polygons using GeometryService and generalize method (not tested, could also take a while to process depending on your data)

     - make a copy of original data (if possible), make geometry and attribute generalization in ArcGIS, then share as feature service using AGOL

Hope this helps a bit,

Regards,

Adam

0 Kudos