<?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: remove some Layers from the map in WAB (DE) in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814787#M6878</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sara,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; As I mentioned in my last reply:&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can not remove a sub layer you have to remove the whole layer.&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can set a sublayer visibility to false but you can not remove a sublayer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Nov 2018 13:40:12 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2018-11-12T13:40:12Z</dc:date>
    <item>
      <title>remove some Layers from the map in WAB (DE)</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814784#M6875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I am new to WAB(DE), I want to make a widget that removes some layers from the map,&lt;/P&gt;&lt;P&gt;I tried the code below but id does not work,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var layerInfos = LayerInfos.getInstanceSync();&lt;BR /&gt; array.forEach(layerInfos.getLayerInfoArray(), function(layerInfo) {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; this.map.removeLayer(layerInfo.newSubLayers[0].layerObject);&lt;BR /&gt; this.map.removeLayer(layerInfo.newSubLayers[1].layerObject);&lt;BR /&gt; this.map.removeLayer(layerInfo.newSubLayers[2].layerObject);&lt;BR /&gt;&lt;BR /&gt; }, this);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What is wrong with it ?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3101"&gt;Robert Scheitlin, GISP&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/space/2100"&gt;ArcGIS Enterprise&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2018 15:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814784#M6875</guid>
      <dc:creator>SaraEL_MALKI</dc:creator>
      <dc:date>2018-11-09T15:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: remove some Layers from the map in WAB (DE)</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814785#M6876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sara,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;You have a big issue with your logic. In your code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;removeLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerInfo&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;newSubLayers&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layerObject&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;you are assuming that the layer has sublayers 0 thru 2 and then try and remove the sublayers layer object form the map. You can not remove a sub layer you have to remove the whole layer.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; lyrInfoArr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; layerInfos&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getLayerInfoArray&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;removeLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyrInfoArr&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layerObject&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍
&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;removeLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyrInfoArr&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layerObject&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍
&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;removeLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyrInfoArr&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layerObject&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:36:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814785#M6876</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T09:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: remove some Layers from the map in WAB (DE)</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814786#M6877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;your code didn't work because I don't have three layers, I have published ONE mapService that contains three layers, it's giving me "TypeError: Cannot read property 'layerObject' of undefined"&lt;/P&gt;&lt;P&gt;because that is my "lyrInfoArr" variable:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/429329_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;I have tried also:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var layerInfos = LayerInfos.getInstanceSync(); &lt;BR /&gt;var lyrInfoArr = layerInfos.getLayerInfoArray();&lt;BR /&gt;var layerLayer=lyrInfoArr[0].layerObject.layerInfos;&lt;/P&gt;&lt;P&gt;this.map.removeLayer(layerLayer[0]);&lt;BR /&gt;this.map.removeLayer(layerLayer[1]);&lt;BR /&gt;this.map.removeLayer(layerLayer[2]);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But this code does nothing .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Nov 2018 09:02:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814786#M6877</guid>
      <dc:creator>SaraEL_MALKI</dc:creator>
      <dc:date>2018-11-12T09:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: remove some Layers from the map in WAB (DE)</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814787#M6878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sara,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; As I mentioned in my last reply:&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can not remove a sub layer you have to remove the whole layer.&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can set a sublayer visibility to false but you can not remove a sublayer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Nov 2018 13:40:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/remove-some-layers-from-the-map-in-wab-de/m-p/814787#M6878</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-11-12T13:40:12Z</dc:date>
    </item>
  </channel>
</rss>

