1

I am using v 3.11 of the ArcGIS API for Javascript and executing the PrintTask to generate a printable pdf of a web map. The map has a couple of Dynamic Map Service Layers that are dynamically rendered, i.e. the user can control the layer symbology based on various inputs.

When I execute the PrintTask, the dynamically rendered layers do appear on the printable pdf map. But, I can't get a legend for those dynamic layers to appear on the pdf. I have tried a couple different approaches:

1) I have excluded the legendLayer array from the 'layoutOptions' object. I was hoping that would automatically generate a legend for all layers on the map, as suggested by the documentation. A legend does appear with the non-dynamic operational layers present, but not the dynamically rendered layers

2) I have created a legendLayer object specific to the dynamically rendered layers, like the code below, but still the layer doesn't appear in the legend.

var printTemplate = new PrintTemplate();  
var legendLayers = [];  
var legendLayer = new LegendLayer();  
legendLayer.layerId = "dynLayer_0";  
legendLayer.subLayerIds = [0];  
legendLayers.push(legendLayer);  
printTemplate.layoutOptions = { "titleText": title, "scalebarUnit": this._localMap.getAppConfig().printing.scalebarUnit, "legendLayers": legendLayers}; 

Any suggestions on how i can get my dynamically rendered layers to appear in the map legend?

(This same question is posted on the Esri discussion forum here)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.