I have two comboboxes. The first filters the contents on the second. I want a specific layer of the 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!!
var stewardship = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/FeatureServer/0" , {
mode: FeatureLayer.MODE_SELECTION,
outFields: ['*']
});
map.addLayers([stewardship]);
dojo.connect(dijit.byId("Activity"), 'onChange', function(value){
//alert('ok ' + event);
activity = dijit.byId('Activity');
var layerId = activity.item["layerId"]
console.log(layerId)
activityGroupValue = dijit.byId('ActivityGroup').get('value')
if (activityGroupValue == " " && value in oc(forestrylist))
{
dijit.byId('ActivityGroup').set('value', "Forestry")
}
else if (activityGroupValue == " " && value in oc(medialist))
{
dijit.byId('ActivityGroup').set('value', "Media")
}
else if (activityGroupValue == " " && value in oc(conservationeducationlist))
{
dijit.byId('ActivityGroup').set('value', "Conservation Education")
}
else if (activityGroupValue == " " && value in oc(firelist))
{
dijit.byId('ActivityGroup').set('value', "Fire")
}
else if (activityGroupValue == " " && value in oc(urbanforestrylist))
{
dijit.byId('ActivityGroup').set('value', "Urban Forestry")
}
else if (activityGroupValue == " " && value in oc(professionaldevelopmentlist))
{
dijit.byId('ActivityGroup').set('value', "Professional Development")
}
else if (activityGroupValue == " " && value in oc(oakwiltlist))
{
dijit.byId('ActivityGroup').set('value', "Oak Wilt")
}
stewardship = new FeatureLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/FeatureServer/" + layerId, {
mode: FeatureLayer.MODE_SELECTION,
id: 'stewardship_' + layerId,
outFields: ['*']
});
map.addLayers([stewardship]);
console.log(stewardship)