<?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: LayerList and setting Legend graphics in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527025#M49180</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect. Thanks for that info David.&amp;nbsp;&amp;nbsp; Great work team ESRI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I think (??) this is new.. .but I noticed in the Sample now that LayerList turns on as soon as you 'open' a Group.&amp;nbsp; This is awesome. Smart thinking. Because this solves the question I've always had of if they'd make groups automatically turn on, if you turn a child sublayer on. Now, it's fixed, because opening a group turns in on.&amp;nbsp; Makes sense.&amp;nbsp; So happy with this widget now.&amp;nbsp; The last thing I'm wondering is if ESRI will add transparency sliders like AGSTOC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe ESRI should consider adding a 'partial' icon for the Checkbox of a group if only some of the layers are turned on.&amp;nbsp;&amp;nbsp; (i.e. &lt;A href="https://css-tricks.com/indeterminate-checkboxes/" title="https://css-tricks.com/indeterminate-checkboxes/"&gt;https://css-tricks.com/indeterminate-checkboxes/&lt;/A&gt;​ &amp;amp; &lt;A href="http://www.axure.com/c/forum/feature-requests/11684-indeterminate-partially-checked-checkboxes.html" title="http://www.axure.com/c/forum/feature-requests/11684-indeterminate-partially-checked-checkboxes.html"&gt;Axure Forums&lt;/A&gt;&amp;nbsp; ) That square dot that indicates only some of the group layers are on, like how desktop applications indicate this. This actually even applies to ArcGIS &lt;STRONG&gt;Desktop'&lt;/STRONG&gt;s TOC as well.&amp;nbsp; This user interface metaphor is widely understood and nearly universal in software.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Dec 2015 19:14:28 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2015-12-04T19:14:28Z</dc:date>
    <item>
      <title>LayerList and setting Legend graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527023#M49178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All - &lt;/P&gt;&lt;P&gt;In working with the LayerList widget the past month or so we kept trying to figure out a way to get the symbology from the feature layer and Legend into the innerHTML of the option of the LayerList widget so that we can display the feature layers' graphic under each list node. So we went back to the map's on 'layers-add-result' event setting up the function to return each layer and each layers defined id as the title:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mapMain.on("layers-add-result", function(results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerInfo = array.map(results.layers, function (layer, index) { //dojo array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return {layer:layer.layer, title:layer.layer.id};
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend = new Legend({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map : mapMain,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerInfos: layerInfo,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrangement : Legend.ALIGN_LEFT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&amp;nbsp; "legendDiv");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.startup();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; layerInfo.length; i++){ // cant use i=0, when a label layer is present,don't know why yet.
&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; console.log(legend.layerInfos&lt;I&gt;);&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; layerInfo&lt;I&gt;.content = domConstruct.create("div", {&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; innerHTML: legend.domNode.childNodes[(layerInfo.length -1) -i].childNodes[1].innerHTML
&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; layerList = new LayerList({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map: mapMain,&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers : layerInfo
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, "layerListDiv");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerList.startup();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
mapMain.on("zoom-end", function(results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.refresh();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; layerInfo.length; 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;&amp;nbsp;&amp;nbsp; layerInfo&lt;I&gt;.content = domConstruct.create("div", {&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; innerHTML: legend.domNode.childNodes[(layerInfo.length -1) -i].childNodes[1].innerHTML
&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; layerList.refresh();
 }
 });
document.getElementById("legendDiv").style.display = "none";&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically we (&lt;A href="https://community.esri.com/migrated-users/11394" target="_blank"&gt;Michael Stranovsky&lt;/A&gt;​) and myself discovered by setting a console log on the legend layerInfos, we could see that legend has a content property and that by stepping into the content property we could get at the innerHTML dom element that contains the graphic and at what index level.&amp;nbsp; So the for loop says that for each layer, go into the content, construct a div and then set the innerHTML of each layer at child node index: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;[(layerInfo.length - 1) -i]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because the legend layer ordering is the reverse of the map layer ordering we add the additional (-i).&amp;nbsp; At any rate, the innterHTML completes by stepping down one more childNodes element [1] to get at the graphic (childNodes element at [0] is the layer title text).&amp;nbsp; Add&amp;nbsp; the layerList Widgets, pass in the layerInfo value from the loop into the layerInfos option, and start the layerList.&amp;nbsp; To keep from displaying the legend div, simply set it's display to none.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are layers with zoom dependency, no childNodes element will be created in the legend because they don't exist yet.&amp;nbsp; So add a on 'zoom-end' event with a legend refresh, loop through the layers childNodes elements again and refresh the layer list and when the node is created it will be added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Known issue(s):&amp;nbsp; With a label layer present in the map, the loop counter must be started at 1.&amp;nbsp; Don't know why yet.&amp;nbsp; I also haven't tested this configuration using tiled or dynamic layers.&amp;nbsp; I welcome any comments or insights . . .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:57:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527023#M49178</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2021-12-11T22:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: LayerList and setting Legend graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527024#M49179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;With the 3.15 update, the above code is no longer needed, thank you ESRI&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.&amp;nbsp; Now simply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapMain.on("layers-add-result", function(results) { 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var layerInfo = array.map(results.layers, function (layer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return {layer:layer.layer, title:layer.layer.id};
&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; var layerList = new LayerList({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map: mapMain,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showLegend: true, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers : layerInfo
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, "layerListDiv");
&amp;nbsp; layerList.startup();
&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set the showLegend constructor option to true and you have your legend...&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:57:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527024#M49179</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2021-12-11T22:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: LayerList and setting Legend graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527025#M49180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect. Thanks for that info David.&amp;nbsp;&amp;nbsp; Great work team ESRI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I think (??) this is new.. .but I noticed in the Sample now that LayerList turns on as soon as you 'open' a Group.&amp;nbsp; This is awesome. Smart thinking. Because this solves the question I've always had of if they'd make groups automatically turn on, if you turn a child sublayer on. Now, it's fixed, because opening a group turns in on.&amp;nbsp; Makes sense.&amp;nbsp; So happy with this widget now.&amp;nbsp; The last thing I'm wondering is if ESRI will add transparency sliders like AGSTOC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe ESRI should consider adding a 'partial' icon for the Checkbox of a group if only some of the layers are turned on.&amp;nbsp;&amp;nbsp; (i.e. &lt;A href="https://css-tricks.com/indeterminate-checkboxes/" title="https://css-tricks.com/indeterminate-checkboxes/"&gt;https://css-tricks.com/indeterminate-checkboxes/&lt;/A&gt;​ &amp;amp; &lt;A href="http://www.axure.com/c/forum/feature-requests/11684-indeterminate-partially-checked-checkboxes.html" title="http://www.axure.com/c/forum/feature-requests/11684-indeterminate-partially-checked-checkboxes.html"&gt;Axure Forums&lt;/A&gt;&amp;nbsp; ) That square dot that indicates only some of the group layers are on, like how desktop applications indicate this. This actually even applies to ArcGIS &lt;STRONG&gt;Desktop'&lt;/STRONG&gt;s TOC as well.&amp;nbsp; This user interface metaphor is widely understood and nearly universal in software.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Dec 2015 19:14:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527025#M49180</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-12-04T19:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: LayerList and setting Legend graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527026#M49181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 3.15 version does have a transparency slider built in. You can add it with the &lt;A href="https://developers.arcgis.com/javascript/jsapi/layerlist-amd.html#showopacityslider"&gt;showOpacitySlider&lt;/A&gt; property. Originally, it could be added by utilizing one of the optional custom nodes, but this is an easier implementation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Dec 2015 16:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527026#M49181</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2015-12-08T16:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: LayerList and setting Legend graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527027#M49182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ken. Sweet. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Dec 2015 18:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527027#M49182</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-12-08T18:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: LayerList and setting Legend graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527028#M49183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah Ken I saw your earlier sample with slider node, got us thinking about child nodes in the legend and adding as the innerHtml content at 3.14, hence what we were able to come up with. But yes 3.15 much easier for sure &lt;/P&gt;&lt;P&gt;Thanks for that-&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Dec 2015 19:08:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/layerlist-and-setting-legend-graphics/m-p/527028#M49183</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2015-12-08T19:08:21Z</dc:date>
    </item>
  </channel>
</rss>

