Select to view content in your preferred language

Radio Butttons not displaying the map or legend

669
1
Jump to solution
05-22-2012 08:26 AM
ionarawilson1
Deactivated User
I am working on a web map application that has two combo boxes, one for year (called yearcombo) and for measures (called myURL) for that selected year, and also two radiobuttons (in radioBtnGroup). So the user clicks on the first combo box to choose the year (2007 or 2009), then on the second combo box to choose the measure and then he can click on the radiobuttons to see either the direct impact for that measure or the total impact (please see image)


Before I had services for each year and everything was working great but I decided to combine the services and have the two years together.  So now the service has four layers, one layer for each radiobutton for 2007 and one layer for each radio button in 2009. I changed the code and everything works fine, besides when I click on the radio button for total impact for 2009, the image and legend doesnt change. The problem does not happen when I select 2007, just 2009. I am not sure if this has to do with a filter in the combo box.

Here is the code snippet for the combo boxes:



     
      <mx:FormItem label="Year        :"  >
       <mx:ComboBox   id="yearcombo" selectedIndex="1" labelField="label" width="100%" change="changeEvt(event)"  >
        <mx:ArrayCollection id="year"  >
        
        
         <fx:Object label="2007"  year="2007" />
         <fx:Object label="2009"  year="2009" />
        
        
        </mx:ArrayCollection>
       
       
       </mx:ComboBox>
      
      </mx:FormItem>
     
      <mx:FormItem label="Measure:">
       <mx:ComboBox   id="myURL" selectedIndex="4" width="80%"    >
        <mx:ArrayCollection id="measures"  filterFunction="filteryears"  >
        
        
        
         <fx:Object id="totalsemp07" label="Employment Totals"  value="TFEI_07__09_employment_TOTALS_TEST3" year="2007"  />
         <fx:Object id="totalsemp09" label="Employment Totals " value="TFEI_07__09_employment_TOTALS_TEST3" year="2009" />
         <fx:Object id="totalslabinc07" label="Labor Income Totals"  value="TFEI_07_09_labincome_TOTALS_TEST4" year="2007"  />
         <fx:Object id="totalslabinc09" label="Labor Income Totals " value="TFEI_07_09_labincome_TOTALS_TEST4" year="2009" />
         <fx:Object label="" value="http://tfs-24279/ArcGIS/rest/services/EconomicImpact/TFEI_transparent/MapServer" year="2009"/>
        
         <fx:Object id="blank" label=" "  />
        
        
        </mx:ArrayCollection>
       
       
       </mx:ComboBox>
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ionarawilson1
Deactivated User
I figured out what the problem was and will soon be posting the project in the code gallery!!!

By the way, that problem happened because I needed to change the change event function and the load layer function to have:

if (yearcombo.selectedIndex == 1)
    {
    
     for(var i:uint = 0; i < (2); i++)
     {
      var radioBtn:RadioButton = new RadioButton;
      radioBtn.groupName = "radioBtnGroup";
      radioBtn.value = i;
     
     
      if (dynamicLayer.layerInfos.name == "Direct Impact (Million $)")
      {
       radioBtn.label = "Direct Impact";
      
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Million $)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Jobs)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Direct Impact (Jobs)")
      {radioBtn.label = "Direct Impact";
      }
      else
      {radioBtn.visible= false;
      }
     
      layerPanel.addChild(radioBtn);
     
     
     
      radioBtnGroup.selectedValue = 0;
      dynamicLayer.visibleLayers = new ArrayCollection([2]);
      myLegend.layers = [dynamicLayer];
      myLegend.visible = true;
     }
    }


INSTEAD OF :



    if (yearcombo.selectedIndex == 1)
    {
    
     for(var i:uint = 2; i < (dynamicLayer.layerInfos.length); i++)
     {
      var radioBtn:RadioButton = new RadioButton;
      radioBtn.groupName = "radioBtnGroup";
      radioBtn.value = i;
     
     
      if (dynamicLayer.layerInfos.name == "Direct Impact (Million $)")
      {
       radioBtn.label = "Direct Impact";
      
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Million $)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Jobs)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Direct Impact (Jobs)")
      {radioBtn.label = "Direct Impact";
      }
      else
      {radioBtn.visible= false;
      }
     
      layerPanel.addChild(radioBtn);
radioBtnGroup.selectedValue = 2;
      dynamicLayer.visibleLayers = new ArrayCollection([2]);
      myLegend.layers = [dynamicLayer];
      myLegend.visible = true;
     }
    }

View solution in original post

0 Kudos
1 Reply
ionarawilson1
Deactivated User
I figured out what the problem was and will soon be posting the project in the code gallery!!!

By the way, that problem happened because I needed to change the change event function and the load layer function to have:

if (yearcombo.selectedIndex == 1)
    {
    
     for(var i:uint = 0; i < (2); i++)
     {
      var radioBtn:RadioButton = new RadioButton;
      radioBtn.groupName = "radioBtnGroup";
      radioBtn.value = i;
     
     
      if (dynamicLayer.layerInfos.name == "Direct Impact (Million $)")
      {
       radioBtn.label = "Direct Impact";
      
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Million $)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Jobs)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Direct Impact (Jobs)")
      {radioBtn.label = "Direct Impact";
      }
      else
      {radioBtn.visible= false;
      }
     
      layerPanel.addChild(radioBtn);
     
     
     
      radioBtnGroup.selectedValue = 0;
      dynamicLayer.visibleLayers = new ArrayCollection([2]);
      myLegend.layers = [dynamicLayer];
      myLegend.visible = true;
     }
    }


INSTEAD OF :



    if (yearcombo.selectedIndex == 1)
    {
    
     for(var i:uint = 2; i < (dynamicLayer.layerInfos.length); i++)
     {
      var radioBtn:RadioButton = new RadioButton;
      radioBtn.groupName = "radioBtnGroup";
      radioBtn.value = i;
     
     
      if (dynamicLayer.layerInfos.name == "Direct Impact (Million $)")
      {
       radioBtn.label = "Direct Impact";
      
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Million $)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Total Impact (Jobs)")
      {radioBtn.label = "Total Impact";
      }
      else if (dynamicLayer.layerInfos.name == "Direct Impact (Jobs)")
      {radioBtn.label = "Direct Impact";
      }
      else
      {radioBtn.visible= false;
      }
     
      layerPanel.addChild(radioBtn);
radioBtnGroup.selectedValue = 2;
      dynamicLayer.visibleLayers = new ArrayCollection([2]);
      myLegend.layers = [dynamicLayer];
      myLegend.visible = true;
     }
    }
0 Kudos