<?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: Wrong symbology in 4.17 Legend widget in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1008936#M71093</link>
    <description>&lt;P&gt;There is a bug logged for this issue in the ArcGIS API for JavaScript 4.15-4.17. It has been fixed for the API version 4.18 of which you can currently test the pre-release by updating the version to 4.18 in your application's html.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Dec 2020 17:44:19 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-12-11T17:44:19Z</dc:date>
    <item>
      <title>Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/168924#M15656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've observed the Legend widget displaying the wrong symbology for some layers; in particular, the Legend will take the symbology for "layer b" and display it for "layer a".&amp;nbsp; I'm fairly certain this is the same problem mentioned in &lt;A _jive_internal="true" href="https://community.esri.com/message/943709-legend-is-updated-incorrectly-in-416"&gt;this thread&lt;/A&gt;, which was observed in 4.16.&amp;nbsp; Below is a description of the cause and a proposed 4.17 solution for those who need a fix "now".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html"&gt;ActiveLayerInfo&lt;/A&gt; class has an internal dictionary for caching legend information retrieved from the server. Keys for this dictionary are generated for each service based upon whether or not the service supports dynamic layers. If dynamic layers are supported, the key is the long JSON string passed&amp;nbsp;as the "dynamicLayers" parameter in the &lt;A href="https://developers.arcgis.com/rest/services-reference/legend-map-service-.htm"&gt;legend request&lt;/A&gt;. If dynamic layers are not supported, the key for the layer is the string "default".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This cache is shared across all instances of &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html"&gt;ActiveLayerInfo&lt;/A&gt;. The intent here is good, in that it can eliminate redundant requests to the server for information that the application has already retrieved. However, the key generation is highly susceptible to collisions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, it is possible for multiple layers that do not support dynamic layers to share the same key "default". Since there is only one entry in the dictionary possible for this key, it will always store the most recently retrieved legend response. As a result, when layer symbology is rendered in the legend, a layer can incorrectly display the symbology for a completely different layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A fix for this is to generate better keys that have fewer collisions. If you're using a locally hosted copy of the API, you can do this yourself.&amp;nbsp; In my solution, I've prepended the layer's URL to the key. In this case you will need to do two find-and-replace operations in the file esri/widgets/Legend.js.&amp;nbsp; Note, this solution is for version 4.17, and may not work with other versions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part 1: search for (in function _getLegendLayers):&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; b&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;a&lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;hasDynamicLayers&lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dynamicLayers&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"default"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;e&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;I&lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;I&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;b&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace with:&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; b&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;url&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;a&lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;hasDynamicLayers&lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dynamicLayers&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"default"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;e&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;I&lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;I&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;b&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part 2: search for (in function _generateLegendElementsForSublayers):&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;p&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;hasDynamicLayers&lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dynamicLayers&lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"default"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace with:&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;p&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;url&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;hasDynamicLayers&lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dynamicLayers&lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"default"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be further noted that my application uses multiple instances of the Legend widget simultaneously, but if I understand this problem correctly,&amp;nbsp;it could still manifest itself when using a single Legend instance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Oct 2020 20:09:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/168924#M15656</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2020-10-21T20:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1000682#M70783</link>
      <description>&lt;P&gt;I'm having this exact same problem.&amp;nbsp; Your reasoning sounds correct.&amp;nbsp; However, I'm using the API through webpack and node.js.&amp;nbsp; It's minimized so I can't find the getLegendLayers function.&amp;nbsp; Have you contacted anyone at esri about this?&amp;nbsp; This sounds like a pretty big bug.&amp;nbsp; I have a lot of different map services in my application.&amp;nbsp; I'm using the layerlist widget with the legend embedded.&amp;nbsp; I'm getting all kinds of unexpected results with layers drawing different legends.&amp;nbsp; Any update on your solution?&amp;nbsp; Esri, any comment on this bug?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 14:51:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1000682#M70783</guid>
      <dc:creator>NilsBabel1</dc:creator>
      <dc:date>2020-11-12T14:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1008936#M71093</link>
      <description>&lt;P&gt;There is a bug logged for this issue in the ArcGIS API for JavaScript 4.15-4.17. It has been fixed for the API version 4.18 of which you can currently test the pre-release by updating the version to 4.18 in your application's html.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 17:44:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1008936#M71093</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-12-11T17:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1011182#M71147</link>
      <description>&lt;P&gt;I have downloaded version 4.18, tested my application, and found that this issue has not been fixed. In my situation, I have the following:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Layer A (a MapImageLayer with no &lt;A href="https://developers.arcgis.com/rest/services-reference/export-map.htm" target="_self"&gt;dynamicLayers&lt;/A&gt;) is visible by default, and loaded into the map.&lt;/LI&gt;&lt;LI&gt;Layer B (a TileLayer with no &lt;A href="https://developers.arcgis.com/rest/services-reference/export-map.htm" target="_self"&gt;dynamicLayers&lt;/A&gt;) is not visible by default, and is also loaded into the map.&lt;/LI&gt;&lt;LI&gt;A Legend widget is created for Layer A and correctly displays the symbology for Layer A.&lt;/LI&gt;&lt;LI&gt;A Legend widget is created for Layer B, but displays nothing because the layer is not visible.&lt;/LI&gt;&lt;LI&gt;Layer B is set to visible, and Legend B correctly displays the symbology for Layer B.&lt;/LI&gt;&lt;LI&gt;After zooming in on the map, Legend A refreshes and now incorrectly displays the symbology for Layer B. (Legend B continues to display the symbology for Layer B, as it should.)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My workaround for 4.18 is the same as for 4.17, although the code to replace in esri/widgets/Legend.js is slightly different:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part 1: search for (in function _getLegendLayers):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(a=a&amp;amp;&amp;amp;a.hasDynamicLayers?a.dynamicLayers:null)||"default",A=va&amp;amp;&amp;amp;va[q];&lt;/LI-CODE&gt;&lt;P&gt;Replace with:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.layer.url+((a=a&amp;amp;&amp;amp;a.hasDynamicLayers?a.dynamicLayers:null)||"default"),A=va&amp;amp;&amp;amp;va[q];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Part 2: search for (in function _generateLegendElementsForSublayers):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;W=Q.hasDynamicLayers&amp;amp;&amp;amp;Q.dynamicLayers||"default";&lt;/LI-CODE&gt;&lt;P&gt;Replace with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;W=this.layer.url+(Q.hasDynamicLayers&amp;amp;&amp;amp;Q.dynamicLayers||"default");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 22:36:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1011182#M71147</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2020-12-18T22:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1022161#M71572</link>
      <description>&lt;P&gt;Hi Joel,&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks a lot for the workaround! It works like charm!&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have the same issue with a single Legend instance. The problem for us, is happening when you load multiple map image layers that include sublayers with same ids. For example Map image layer A with sublayer 1 (let's call it A1) and map image layer B with sublayer 1 (let's call it B1) . Depending the order they are loaded, sometimes the legend for A1 will have the values of B1 and sometimes the legend for B1 will have the values of A1 etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like there is no solution in 4.18. At least, there is nothing in the release notes about it. Hopefully it will be fixed in 4.19!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 16:32:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1022161#M71572</guid>
      <dc:creator>MichailMarinakis1</dc:creator>
      <dc:date>2021-02-01T16:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1065355#M73407</link>
      <description>&lt;P&gt;This was fixed in version 4.19.&amp;nbsp; However, the fix has caused new problems, as seen &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript/4-19-legend-widget-bug-duplicated-requests/td-p/1065353" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 00:04:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1065355#M73407</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2021-06-05T00:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong symbology in 4.17 Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1065540#M73415</link>
      <description>&lt;P&gt;Thanks for the heads up! I will subscribe to the new post.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 07:48:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wrong-symbology-in-4-17-legend-widget/m-p/1065540#M73415</guid>
      <dc:creator>MichailMarinakis1</dc:creator>
      <dc:date>2021-06-07T07:48:38Z</dc:date>
    </item>
  </channel>
</rss>

