<?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: Radio Button on/off Layers in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526278#M11915</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Golden,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Just set the verticalGap of the parent (i.e. the Panel).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 29 May 2010 20:25:24 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2010-05-29T20:25:24Z</dc:date>
    <item>
      <title>Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526271#M11908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After an entire day of attempting this, I'm hoping to find some answers here on the forum. It appears I've bitten off more than I can chew. What I'm trying to do is create a set of radio buttons that turn on different layers from a dynamic service. When a radio button is clicked it makes a layer visible and the previously visible layer is turned off.&amp;nbsp; (i.e. Only one layer is visible at a time) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been trying to modify the sample: Dynamic Map Layers on/off, but this has turned into a giant mess. Its just not designed for radio buttons. I had wanted some intelligence (using an array) built into my code, but I'm totally fine for just hard coding it in. Here's a chunk my relevant mxml&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;esri:Map&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:extent&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:Extent xmin="-91.17" ymin="40.944" xmax="-90.37" ymax="41.4"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&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;&amp;nbsp;&amp;nbsp; &amp;lt;esri:SpatialReference wkid="4326"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Extent&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:extent&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:ArcGISDynamicMapServiceLayer id="depthDyn"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://blackberry.sws.uiuc.edu/ArcGIS/rest/services/FlexDev/Depth/MapServer" rel="nofollow" target="_blank"&gt;http://blackberry.sws.uiuc.edu/ArcGIS/rest/services/FlexDev/Depth/MapServer&lt;/A&gt;&lt;SPAN&gt;" /&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Map&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;mx:Panel width="300" height="250" x="20" y="250" paddingLeft="20"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;mx:RadioButtonGroup id="cb" itemClick="radioClick(event);"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:RadioButton groupName="cb" id="depth500" value="m500" label="Mercer500" width="150"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:RadioButton groupName="cb" id="depth200" value="m200" label="Mercer200" width="150"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:RadioButton groupName="cb" id="depth100" value="m100" label="Mercer100" width="150"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:RadioButton groupName="cb" id="depth50" value="m50" label="Mercer50" width="150"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:RadioButton groupName="cb" id="depth10" value="m10" label="Mercer10" width="150"/&amp;gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;/mx:Panel&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Apr 2010 19:45:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526271#M11908</guid>
      <dc:creator>MattWilliams</dc:creator>
      <dc:date>2010-04-07T19:45:51Z</dc:date>
    </item>
    <item>
      <title>Try this</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526272#M11909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, Try this one out. It will add all layers automatically and make the first layer visible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
 xmlns:esri="http://www.esri.com/2008/ags"
 &amp;gt;
 &amp;lt;mx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import mx.events.ItemClickEvent;
&amp;nbsp;&amp;nbsp; import mx.collections.ArrayCollection;
&amp;nbsp;&amp;nbsp; import mx.controls.RadioButton;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function loadLayerName():void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.removeAllChildren();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //loop through each layer and add as a radiobutton
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i:uint = 0; i &amp;lt; (dynamicLayer.layerInfos.length); i++) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var radioBtn:RadioButton = new RadioButton;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.groupName = "radioBtnGroup";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.value = i;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.label = dynamicLayer.layerInfos&lt;I&gt;.name;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.addChild(radioBtn);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //set the visible layer the first radio button
&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtnGroup.selectedValue = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicLayer.visibleLayers = new ArrayCollection([0]);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function radioClickHandler(event:ItemClickEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // update the visible layers to only show the layer selected
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
&amp;nbsp;&amp;nbsp; }

&amp;nbsp; ]]&amp;gt;
 &amp;lt;/mx:Script&amp;gt;
 
 
 &amp;lt;esri:Map id="myMap"&amp;gt;
&amp;nbsp; &amp;lt;esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:Extent xmin="-126" ymin="27" xmax="-72" ymax="50"&amp;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;&amp;nbsp;&amp;nbsp; &amp;lt;esri:SpatialReference wkid="4326"/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Extent&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
&amp;nbsp;&amp;nbsp; load="loadLayerName()"
&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/{myURL.selectedItem}/MapServer" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Map&amp;gt;
 
 &amp;lt;mx:ComboBox id="myURL" selectedIndex="0" horizontalCenter="0"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:Array&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:String&amp;gt;Specialty/ESRI_StateCityHighway_USA&amp;lt;/mx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:String&amp;gt;Specialty/ESRI_StatesCitiesRivers_USA&amp;lt;/mx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:String&amp;gt;Demographics/ESRI_Census_USA&amp;lt;/mx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/mx:Array&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/mx:ComboBox&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 &amp;lt;mx:Panel id="layerPanel" width="300" height="250" x="20" y="250" paddingLeft="20"&amp;gt;
