<?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 title based on variable needs to refresh too in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530027#M49442</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's not just changing the title, it's getting rid of the entire legend and recreating it every time. I'd like to avoid this.&amp;nbsp; What I did was add another div right above the legend, calling it legendTitle.&amp;nbsp; Then I styled the legend so that its default title wouldn't display at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14090812548913278 jive_text_macro" jivemacro_uid="_14090812548913278" modifiedtitle="true"&gt;
&lt;P&gt;.esriLegendServiceLabel {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; display:none;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I set the content of my new legendTitle to be the field name like I wanted. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Aug 2014 19:28:27 GMT</pubDate>
    <dc:creator>TracySchloss</dc:creator>
    <dc:date>2014-08-26T19:28:27Z</dc:date>
    <item>
      <title>Legend title based on variable needs to refresh too</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530025#M49440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a project that let's the user change which attribute field is used in the display.&amp;nbsp; It's based on the sample &lt;A href="https://developers.arcgis.com/javascript/jssamples/renderer_dynamic_layer_change_attribute.html"&gt;https://developers.arcgis.com/javascript/jssamples/renderer_dynamic_layer_change_attribute.html&lt;/A&gt;&amp;nbsp; For the legend, I'm creating it if it doesn't exist, but if it does, then I just want it to refresh.&amp;nbsp; My problem is that the title is based on a variable, defined based on the change event of the FilteringSelect list of fields.&amp;nbsp; When I change the field, the legend itself updates, but it still has the title from its initial creation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I change just the title?&amp;nbsp; It doesn't seem to be honoring my title definition when I specify legend.refresh().&amp;nbsp; In this example, fields is the array of attributes from my layer and fieldChoice is the selected item from the FilteringSelect.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14090688226248890 jive_text_macro" jivemacro_uid="_14090688226248890" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp; domConstruct.empty("legendDiv");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!legend){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend = new Legend({&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map: map,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerInfos: [{ "layer": featureLayer, "title": fields[fieldChoice] }]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },"legendDiv");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.startup();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.refresh();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 16:05:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530025#M49440</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-08-26T16:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Legend title based on variable needs to refresh too</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530026#M49441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ran in the same problem while creating a web map for my Capstone project but using the Generate Render Sample (&lt;A href="https://developers.arcgis.com/javascript/jssamples/renderer_generate_renderer.html" title="https://developers.arcgis.com/javascript/jssamples/renderer_generate_renderer.html"&gt;Generate renderer | ArcGIS API for JavaScript&lt;/A&gt; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got to solve the problem by adding the "app." back into it and setting the "var app []" as a global variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14090720427889206 jive_text_macro" jivemacro_uid="_14090720427889206" modifiedtitle="true"&gt;
&lt;P&gt;function createLegend(map, fl) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // destroy previous legend, if present&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if ( app.hasOwnProperty("legend") ) {&lt;/P&gt;
&lt;P&gt;app.legend.destroy();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; domConstruct.destroy(dojo.byId("legendDiv"));&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // create a new div for the legend&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var legendDiv = domConstruct.create("div", {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; id: "legendDiv"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }, dom.byId("legendWrapper"));&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; app.legend = new Legend({&lt;/P&gt;
&lt;P&gt;&amp;nbsp; map : map,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; layerInfos : [{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; layer : fl,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; title : "Census Attribute: " + fields[currentAttribute]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }, legendDiv);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; app.legend.startup();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 16:54:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530026#M49441</guid>
      <dc:creator>MirceaMaierean</dc:creator>
      <dc:date>2014-08-26T16:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Legend title based on variable needs to refresh too</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530027#M49442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's not just changing the title, it's getting rid of the entire legend and recreating it every time. I'd like to avoid this.&amp;nbsp; What I did was add another div right above the legend, calling it legendTitle.&amp;nbsp; Then I styled the legend so that its default title wouldn't display at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14090812548913278 jive_text_macro" jivemacro_uid="_14090812548913278" modifiedtitle="true"&gt;
&lt;P&gt;.esriLegendServiceLabel {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; display:none;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I set the content of my new legendTitle to be the field name like I wanted. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 19:28:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530027#M49442</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-08-26T19:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Legend title based on variable needs to refresh too</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530028#M49443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand the question correctly then calling legend.refresh and providing the updated layer info with the new title should update the title in the legend. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.refresh([{&lt;/P&gt;&lt;P&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; layer: featureLayer,&lt;/P&gt;&lt;P&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; title: "Updated layer name" &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }]);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 00:20:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530028#M49443</guid>
      <dc:creator>KellyHutchins</dc:creator>
      <dc:date>2014-08-27T00:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Legend title based on variable needs to refresh too</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530029#M49444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your way worked and is more right then my workaround method, so I changed which one is marked as Correct Answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 13:12:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/legend-title-based-on-variable-needs-to-refresh/m-p/530029#M49444</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-08-27T13:12:41Z</dc:date>
    </item>
  </channel>
</rss>

