<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Javascript API print task legend with dynamically rendered layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494076#M45896</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should clarify - 'inputsAgreementsCount' holds the length of a separate array, which contains all the checkboxes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jan 2016 19:24:00 GMT</pubDate>
    <dc:creator>LauraMiles1</dc:creator>
    <dc:date>2016-01-19T19:24:00Z</dc:date>
    <item>
      <title>Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494069#M45889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Hello.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;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.&amp;nbsp; I have tried a couple different approaches:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;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&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164222962083195" jivemacro_uid="_14164222962083195"&gt;
&lt;P&gt;var printTemplate = new PrintTemplate();&lt;/P&gt;
&lt;P&gt;var legendLayers = [];&lt;/P&gt;
&lt;P&gt;var legendLayer = new LegendLayer();&lt;/P&gt;
&lt;P&gt;legendLayer.layerId = "dynLayer_0";&lt;/P&gt;
&lt;P&gt;legendLayer.subLayerIds = [0];&lt;/P&gt;
&lt;P&gt;legendLayers.push(legendLayer);&lt;/P&gt;
&lt;P&gt;printTemplate.layoutOptions = { "titleText": title, "scalebarUnit": this._localMap.getAppConfig().printing.scalebarUnit, "legendLayers": legendLayers};&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Any suggestions on how i can get my dynamically rendered layers to appear in the map legend?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 18:41:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494069#M45889</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2014-11-19T18:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494070#M45890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas, did you ever figure this out? I'm running into the same issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 23:29:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494070#M45890</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2015-12-16T23:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494071#M45891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Laura.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nope. Sorry to say that i never got it figured it. At the 2015 dev summit i chatted with one of the Esri devs and we never got it figured out then either.&amp;nbsp; It 'should' work but doesn't.&amp;nbsp; Not sure if any of the updates since 3.11 helped or not..... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 23:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494071#M45891</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2015-12-16T23:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494072#M45892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, that's disappointing to hear! I'm using 3.15 and the issue still seems to be present. I posted a new question here on geonet but no replies so far. Thanks for your quick response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 23:43:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494072#M45892</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2015-12-16T23:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494073#M45893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good luck. Please post back here if you get an answer to your other thread.&amp;nbsp; Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 23:46:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494073#M45893</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2015-12-16T23:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494074#M45894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I certainly will!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 23:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494074#M45894</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2015-12-16T23:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494075#M45895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas, I did end up getting a solution from ESRI technical support. Apparently a string value works for setVisibleLayers, however this does not pass properly into the printTask. In my situation I needed to convert the string value to an integer. I'm not sure how you've gone about yours but mine was looping through a bunch of checkboxes and updating an array based on which ones were checked, then using that array in setVisibleLayers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for (var i = 0; i &amp;lt; inputsAgreementsCount; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (inputsAgreements&lt;I&gt;.checked) {&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visibleAgreementsLayerIds.push(parseInt(inputsAgreements&lt;I&gt;.value));&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

layerAgreements.setVisibleLayers(visibleAgreementsLayerIds);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where 'inputsAgreementsCount' holds the length of the array, 'inputsAgreements' is the checkbox, and 'visibleAgreementsLayerIds' is the array containing the layerId of each layer that should be visible. Previously I didn't have parseInt in the loop to convert the layerId to an integer. As soon as I added that, everything worked!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully this is some help to you too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:44:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494075#M45895</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2021-12-11T21:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494076#M45896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should clarify - 'inputsAgreementsCount' holds the length of a separate array, which contains all the checkboxes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jan 2016 19:24:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494076#M45896</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2016-01-19T19:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Javascript API print task legend with dynamically rendered layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494077#M45897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Laura.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is awesome! Thank you for your undaunted quest for the answer.&amp;nbsp; I am going to have to brush off an old project and see if we can finally get the printing to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:03:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/javascript-api-print-task-legend-with-dynamically/m-p/494077#M45897</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2016-01-20T20:03:43Z</dc:date>
    </item>
  </channel>
</rss>