&amp;nbsp; &amp;lt;mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/&amp;gt;
 &amp;lt;/mx:Panel&amp;gt;
 
&amp;lt;/mx:Application&amp;gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526272#M11909</guid>
      <dc:creator>MarkHoyland</dc:creator>
      <dc:date>2021-12-11T22:55:24Z</dc:date>
    </item>
    <item>
      <title>Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526273#M11910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm at home right now, so I can't try out your code. However, its appears to on and off different services, not layers. I'm need to run this as one service with 5 layers. Sorry if I wasn't clear in my previous post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: I also want to express my thanks and appreciation to you for taking the time to help out a fellow.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 00:56:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526273#M11910</guid>
      <dc:creator>MattWilliams</dc:creator>
      <dc:date>2010-04-08T00:56:22Z</dc:date>
    </item>
    <item>
      <title>Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526274#M11911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have added a combobox with the extra dynamic services so you can see a generic implementation of what you requested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When you chose a DynamicMapService from the combobox, only its layers are automatically added as radiobuttons to the panel. If you select a different combobox item, the panel will be updated to only show that DynamicService's layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can remove the combo box and just have your "depthDyn" dynamic service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The radio buttons get created from the DynamicMapService's "load" event. eg load="loadLayerName()"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will have to test in flex to see it in action.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 01:13:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526274#M11911</guid>
      <dc:creator>MarkHoyland</dc:creator>
      <dc:date>2010-04-08T01:13:02Z</dc:date>
    </item>
    <item>
      <title>Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526275#M11912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah! I think I see what you mean...through my vague and mottled understanding of actionscript. Thanks again. I can't wait to try it out tomorrow.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 01:56:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526275#M11912</guid>
      <dc:creator>MattWilliams</dc:creator>
      <dc:date>2010-04-08T01:56:54Z</dc:date>
    </item>
    <item>
      <title>Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526276#M11913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Works perfectly! Thank you so much. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not finding a place to mark this as answered, so I'll just write: ANSWERED&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: (In case anyone else uses this and for my own curiousity) Why is the line &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;layerPanel.removeAllChildren();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;necessary in the code? I found that it was preventing me from adding anything to the panel (e.g. A transparency slider). I hope there aren't any repercussions from removing it. I don't seem to be experiencing any problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit (2):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layerPanel.removeAllChildren(); is necessary if you are working with multiple dynamic services. It basically wipes the panel slate clean and then repopulates the radio buttons with the layers in the new dynamic service.&amp;nbsp; It just hit me as I was sitting here, so I thought I would answer my own question.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Apr 2010 13:42:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526276#M11913</guid>
      <dc:creator>MattWilliams</dc:creator>
      <dc:date>2010-04-08T13:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Try this</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526277#M11914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi, Try this one out. It will add all layers automatically and make the first layer visible.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
 xmlns:esri="http://www.esri.com/2008/ags"
 &amp;gt;
 &amp;lt;mx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import mx.events.ItemClickEvent;
&amp;nbsp;&amp;nbsp; import mx.collections.ArrayCollection;
&amp;nbsp;&amp;nbsp; import mx.controls.RadioButton;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function loadLayerName():void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.removeAllChildren();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //loop through each layer and add as a radiobutton
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i:uint = 0; i &amp;lt; (dynamicLayer.layerInfos.length); i++) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var radioBtn:RadioButton = new RadioButton;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.groupName = "radioBtnGroup";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.value = i;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.label = dynamicLayer.layerInfos&lt;I&gt;.name;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.addChild(radioBtn);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //set the visible layer the first radio button
&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtnGroup.selectedValue = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicLayer.visibleLayers = new ArrayCollection([0]);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function radioClickHandler(event:ItemClickEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // update the visible layers to only show the layer selected
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
&amp;nbsp;&amp;nbsp; }

&amp;nbsp; ]]&amp;gt;
 &amp;lt;/mx:Script&amp;gt;
 
 
 &amp;lt;esri:Map id="myMap"&amp;gt;
