<?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 Help to understand how setVisibleLayers works with WAB2.1 in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/help-to-understand-how-setvisiblelayers-works-with/m-p/131896#M3787</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I write a widget for WAB 2.1 where I add 3&amp;nbsp;Dynamic MapService Layers hosted on ArcGIS Server. Every layer has one sublayer visible at widget startup.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var layer1 = new ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F62.236.121.188%2Farcgis%2Frest%2Fservices%2FDataAndMaps%2FBackground%2FMapServer" rel="nofollow" target="_blank"&gt;http://62.236.121.188/arcgis/rest/services/DataAndMaps/Background/MapServer&lt;/A&gt;&lt;SPAN&gt;", {"id": "Background"});&lt;/SPAN&gt;&lt;BR /&gt; layer1.on("load", function (e) {&lt;BR /&gt; layer1.setVisibleLayers([2]); &lt;BR /&gt; map.addLayer(layer1); &lt;BR /&gt; });&lt;BR /&gt;&lt;SPAN&gt; var layer2 = new ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F62.236.121.188%2Farcgis%2Frest%2Fservices%2FDataAndMaps%2FPressures%2FMapServer" rel="nofollow" target="_blank"&gt;http://62.236.121.188/arcgis/rest/services/DataAndMaps/Pressures/MapServer&lt;/A&gt;&lt;SPAN&gt;", {"id": "Pressures"});&lt;/SPAN&gt;&lt;BR /&gt; layer2.on("load", function (e) {&lt;BR /&gt; layer2.setVisibleLayers([2]); &lt;BR /&gt; map.addLayer(layer2); &lt;BR /&gt; });&lt;BR /&gt;&lt;SPAN&gt; var layer3 = new ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F62.236.121.188%2Farcgis%2Frest%2Fservices%2FDataAndMaps%2FMSP%2FMapServer" rel="nofollow" target="_blank"&gt;http://62.236.121.188/arcgis/rest/services/DataAndMaps/MSP/MapServer&lt;/A&gt;&lt;SPAN&gt;", {"id": "MSP"});&lt;/SPAN&gt;&lt;BR /&gt; layer3.on("load", function (e) {&lt;BR /&gt; layer3.setVisibleLayers([2]); &lt;BR /&gt; map.addLayer(layer3); &lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the button is clicked, visible sublayers in every layers should be changed. I want to get&amp;nbsp;sublayer 2 not visible and sublayer 3 becomes visible for every layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;function onLayerListItemClick(e) {&lt;BR /&gt; layer1.setVisibleLayers([3]);&lt;BR /&gt; layer2.setVisibleLayers([3]);&lt;BR /&gt; layer3.setVisibleLayers([3]);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens on click, is that the last (of three) layer changes visibility of sublayers as expected. First layer makes visible 14 sublayers and second - 33 sublayers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did the same task thing not using WAB, but just Javascript API for ArcGIS 3.18. And it work fine! Sublayers 2 become not visible and sublayers 3 become visible for every layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not understand why is this happening. Can, please, somebody from WAB team&amp;nbsp;explain&amp;nbsp;what is going under calling&amp;nbsp;&lt;SPAN&gt;setVisibleLayers() and what I should do to make my WAB widget do the same thing that I can do with pure Javascript API.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Source code WAB Widget and JSAPI versions are attached.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Andžej&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Oct 2016 14:07:07 GMT</pubDate>
    <dc:creator>AndžejMiloš</dc:creator>
    <dc:date>2016-10-14T14:07:07Z</dc:date>
    <item>
      <title>Help to understand how setVisibleLayers works with WAB2.1</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/help-to-understand-how-setvisiblelayers-works-with/m-p/131896#M3787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I write a widget for WAB 2.1 where I add 3&amp;nbsp;Dynamic MapService Layers hosted on ArcGIS Server. Every layer has one sublayer visible at widget startup.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var layer1 = new ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F62.236.121.188%2Farcgis%2Frest%2Fservices%2FDataAndMaps%2FBackground%2FMapServer" rel="nofollow" target="_blank"&gt;http://62.236.121.188/arcgis/rest/services/DataAndMaps/Background/MapServer&lt;/A&gt;&lt;SPAN&gt;", {"id": "Background"});&lt;/SPAN&gt;&lt;BR /&gt; layer1.on("load", function (e) {&lt;BR /&gt; layer1.setVisibleLayers([2]); &lt;BR /&gt; map.addLayer(layer1); &lt;BR /&gt; });&lt;BR /&gt;&lt;SPAN&gt; var layer2 = new ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F62.236.121.188%2Farcgis%2Frest%2Fservices%2FDataAndMaps%2FPressures%2FMapServer" rel="nofollow" target="_blank"&gt;http://62.236.121.188/arcgis/rest/services/DataAndMaps/Pressures/MapServer&lt;/A&gt;&lt;SPAN&gt;", {"id": "Pressures"});&lt;/SPAN&gt;&lt;BR /&gt; layer2.on("load", function (e) {&lt;BR /&gt; layer2.setVisibleLayers([2]); &lt;BR /&gt; map.addLayer(layer2); &lt;BR /&gt; });&lt;BR /&gt;&lt;SPAN&gt; var layer3 = new ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F62.236.121.188%2Farcgis%2Frest%2Fservices%2FDataAndMaps%2FMSP%2FMapServer" rel="nofollow" target="_blank"&gt;http://62.236.121.188/arcgis/rest/services/DataAndMaps/MSP/MapServer&lt;/A&gt;&lt;SPAN&gt;", {"id": "MSP"});&lt;/SPAN&gt;&lt;BR /&gt; layer3.on("load", function (e) {&lt;BR /&gt; layer3.setVisibleLayers([2]); &lt;BR /&gt; map.addLayer(layer3); &lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the button is clicked, visible sublayers in every layers should be changed. I want to get&amp;nbsp;sublayer 2 not visible and sublayer 3 becomes visible for every layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;function onLayerListItemClick(e) {&lt;BR /&gt; layer1.setVisibleLayers([3]);&lt;BR /&gt; layer2.setVisibleLayers([3]);&lt;BR /&gt; layer3.setVisibleLayers([3]);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens on click, is that the last (of three) layer changes visibility of sublayers as expected. First layer makes visible 14 sublayers and second - 33 sublayers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did the same task thing not using WAB, but just Javascript API for ArcGIS 3.18. And it work fine! Sublayers 2 become not visible and sublayers 3 become visible for every layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not understand why is this happening. Can, please, somebody from WAB team&amp;nbsp;explain&amp;nbsp;what is going under calling&amp;nbsp;&lt;SPAN&gt;setVisibleLayers() and what I should do to make my WAB widget do the same thing that I can do with pure Javascript API.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Source code WAB Widget and JSAPI versions are attached.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Andžej&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2016 14:07:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/help-to-understand-how-setvisiblelayers-works-with/m-p/131896#M3787</guid>
      <dc:creator>AndžejMiloš</dc:creator>
      <dc:date>2016-10-14T14:07:07Z</dc:date>
    </item>
  </channel>
</rss>

