<?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 Get Layer By ComboBox in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/get-layer-by-combobox/m-p/329021#M7854</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;want to be able to turn on and off the layer (visibleLayers) by ComboBox. I'm attempting to create three ComboBoxs for the user to toggle the visibility of layers in a dynamic map service layer. these three ComboxBoxs Respectively represent "dynamic services", "Year", "Month" .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I know There are some mistakes the code , but I can not modify,Please help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I referred to the &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/2106-Radio-Button-on-off-Layers?highlight=Dynamic+layers" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/2106-Radio-Button-on-off-Layers?highlight=Dynamic+layers&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's One of them my relevant MapServer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://219.246.47.247/ArcGIS/rest/se...day5/MapServer" rel="nofollow noopener noreferrer" target="_blank"&gt;http://219.246.47.247/ArcGIS/rest/se...day5/MapServer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Service Description: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Map Name: Layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All Layers and Tables &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Layers: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;xianjie (0) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma021011 (1) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma021021 (2) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma031101 (3) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma061215 (4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma061215 (5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;eg."ma021011": "ma" representative "Lable"; "02" representative "Year(2002)"; "10" representative "month"; "11" representative "day"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my relevant mxml:&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" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:esri="http://www.esri.com/2008/ags"
minWidth="955" minHeight="600"&amp;gt;
&amp;lt;s:layout&amp;gt;
&amp;lt;s:VerticalLayout/&amp;gt;
&amp;lt;/s:layout&amp;gt;
&amp;lt;fx:Script&amp;gt;
&amp;lt;![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.RadioButton;
import mx.events.ItemClickEvent;

private function loadLayerName():void
{
layerPanel.removeAllChildren();

//loop through each layer and add as a radiobutton
var aa:String = "ma" + yearURL.selectedItem.toString() + monthURL.selectedItem.toString();


for(var i:uint = 0; i &amp;lt; (dynamicLayer.layerInfos.length); i++) 
{

if (aa = dynamicLayer.layerInfos&lt;I&gt;.name);
{

var radioBtn:RadioButton = new RadioButton;
radioBtn.groupName = "radioBtnGroup";
radioBtn.value = i;
radioBtn.label = dynamicLayer.layerInfos&lt;I&gt;.name;
layerPanel.addChild(radioBtn);
}
}

//set the visible layer the first radio button
radioBtnGroup.selectedValue = 0;
dynamicLayer.visibleLayers = new ArrayCollection([0]);
}

private function radioClickHandler(event:ItemClickEvent):void
{
// update the visible layers to only show the layer selected
dynamicLayer.visibleLayers = new ArrayCollection([event.index]);

} 
]]&amp;gt;
&amp;lt;/fx:Script&amp;gt;
&amp;lt;fxeclarations&amp;gt;
&amp;lt;!--&amp;nbsp; --&amp;gt;
&amp;lt;/fxeclarations&amp;gt;

&amp;lt;esri:Map id="myMap"&amp;gt;

&amp;lt;esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
load="loadLayerName()"
url="http://219.246.47.247/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;lt;fx:Array&amp;gt;

&amp;lt;fx:String&amp;gt;day&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;day5&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;day10&amp;lt;/fx:String&amp;gt;
&amp;lt;/fx:Array&amp;gt;

&amp;lt;/mx:ComboBox&amp;gt;

&amp;lt;mx:ComboBox id="yearURL"&amp;gt;
&amp;lt;fx:Array&amp;gt;

&amp;lt;fx:String&amp;gt;2002&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;2003&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;2006&amp;lt;/fx:String&amp;gt;
&amp;lt;/fx:Array&amp;gt;

&amp;lt;/mx:ComboBox&amp;gt;

&amp;lt;mx:ComboBox id="monthURL"&amp;gt;
&amp;lt;fx:Array&amp;gt;

&amp;lt;fx:String&amp;gt;10&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;11&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;12&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;01&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;02&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;03&amp;lt;/fx:String&amp;gt;
&amp;lt;/fx:Array&amp;gt;

&amp;lt;/mx:ComboBox&amp;gt;

&amp;lt;mx:Panel id="layerPanel" width="300" height="250" x="20" y="250" paddingLeft="20"&amp;gt;
&amp;lt;mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/&amp;gt;
&amp;lt;/mx:Panel&amp;gt;