&amp;nbsp; &amp;lt;esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:Extent xmin="-126" ymin="27" xmax="-72" ymax="50"&amp;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;&amp;nbsp;&amp;nbsp; &amp;lt;esri:SpatialReference wkid="4326"/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Extent&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
&amp;nbsp;&amp;nbsp; load="loadLayerName()"
&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/{myURL.selectedItem}/MapServer" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Map&amp;gt;
 
 &amp;lt;mx:ComboBox id="myURL" selectedIndex="0" horizontalCenter="0"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:Array&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:String&amp;gt;Specialty/ESRI_StateCityHighway_USA&amp;lt;/mx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:String&amp;gt;Specialty/ESRI_StatesCitiesRivers_USA&amp;lt;/mx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:String&amp;gt;Demographics/ESRI_Census_USA&amp;lt;/mx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/mx:Array&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/mx:ComboBox&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 &amp;lt;mx:Panel id="layerPanel" width="300" height="250" x="20" y="250" paddingLeft="20"&amp;gt;
&amp;nbsp; &amp;lt;mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/&amp;gt;
 &amp;lt;/mx:Panel&amp;gt;
 
&amp;lt;/mx:Application&amp;gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have used this code for my project, and it works perfectly except that my radiobuttons&amp;nbsp; representing layers from my map service are grouped on top of each other. Is there anyway i can set the vertical gap to avoid them overlaying on top of one another?.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526277#M11914</guid>
      <dc:creator>MGSethe</dc:creator>
      <dc:date>2021-12-11T22:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526278#M11915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Golden,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Just set the verticalGap of the parent (i.e. the Panel).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 May 2010 20:25:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526278#M11915</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2010-05-29T20:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526279#M11916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just found this thread and have used this nice code and it works OK as standalone appl. But I need similar solution for Widget (Radio Buttons instead of CheckBox in TOC&amp;nbsp; in f.e. Layer List widget or MapSwitcher Widget) to use with ArcGis Viewer for Flex 2.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I trayed to use this code with some changes in my widget but still have problems. My widget comunicate with ArcGis services on my server and i can select diferent services and get listed layers in RadioButton group for selected service but I can't get displayed selected layers on the map. Look as my widget doesn't comunicate with others widgets.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Has sombody used this code in widget or anyone who could help me?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 12:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526279#M11916</guid>
      <dc:creator>RadmilPopovic</dc:creator>
      <dc:date>2010-10-14T12:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526280#M11917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a compiled version of the radio button layer control widget available?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2011 20:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526280#M11917</guid>
      <dc:creator>DennisAkins</dc:creator>
      <dc:date>2011-06-13T20:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526281#M11918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am looking to implement radio buttons to turn on only one layer at a time through a TOC or LayerSelect widget in Flex Viewer.&amp;nbsp; Specifically, I want to enable only one polygon feature to be displayed at a time, but I would like to allow multiple point and line features to be displayed simultaneously.&amp;nbsp; Does anybody have a code solution or tips for this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ben K&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2011 22:17:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526281#M11918</guid>
      <dc:creator>BenKane</dc:creator>
      <dc:date>2011-07-01T22:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526282#M11919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does anybody knows how to change to this great code to use checkbox instead. I was able to show check box instead of option buttons (see below), however, when I hit the checkboxes to turn on and off layer nothing happens. Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private function loadLayerName():void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.removeAllChildren();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //loop through each layer and add as a radiobutton
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i:uint = 0; i &amp;lt; (dynamicLayer.layerInfos.length); i++) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var chks:CheckBox = new CheckBox;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chks.name="{checks}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chks.label= dynamicLayer.layerInfos&lt;I&gt;.name;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.addChild(chks); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526282#M11919</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2021-12-11T22:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526283#M11920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will need to add an event listener when the ckeckbox is created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the handler you would then have to add or remove the layer from the visiblelayers arraycollection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//add event listener
 var chks:CheckBox = new CheckBox;
 chks.addEventListener(Event.CHANGE, chk_changeHandler);


