<?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: Programmatically Turning Layers Off/On in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639868#M14194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rich,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on the functionality you are describing, there really isn't a need to replicate the code-based functionality you had in ArcIMS.&amp;nbsp; Just define the layer groupings in your mxd, add the appropriate layers to those groups and use the MapSwitcher widget (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapps/flexviewer/help/widgets/mapswitcher_widget.htm"&gt;http://help.arcgis.com/en/webapps/flexviewer/help/widgets/mapswitcher_widget.htm&lt;/A&gt;&lt;SPAN&gt;) in your application.&amp;nbsp; Map Switcher will display the grouped layers under the More button and allow the users to turn on/off any&amp;nbsp; layer groups or individual layers under the groups that they want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Keith&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Nov 2010 17:56:49 GMT</pubDate>
    <dc:creator>KeithPalmer</dc:creator>
    <dc:date>2010-11-09T17:56:49Z</dc:date>
    <item>
      <title>Programmatically Turning Layers Off/On</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639866#M14192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We're currently trying to recreate functionality we have in our ArcIMS based mapping application within the ArcGIS Server Flex Viewer. One of the options we currently allow our visitors is to toggle on and off map themes, or predefined groupings of similar layers (i.e. a Recreation theme that will turn on the parks layer, boat ramp layer and trails layer). In ArcIMS we accomplished this through code on the back-end: theme names were passed as a query string in the URL, layers to be turned on and off for each theme were stored in tables within our RDBMS. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We're just getting our feet wet with the Flex Viewer and really are not sure where to begin to replicate this feature. We sorted through the standard widgets, but didn't come across anything that sounded like it would work. Does anyone have any suggestions or ideas that can get us going with this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich Hammond&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GIS Team Leader&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Florida Center for Community Design and Research&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;University of South Florida&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 12:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639866#M14192</guid>
      <dc:creator>RichHammond</dc:creator>
      <dc:date>2010-11-09T12:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Turning Layers Off/On</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639867#M14193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can get all the layers by doing something like this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var layerArray:Array = new Array();
&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; var mapLyrs:Array = map.layerIds.sort();
&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; for(var i:Number = 0; i &amp;lt;= map.layerIds.length-1; i++)
&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;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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var layer:Layer = map.getLayer(mapLyrs&lt;I&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; }
&lt;/I&gt;&lt;/PRE&gt;&lt;SPAN&gt;Then you can set layer.visible to turn layers on/off.&amp;nbsp; Or if you know the name of your layer you can do something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;map.getLayer("LAYERNAME") where you set LAYERNAME in config.xml &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;lt;operationallayers&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;layer label="LAYERNAME" type="feature" visible="false" alpha="1" 
&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; url="http://url/to/layer/rest/service"/&amp;gt;
&amp;lt;/operationallayers&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Additional Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also check out the LayerList widget.&amp;nbsp; Which will give you groups of layers provided they are in the same Feature Dataset on ArcServer end.&amp;nbsp; So if you had a layer like this in your config.xml&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;layer label="NOAA Services" type="dynamic" visible="false" alpha="0.5"
&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; url="http://publicsafetytemplates.esri.com/ArcGIS/rest/services/EMCOP/PublicSafetyFeedSample/MapServer"/&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would show a collapsible list of all layers under that rest url.&amp;nbsp; I hope that makes sense.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:11:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639867#M14193</guid>
      <dc:creator>MattMoyles</dc:creator>
      <dc:date>2021-12-12T03:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Turning Layers Off/On</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639868#M14194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rich,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on the functionality you are describing, there really isn't a need to replicate the code-based functionality you had in ArcIMS.&amp;nbsp; Just define the layer groupings in your mxd, add the appropriate layers to those groups and use the MapSwitcher widget (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapps/flexviewer/help/widgets/mapswitcher_widget.htm"&gt;http://help.arcgis.com/en/webapps/flexviewer/help/widgets/mapswitcher_widget.htm&lt;/A&gt;&lt;SPAN&gt;) in your application.&amp;nbsp; Map Switcher will display the grouped layers under the More button and allow the users to turn on/off any&amp;nbsp; layer groups or individual layers under the groups that they want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Keith&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 17:56:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/programmatically-turning-layers-off-on/m-p/639868#M14194</guid>
      <dc:creator>KeithPalmer</dc:creator>
      <dc:date>2010-11-09T17:56:49Z</dc:date>
    </item>
  </channel>
</rss>

