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();
}
}
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
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
Kelly Hutchins Can you confirm if the DotDensity renderer is a supported renderer for use with dynamic layers?
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