<?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: Update the layer of the feature layer according to the combobox value in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107465#M9970</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried that Stephen and it does not work, the feature layer created as a global variable does not get removed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Nov 2013 12:39:52 GMT</pubDate>
    <dc:creator>ionarawilson1</dc:creator>
    <dc:date>2013-11-22T12:39:52Z</dc:date>
    <item>
      <title>Update the layer of the feature layer according to the combobox value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107463#M9968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have two comboboxes. The first filters the contents on the second. I want a specific layer of the&amp;nbsp; feature layer to be activated depending on the selection of the second combobox. I created a global variable for the feature layer (stewardship), and also used that variable inside the change function of the combobox. I can see in the console that the layer id changes inside the function, but the layer in the map does not change, because it is still looking at the global variable value. Any ideas on what to do ? Thank you!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp; 
 var stewardship = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/FeatureServer/0" , {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mode: FeatureLayer.MODE_SELECTION, 
&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; outFields: ['*']
});
&amp;nbsp; 
 map.addLayers([stewardship]);

&amp;nbsp;&amp;nbsp; dojo.connect(dijit.byId("Activity"), 'onChange', function(value){ 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //alert('ok ' + event);
&amp;nbsp;&amp;nbsp;&amp;nbsp; activity = dijit.byId('Activity');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var layerId = activity.item["layerId"]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(layerId)
&amp;nbsp;&amp;nbsp; activityGroupValue = dijit.byId('ActivityGroup').get('value')
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(forestrylist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Forestry")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; else if (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(medialist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Media")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; else if (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(conservationeducationlist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Conservation Education")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; else if&amp;nbsp; (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(firelist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Fire")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; else if (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(urbanforestrylist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Urban Forestry")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }


&amp;nbsp;&amp;nbsp; else if&amp;nbsp; (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(professionaldevelopmentlist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Professional Development")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; else if (activityGroupValue == " " &amp;amp;&amp;amp; value in oc(oakwiltlist))
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dijit.byId('ActivityGroup').set('value', "Oak Wilt")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
stewardship = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/FeatureServer/" + layerId, {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mode: FeatureLayer.MODE_SELECTION, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id: 'stewardship_' + layerId,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields: ['*']
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
});
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp; map.addLayers([stewardship]);
&amp;nbsp;&amp;nbsp; console.log(stewardship)

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 19:34:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107463#M9968</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-11-21T19:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Update the layer of the feature layer according to the combobox value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107464#M9969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;During your onChange event, you update the variable for the layer, but don't actually do anything with it. Within this function, you need to remove the existing layer from the map, recreate it, then re-add it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
var stewardship = new FeatureLayer("..../FeatureServer/0" , {...});
map.addLayers([stewardship]);

dojo.connect(dijit.byId("Activity"), 'onChange', function(value){
&amp;nbsp; //remove the existing stewardship layer
&amp;nbsp; map.removeLayer(stewardship);

&amp;nbsp; //re-create it using the new ID
&amp;nbsp; stewardship = new FeatureLayer("..../FeatureServer/" + layerId, {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id: 'stewardship_' + layerId....
&amp;nbsp; });

&amp;nbsp; //add it to the map again
&amp;nbsp; map.addLayers([stewardship]);
});

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:30:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107464#M9969</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-11T06:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Update the layer of the feature layer according to the combobox value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107465#M9970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried that Stephen and it does not work, the feature layer created as a global variable does not get removed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 12:39:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107465#M9970</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-11-22T12:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Update the layer of the feature layer according to the combobox value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107466#M9971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ionara, I have replied to you in another post: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/97254-Feature-Layer-layer-as-a-variable"&gt;http://forums.arcgis.com/threads/97254-Feature-Layer-layer-as-a-variable&lt;/A&gt;&lt;SPAN&gt;. Please remember that once a feature layer is added to the map, it will stay there until you specifically remove it or hide it. In the above reply, I haven't specified how you will remove or hide the loaded layers. That should be an easy task to accomplish though. Otherwise, let me know.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 16:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/update-the-layer-of-the-feature-layer-according-to/m-p/107466#M9971</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-11-22T16:41:46Z</dc:date>
    </item>
  </channel>
</rss>

