AnsweredAssumed Answered

Javascript API print task legend with dynamically rendered layer

Question asked by tomrip on Nov 19, 2014
Latest reply on Jan 20, 2016 by tomrip


I am using v 3.11 of the Javascript API and executing the PrintTask to generate a printable pdf. 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 printed map. But, I can't get a legend for those dynamic layers to appear on the printed map.  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 he 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];
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?


Thank you.