&amp;lt;/s:Application&amp;gt; 
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:35:03 GMT</pubDate>
    <dc:creator>weiwang3</dc:creator>
    <dc:date>2021-12-11T15:35:03Z</dc:date>
    <item>
      <title>Get Layer By ComboBox</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/get-layer-by-combobox/m-p/329021#M7854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;want to be able to turn on and off the layer (visibleLayers) by ComboBox. I'm attempting to create three ComboBoxs for the user to toggle the visibility of layers in a dynamic map service layer. these three ComboxBoxs Respectively represent "dynamic services", "Year", "Month" .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I know There are some mistakes the code , but I can not modify,Please help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I referred to the &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/2106-Radio-Button-on-off-Layers?highlight=Dynamic+layers" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/2106-Radio-Button-on-off-Layers?highlight=Dynamic+layers&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's One of them my relevant MapServer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://219.246.47.247/ArcGIS/rest/se...day5/MapServer" rel="nofollow noopener noreferrer" target="_blank"&gt;http://219.246.47.247/ArcGIS/rest/se...day5/MapServer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Service Description: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Map Name: Layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All Layers and Tables &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Layers: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;xianjie (0) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma021011 (1) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma021021 (2) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma031101 (3) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma061215 (4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ma061215 (5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;eg."ma021011": "ma" representative "Lable"; "02" representative "Year(2002)"; "10" representative "month"; "11" representative "day"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my relevant mxml:&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" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:esri="http://www.esri.com/2008/ags"
minWidth="955" minHeight="600"&amp;gt;
&amp;lt;s:layout&amp;gt;
&amp;lt;s:VerticalLayout/&amp;gt;
&amp;lt;/s:layout&amp;gt;
&amp;lt;fx:Script&amp;gt;
&amp;lt;![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.RadioButton;
import mx.events.ItemClickEvent;

private function loadLayerName():void
{
layerPanel.removeAllChildren();

//loop through each layer and add as a radiobutton
var aa:String = "ma" + yearURL.selectedItem.toString() + monthURL.selectedItem.toString();


for(var i:uint = 0; i &amp;lt; (dynamicLayer.layerInfos.length); i++) 
{

if (aa = dynamicLayer.layerInfos&lt;I&gt;.name);
{

var radioBtn:RadioButton = new RadioButton;
radioBtn.groupName = "radioBtnGroup";
radioBtn.value = i;
radioBtn.label = dynamicLayer.layerInfos&lt;I&gt;.name;
layerPanel.addChild(radioBtn);
}
}

//set the visible layer the first radio button
radioBtnGroup.selectedValue = 0;
dynamicLayer.visibleLayers = new ArrayCollection([0]);
}

private function radioClickHandler(event:ItemClickEvent):void
{
// update the visible layers to only show the layer selected
dynamicLayer.visibleLayers = new ArrayCollection([event.index]);

} 
]]&amp;gt;
&amp;lt;/fx:Script&amp;gt;
&amp;lt;fxeclarations&amp;gt;
&amp;lt;!--&amp;nbsp; --&amp;gt;
&amp;lt;/fxeclarations&amp;gt;

&amp;lt;esri:Map id="myMap"&amp;gt;

&amp;lt;esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
load="loadLayerName()"
url="http://219.246.47.247/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;lt;fx:Array&amp;gt;

&amp;lt;fx:String&amp;gt;day&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;day5&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;day10&amp;lt;/fx:String&amp;gt;
&amp;lt;/fx:Array&amp;gt;

&amp;lt;/mx:ComboBox&amp;gt;

&amp;lt;mx:ComboBox id="yearURL"&amp;gt;
&amp;lt;fx:Array&amp;gt;

&amp;lt;fx:String&amp;gt;2002&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;2003&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;2006&amp;lt;/fx:String&amp;gt;
&amp;lt;/fx:Array&amp;gt;

&amp;lt;/mx:ComboBox&amp;gt;

&amp;lt;mx:ComboBox id="monthURL"&amp;gt;
&amp;lt;fx:Array&amp;gt;

&amp;lt;fx:String&amp;gt;10&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;11&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;12&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;01&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;02&amp;lt;/fx:String&amp;gt;
&amp;lt;fx:String&amp;gt;03&amp;lt;/fx:String&amp;gt;
&amp;lt;/fx:Array&amp;gt;

&amp;lt;/mx:ComboBox&amp;gt;

&amp;lt;mx:Panel id="layerPanel" width="300" height="250" x="20" y="250" paddingLeft="20"&amp;gt;
&amp;lt;mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/&amp;gt;
&amp;lt;/mx:Panel&amp;gt;

&amp;lt;/s:Application&amp;gt; 
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/get-layer-by-combobox/m-p/329021#M7854</guid>
      <dc:creator>weiwang3</dc:creator>
      <dc:date>2021-12-11T15:35:03Z</dc:date>
    </item>
  </channel>
</rss>