protected function chk_changeHandler(event:Event):void
{
 var checkBox:CheckBox = event.currentTarget as CheckBox;
 if (checkBox.selected = true)
 {
&amp;nbsp; trace("check is selected");
&amp;nbsp; //add to visiblelayers
 }
 else
 {
&amp;nbsp; // remove from visiblelayers
 }
}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526283#M11920</guid>
      <dc:creator>MarkHoyland</dc:creator>
      <dc:date>2021-12-11T22:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526284#M11921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply, I have flex 4.6 at work trying to redo the initial code using flex 4.6, looks like the way you handle RadioButtonGroup is totally changed from flex 3 to flex 4. Need to convert this code to flex 4 first and then test your logic. I am bit stuck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, Flex 4 didn't like &lt;/SPAN&gt;&lt;STRONG&gt;layerPanel.addChild(radioBtn)&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Change to:&lt;/SPAN&gt;&lt;STRONG&gt; layerPanel.addElement(radioBtn)&lt;/STRONG&gt;&lt;SPAN&gt;; only on button is loaded and all the text are overlapped. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help in that direction will be definitely appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]17098[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2012 15:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526284#M11921</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2012-08-20T15:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526285#M11922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Koman,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You now need to set the panel's layout inside the panel. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(In the VerticalLayout tag you can set any padding ang gap etc.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;lt;s:Panel&amp;gt;
 &amp;lt;s:layout&amp;gt;
&amp;nbsp; &amp;lt;s:VerticalLayout paddingTop="10" gap="2"/&amp;gt;
 &amp;lt;/s:layout&amp;gt;
 
&amp;lt;/s:Panel&amp;gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526285#M11922</guid>
      <dc:creator>MarkHoyland</dc:creator>
      <dc:date>2021-12-11T22:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526286#M11923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The panel worked wonderfully, the radio button are loaded correctly but when clicked the layers don't turn on/off. I am still migrating from 3 to 4, I am a bit still struggling with this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;&lt;STRONG&gt;Here is the question&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;: With Flex 3 the radioButton is loaded directly in the panel and with Flex 4 the &amp;lt;s:RadioButtonGroup&amp;gt; it set in &amp;lt;fx:Declaration&amp;gt; and the&amp;lt; Radiobutton&amp;gt; item are loaded in the panel. I think because of this when I clicked the radioBtnGroup_itemClickHandler is not being fired. Do I need additional steps to make this work. I am little bit perplexed by this. Thank you so much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;fx:Declarations&amp;gt;
&amp;nbsp; &amp;lt;s:RadioButtonGroup id="radioBtnGroup" itemClick="radioBtnGroup_itemClickHandler(event)" /&amp;gt;&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp; &amp;lt;!-- Place non-visual elements (e.g., services, value objects) here --&amp;gt;
 &amp;lt;/fx:Declarations&amp;gt;
 &amp;lt;esri:Map id="myMap"&amp;gt;
&amp;nbsp; &amp;lt;esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;esri:Extent xmin="-126" ymin="27" xmax="-72" ymax="50"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:SpatialReference wkid="4326"/&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Extent&amp;gt;
&amp;nbsp; &amp;lt;/esri:extent&amp;gt;
&amp;nbsp; &amp;lt;esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; load="loadLayerName()"
&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/{myURL.selectedItem}/MapServer" /&amp;gt;
 &amp;lt;/esri:Map&amp;gt;
 &amp;lt;mx:ComboBox id="myURL" selectedIndex="0" horizontalCenter="0"&amp;gt;
&amp;nbsp; &amp;lt;fx:Array&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;fx:String&amp;gt;Specialty/ESRI_StateCityHighway_USA&amp;lt;/fx:String&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;fx:String&amp;gt;Specialty/ESRI_StatesCitiesRivers_USA&amp;lt;/fx:String&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;fx:String&amp;gt;Demographics/ESRI_Census_USA&amp;lt;/fx:String&amp;gt;
&amp;nbsp; &amp;lt;/fx:Array&amp;gt;
 &amp;lt;/mx:ComboBox&amp;gt;
 &amp;lt;s:Panel id="layerPanel" y="250" width="300" height="250" horizontalCenter="0" &amp;gt;
&amp;nbsp; &amp;lt;s:layout&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;s:VerticalLayout paddingTop="10" gap="2"/&amp;gt;
&amp;nbsp; &amp;lt;/s:layout&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; &amp;lt;s:RadioButton label="Button 1" groupName="radioBtnGroup"/&amp;gt;
&amp;nbsp; &amp;lt;s:RadioButton label="Button 2" groupName="radioBtnGroup"/&amp;gt;
 &amp;lt;/s:Panel&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526286#M11923</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2021-12-11T22:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526287#M11924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Koman,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you look at the adobe help for 4.6 radiobutton, the sample shows it uses the 'group'&amp;nbsp; property instead of the 'groupName'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7d8b.html#WS2db454920e96a9e51e63e3d11c0bf69084-7d8a" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7d8b.html#WS2db454920e96a9e51e63e3d11c0bf69084-7d8a&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours should be &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;s:RadioButton label="Button 1" group="{radioBtnGroup}"/&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyhow here is the original code ported to spark&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:s="library://ns.adobe.com/flex/spark" 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags"&amp;gt;
 
 &amp;lt;s:layout&amp;gt;
