<?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: Legend Widget -- Layers added dynamically in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684441#M63699</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know if you have already seen this sample, but it does update the legend dynamically when we update the visibility of layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/widget_legendvisible"&gt;Legend - toggle services&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Jan 2013 00:01:10 GMT</pubDate>
    <dc:creator>ShreyasVakil</dc:creator>
    <dc:date>2013-01-30T00:01:10Z</dc:date>
    <item>
      <title>Legend Widget -- Layers added dynamically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684440#M63698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are there any examples out there that illustrate the logic associated with using the Legend Dijit with layers that are added to the map after the map is instantiated?&amp;nbsp; All the examples seem to focus on displaying legends for layers that are known at runtime.&amp;nbsp; In my application the layers are not necessarily known at runtime.&amp;nbsp; Specifically, I am having some difficulty with the logic associated with &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) initializing the legend at runtime when its possible that no operational layers are loaded &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) later refreshing (or starting) the legend with (ad-hoc) operational layers that are added after the map is initially loaded&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are there any examples out there of this nature?&amp;nbsp; If not, could someone provide an outline of the logic necessary here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 23:21:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684440#M63698</guid>
      <dc:creator>GregKnight</dc:creator>
      <dc:date>2013-01-29T23:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Legend Widget -- Layers added dynamically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684441#M63699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know if you have already seen this sample, but it does update the legend dynamically when we update the visibility of layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/widget_legendvisible"&gt;Legend - toggle services&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2013 00:01:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684441#M63699</guid>
      <dc:creator>ShreyasVakil</dc:creator>
      <dc:date>2013-01-30T00:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Legend Widget -- Layers added dynamically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684442#M63700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Shreyas,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, I have seen that sample.&amp;nbsp; In that sample, the layers are known at runtime however -- and their layerInfo is pushed into an object which is passed to the legend dijit when it is instantiated.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var quakeLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer",{id:'quakes'});
legendLayers.push({layer:quakeLayer,title:'Earthquakes'});
var fireLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer",{id:'fire'});
legendLayers.push({layer:fireLayer,title:"Fire"});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Functionally, this is similar to what Im looking for, but I dont have the luxury of knowing the layerInfo at runtime.&amp;nbsp; What would I do in this case?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW -&amp;nbsp; I love the updates to the JS API pages...&amp;nbsp; fantastic!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:46:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684442#M63700</guid>
      <dc:creator>GregKnight</dc:creator>
      <dc:date>2021-12-12T04:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Legend Widget -- Layers added dynamically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684443#M63701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The legend widget has a refresh property that you can use to update it with new layer information. Here's an example that shows how to refresh the legend with&amp;nbsp; new layer info. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://jsfiddle.net/vguu3/" rel="nofollow" target="_blank"&gt;http://jsfiddle.net/vguu3/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2013 21:46:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684443#M63701</guid>
      <dc:creator>KellyHutchins</dc:creator>
      <dc:date>2013-01-30T21:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Legend Widget -- Layers added dynamically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684444#M63702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Kelly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That definitely helps.&amp;nbsp; Ill revisit my code later today. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2013 12:31:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-widget-layers-added-dynamically/m-p/684444#M63702</guid>
      <dc:creator>GregKnight</dc:creator>
      <dc:date>2013-01-31T12:31:36Z</dc:date>
    </item>
  </channel>
</rss>

