<?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: Enabling layers in ArcGIS Viewer for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300267#M8860</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I got some code from another thread which helped in enabling the toc based upon visibilty of the layer. It works great for child layers in a map service layer but doesnt work for the group layers containing further sub layers. &lt;BR /&gt;&lt;BR /&gt;The result i get is that the unexpectedly all sublayers under the group layer become visible yet the tick boxes for those layers remain unchecked (which is fine), however i am not sure why the sublayers become visible for example&lt;BR /&gt;&lt;BR /&gt;If i have a group layer &lt;BR /&gt;&lt;BR /&gt;Infrastructure&lt;BR /&gt;----buildings&lt;BR /&gt;----structures&lt;BR /&gt;----roads&lt;BR /&gt;&lt;BR /&gt;and i use the code below to only put tick boxes for the group layer called Infrastructure and buildings, it does work and only those checkboxes are ticked but i also get structures and roads visible on the map yet their checkboxes are unticked.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var visLayers:ArrayCollection = dmsl.visibleLayers;
var newVisLayer:ArrayCollection=new ArrayCollection(obj.visLyrs.visibleLayer);
for each(var j:int in newVisLayer){
AppEvent.dispatch(AppEvent.LAYER_VISIBILITY_CHANGED,j);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;In toc Item i have&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
public function TocItem( parentItem:TocItem = null )
{
 _parent = parentItem;
 //ViewerContainer.addEventListener(AppEvent.LAYER_VISIBILITY_CHANGED, updateCB);
 AppEvent.addListener(AppEvent.LAYER_VISIBILITY_CHANGED,updateCB);
}

private function updateCB(event:AppEvent):void
{
 if(this is TocLayerInfoItem)
&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 tli:TocLayerInfoItem = this as TocLayerInfoItem;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; if(tli.layerInfo.id == event.data){
&amp;nbsp;&amp;nbsp; setVisibleDirect(_visible ? false : true);
&amp;nbsp; }
 }
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have got the group layers problem sorted however now i have another problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function updateCB is repeatedly called for all map services. For example if i only want to loop through the sub layers of map service #1, it goes them fine but also goes through sub layers of map service #2. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can i restrict it to only loop through 1 map service. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:24:02 GMT</pubDate>
    <dc:creator>FaizanTayyab</dc:creator>
    <dc:date>2021-12-11T14:24:02Z</dc:date>
    <item>
      <title>Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300261#M8854</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; i have tried to use the code below to make the layer visible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;map.getLayer("USA Daytime Population").visible=ture&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but it is giving me a null reference error. Doesnt the getLayer method accept sub layers?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anyway to make a certain sublayer visible based on a certain condition.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 06:16:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300261#M8854</guid>
      <dc:creator>FaizanTayyab</dc:creator>
      <dc:date>2011-10-18T06:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300262#M8855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Faizan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; No getLayer is not for individual layers only the whole map service to enable visibility on a particular layer in the map service you would use visibleLayers array Collection. Look at the documentation for a layer like ArcGISDynamicMapService and you will see visible layers property and some examples of how to use it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 10:56:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300262#M8855</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2011-10-18T10:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300263#M8856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Faizan,&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; No getLayer is not for individual layers only the whole map service to enable visibility on a particular layer in the map service you would use visibleLayers array Collection. Look at the documentation for a layer like ArcGISDynamicMapService and you will see visible layers property and some examples of how to use it.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. In terms of visibleLayers, i do not get the group layers returned. is this a built in limitation?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 11:00:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300263#M8856</guid>
      <dc:creator>FaizanTayyab</dc:creator>
      <dc:date>2011-10-18T11:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300264#M8857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Faizan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Yes the visibleLayers array collection will never list the id of a group layer but you can add that id to turn on the group.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 11:05:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300264#M8857</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2011-10-18T11:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300265#M8858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Faizan,&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Yes the visibleLayers array collection will never list the id of a group layer but you can add that id to turn on the group.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the advice. I thought the visibleLayers was a read only property but found out that it is read and write. Although i got it work fine, i am unable to get the toc to reflect the same. I am assuming that requires more logic to update the toc with the visibility of each sublayer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 07:25:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300265#M8858</guid>
      <dc:creator>FaizanTayyab</dc:creator>
      <dc:date>2011-10-19T07:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300266#M8859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got some code from another thread which helped in enabling the toc based upon visibilty of the layer. It works great for child layers in a map service layer but doesnt work for the group layers containing further sub layers. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The result i get is that the unexpectedly all sublayers under the group layer become visible yet the tick boxes for those layers remain unchecked (which is fine), however i am not sure why the sublayers become visible for example&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If i have a group layer &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Infrastructure&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;----buildings&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;----structures&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;----roads&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and i use the code below to only put tick boxes for the group layer called Infrastructure and buildings, it does work and only those checkboxes are ticked but i also get structures and roads visible on the map yet their checkboxes are unticked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var visLayers:ArrayCollection = dmsl.visibleLayers;
var newVisLayer:ArrayCollection=new ArrayCollection(obj.visLyrs.visibleLayer);
for each(var j:int in newVisLayer){
AppEvent.dispatch(AppEvent.LAYER_VISIBILITY_CHANGED,j);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In toc Item i have&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
public function TocItem( parentItem:TocItem = null )
{
 _parent = parentItem;
 //ViewerContainer.addEventListener(AppEvent.LAYER_VISIBILITY_CHANGED, updateCB);
 AppEvent.addListener(AppEvent.LAYER_VISIBILITY_CHANGED,updateCB);
}

private function updateCB(event:AppEvent):void
{
 if(this is TocLayerInfoItem)
&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 tli:TocLayerInfoItem = this as TocLayerInfoItem;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; if(tli.layerInfo.id == event.data){
&amp;nbsp;&amp;nbsp; setVisibleDirect(_visible ? false : true);
&amp;nbsp; }
 }
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:23:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300266#M8859</guid>
      <dc:creator>FaizanTayyab</dc:creator>
      <dc:date>2021-12-11T14:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300267#M8860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I got some code from another thread which helped in enabling the toc based upon visibilty of the layer. It works great for child layers in a map service layer but doesnt work for the group layers containing further sub layers. &lt;BR /&gt;&lt;BR /&gt;The result i get is that the unexpectedly all sublayers under the group layer become visible yet the tick boxes for those layers remain unchecked (which is fine), however i am not sure why the sublayers become visible for example&lt;BR /&gt;&lt;BR /&gt;If i have a group layer &lt;BR /&gt;&lt;BR /&gt;Infrastructure&lt;BR /&gt;----buildings&lt;BR /&gt;----structures&lt;BR /&gt;----roads&lt;BR /&gt;&lt;BR /&gt;and i use the code below to only put tick boxes for the group layer called Infrastructure and buildings, it does work and only those checkboxes are ticked but i also get structures and roads visible on the map yet their checkboxes are unticked.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var visLayers:ArrayCollection = dmsl.visibleLayers;
var newVisLayer:ArrayCollection=new ArrayCollection(obj.visLyrs.visibleLayer);
for each(var j:int in newVisLayer){
AppEvent.dispatch(AppEvent.LAYER_VISIBILITY_CHANGED,j);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;In toc Item i have&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
public function TocItem( parentItem:TocItem = null )
{
 _parent = parentItem;
 //ViewerContainer.addEventListener(AppEvent.LAYER_VISIBILITY_CHANGED, updateCB);
 AppEvent.addListener(AppEvent.LAYER_VISIBILITY_CHANGED,updateCB);
}

private function updateCB(event:AppEvent):void
{
 if(this is TocLayerInfoItem)
&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 tli:TocLayerInfoItem = this as TocLayerInfoItem;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; if(tli.layerInfo.id == event.data){
&amp;nbsp;&amp;nbsp; setVisibleDirect(_visible ? false : true);
&amp;nbsp; }
 }
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have got the group layers problem sorted however now i have another problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function updateCB is repeatedly called for all map services. For example if i only want to loop through the sub layers of map service #1, it goes them fine but also goes through sub layers of map service #2. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can i restrict it to only loop through 1 map service. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:24:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300267#M8860</guid>
      <dc:creator>FaizanTayyab</dc:creator>
      <dc:date>2021-12-11T14:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling layers</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300268#M8861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try evt.stopPropagation();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2017 12:04:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/enabling-layers/m-p/300268#M8861</guid>
      <dc:creator>deleted-user-0W0-oLHxDjCX</dc:creator>
      <dc:date>2017-01-06T12:04:39Z</dc:date>
    </item>
  </channel>
</rss>

