How to turn on/off features using checkbox

584
0
08-08-2011 07:37 AM
ShravanBonagiri
New Contributor
Hi All. I need some favor. Here is what I am doing. I have a large SDE table containing 10,000 data points. These points fall into five categories such as Red, Blue, Green, Gray, Yellow. The app functionality should do turn on/off these features (Red, Blue,...) using corresponding check boxes. I am using Feature Layer for the graphics part. I guess this may be a simple functionality. Here is the code that I wrote thus far. Please share your expertise. Thanks in advance.

Code:
private function checkBoxClick(event:MouseEvent):void
   {
   
    if(cBox1.selected==true)
    {    
     fLayer.definitionExpression = "['GIS.STATION.STATUS'] ='Green'";     
     fLayer.visible = false;    
     //Alert.show("Check Box 1 Selected");    
    }
    else
    {
    }
    if(cBox2.selected==true)
    {
     Alert.show("Check Box 2 Selected");
    }
    if(cBox3.selected==true)
    {
     Alert.show("Check Box 3 Selected");
    }
   }

<esri:FeatureLayer id="fLayer"
   mode="snapshot"
   outFields="[GIS.STATION.STATUS]"
   url="http://111.../ArcGIS/rest/services/Station/MapServer/0" >
     
   <esri:renderer>
    <esri:UniqueValueRenderer id="uniqueValueRenderer" attribute="GIS.STATION.STATUS">
    <esri:UniqueValueInfo id="green" value="Green" symbol="{greenDot}"/>
    <esri:UniqueValueInfo  id="gray" value="Gray" symbol="{grayDot}"/>
    <esri:UniqueValueInfo id="yellow" value="Yellow" symbol="{yellowDot}"/>
    <esri:UniqueValueInfo id="red" value="Red" symbol="{redDot}"/>
    </esri:UniqueValueRenderer>
   </esri:renderer>
</esri:FeatureLayer>

<s:CheckBox id="cBox" y="0" label="Select All" selected="true" />
      <s:CheckBox id="cBox1" y="20" label="Red" click="checkBoxClick(event)" />
      <s:CheckBox id="cBox2" y="40" label="Blue" click="checkBoxClick(event)"/>
      <s:CheckBox id="cBox3" y="60" label="Green" click="checkBoxClick(event)"/>
      <s:CheckBox id="cBox4" y="80" label="Yellow" click="checkBoxClick(event)"/>
      <s:CheckBox id="cBox5" y="100" label="Gray" click="checkBoxClick(event)"/>

Happy coding,
Sam
Tags (2)
0 Kudos
0 Replies