&amp;nbsp; &amp;lt;s:VerticalLayout/&amp;gt;
 &amp;lt;/s:layout&amp;gt;
 &amp;lt;fx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import com.esri.ags.events.LayerEvent;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; import mx.collections.ArrayCollection;
&amp;nbsp;&amp;nbsp; import mx.events.ItemClickEvent;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; import spark.components.RadioButton;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; protected function loadLayerName(event:LayerEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.removeAllElements()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //loop through each layer and add as a radiobutton
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i:uint = 0; i &amp;lt; (dynamicLayer.layerInfos.length); i++) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var radioBtn:RadioButton = new RadioButton;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.group = radioBtnGroup;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.value = i;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtn.label = dynamicLayer.layerInfos&lt;I&gt;.name;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPanel.addElement(radioBtn);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //set the visible layer the first radio button
&amp;nbsp;&amp;nbsp;&amp;nbsp; radioBtnGroup.selectedValue = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicLayer.visibleLayers = new ArrayCollection([0]);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; protected function radioClickHandler(event:ItemClickEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // update the visible layers to only show the layer selected
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ]]&amp;gt;
 &amp;lt;/fx:Script&amp;gt;
&amp;nbsp; 

 &amp;lt;fx:Declarations&amp;gt;
&amp;nbsp; &amp;lt;!-- Place non-visual elements (e.g., services, value objects) here --&amp;gt;
&amp;nbsp; &amp;lt;s:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/&amp;gt;

 &amp;lt;/fx:Declarations&amp;gt;
 
 &amp;lt;esri:Map id="myMap"&amp;gt;
&amp;nbsp; &amp;lt;esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;esri:Extent xmin="-126" ymin="27" xmax="-72" ymax="50"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;esri:SpatialReference wkid="4326"/&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Extent&amp;gt;
&amp;nbsp; &amp;lt;/esri:extent&amp;gt;
&amp;nbsp; &amp;lt;esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; load="loadLayerName(event)"
&amp;nbsp;&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/{myURL.selectedItem}/MapServer" /&amp;gt;
&amp;nbsp; 
 &amp;lt;/esri:Map&amp;gt;
 
 &amp;lt;s:ComboBox id="myURL" selectedIndex="0" horizontalCenter="0" width="300"&amp;gt;
&amp;nbsp; &amp;lt;s:dataProvider&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;s:ArrayList&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:String&amp;gt;Specialty/ESRI_StateCityHighway_USA&amp;lt;/fx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:String&amp;gt;Specialty/ESRI_StatesCitiesRivers_USA&amp;lt;/fx:String&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:String&amp;gt;Demographics/ESRI_Census_USA&amp;lt;/fx:String&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/s:ArrayList&amp;gt;
&amp;nbsp; &amp;lt;/s:dataProvider&amp;gt;
 &amp;lt;/s:ComboBox&amp;gt;
 &amp;lt;s:Panel id="layerPanel" width="300" height="250" x="20" y="250"&amp;gt;
&amp;nbsp; &amp;lt;s:layout&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;s:VerticalLayout paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"/&amp;gt;
&amp;nbsp; &amp;lt;/s:layout&amp;gt;
 &amp;lt;/s:Panel&amp;gt;
&amp;lt;/s:Application&amp;gt;

&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526287#M11924</guid>
      <dc:creator>MarkHoyland</dc:creator>
      <dc:date>2021-12-11T22:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526288#M11925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for the code, it helps me understand what I was doing wrong. This is a simple/clean way to do layer on/off, I will definetely put it to good use. Thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 15:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526288#M11925</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2012-08-23T15:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Radio Button on/off Layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526289#M11926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am now trying to use the same example with checkboxes. I was assuming it should be fairly simple, but I admit, I'm wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I am able to load the layers in checkboxes, however, I am not able to have to code work in such way that: when I clicked on the checkbox the layer come on or off. Using dynamicLayer.visibleLayers = new ArrayCollection([5]); layer #6 get turned on but doesnt turned off. I have tried several different thing with no satisfactory result. Any help will be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]17233[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 22:51:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/radio-button-on-off-layers/m-p/526289#M11926</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2012-08-24T22:51:29Z</dc:date>
    </item>
  </channel>
</rss>

