<?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 Problem with updating legend in Legend widget  in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222569#M20680</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the problem:&lt;/P&gt;&lt;P&gt;I'm developing a widget that allows classify the visualization of thematic layers depending of selected field.&lt;/P&gt;&lt;P&gt;So, when I apply the render the first time, the legend works fine. Now, if I change de layer, it applies the render but legend take the default value, not the current value. This happens sometimes but not always, I don't understand what is hapenning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my code when I create the Legend:&lt;/P&gt;&lt;P&gt;createLegend: function () {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;htmlF = "&amp;lt;div id='legendDiv' &amp;gt;&amp;lt;/div&amp;gt;";&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var node = domConstruct.toDom(htmlF);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;domConstruct.place(node, 'legendField');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.legend = new Legend({&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;map: this.map,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layerInfos: [{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hideLayers: this.parameters.idHideLayers,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layer: this.parameters.layer,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;title: this.parameters.layer.title&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;BR /&gt; }, 'legendDiv');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.legend.startup();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.legend.refresh();&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Legend also takes an array of sublayer Ids that will be hide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="thematic classification" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/318622_asd.png" style="width: 620px; height: 516px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Feb 2017 20:13:55 GMT</pubDate>
    <dc:creator>RolandoFlorez</dc:creator>
    <dc:date>2017-02-09T20:13:55Z</dc:date>
    <item>
      <title>Problem with updating legend in Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222569#M20680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the problem:&lt;/P&gt;&lt;P&gt;I'm developing a widget that allows classify the visualization of thematic layers depending of selected field.&lt;/P&gt;&lt;P&gt;So, when I apply the render the first time, the legend works fine. Now, if I change de layer, it applies the render but legend take the default value, not the current value. This happens sometimes but not always, I don't understand what is hapenning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my code when I create the Legend:&lt;/P&gt;&lt;P&gt;createLegend: function () {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;htmlF = "&amp;lt;div id='legendDiv' &amp;gt;&amp;lt;/div&amp;gt;";&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var node = domConstruct.toDom(htmlF);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;domConstruct.place(node, 'legendField');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.legend = new Legend({&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;map: this.map,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layerInfos: [{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hideLayers: this.parameters.idHideLayers,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layer: this.parameters.layer,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;title: this.parameters.layer.title&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;BR /&gt; }, 'legendDiv');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.legend.startup();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.legend.refresh();&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Legend also takes an array of sublayer Ids that will be hide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="thematic classification" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/318622_asd.png" style="width: 620px; height: 516px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2017 20:13:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222569#M20680</guid>
      <dc:creator>RolandoFlorez</dc:creator>
      <dc:date>2017-02-09T20:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with updating legend in Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222570#M20681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rolando,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; From the api docs:&lt;/P&gt;&lt;P&gt;You should call legend.refresh() after you change your layer renderer because you have specified the layerInfos.&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Refresh the legend. Takes an optional list of layerInfos to replace the layers setup by the legend constructor. Calling refresh is only necessary when layerInfos is used in the Legend constructor, otherwise the legend will refresh the layers automatically.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Feb 2017 18:58:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222570#M20681</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-02-11T18:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with updating legend in Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222571#M20682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert for your response.&lt;BR /&gt;But there are something that I cannot understand. When I call the refresh method, can you explain me which parameters I must pass to this method?&lt;BR /&gt;Show me an example please according with my code, the documentation is not clear. In my legend constructor I'm passing hideLayers,title and layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 15:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222571#M20682</guid>
      <dc:creator>RolandoFlorez</dc:creator>
      <dc:date>2017-02-13T15:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with updating legend in Legend widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222572#M20683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(copy this code and apply format)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;createLegend: function () {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; var hideLayers = this.parameters.idHideLayers;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; var layer = this.parameters.layer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; var title = this.parameters.layer.title;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; if (!this.legend) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; htmlF = "&amp;lt;div id='legendDiv' &amp;gt;&amp;lt;/div&amp;gt;";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; var node = domConstruct.toDom(htmlF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; domConstruct.place(node, 'legendField');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; this.legend = new Legend({&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; map: this.map,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; layerInfos: [{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; hideLayers: hideLayers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; layer: layer,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; title: title&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; ]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; }, 'legendDiv');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; this.legend.startup();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; }else{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; this.legend.refresh([{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; hideLayers:hideLayers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; layer:layer,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; title:title&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; }]);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Once created the legend, I tried refresh instead destroy it. So that was the solution, refreshing the legend by passing the same parameters in 'layerinfos' (being hideLayers optional)&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/grin.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2017 16:10:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-updating-legend-in-legend-widget/m-p/222572#M20683</guid>
      <dc:creator>RolandoFlorez</dc:creator>
      <dc:date>2017-02-14T16:10:09Z</dc:date>
    </item>
  </channel>
</rss>

