<?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: Accessing layers from WebMap in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637591#M87434</link>
    <description>&lt;P&gt;Two years later and we're observing similar behavior.&amp;nbsp; We're using the new &amp;lt;arcgis-map&amp;gt; component and portalItem which is great for maintenance of the symbology, display fields, and popups...&amp;nbsp; it's a great abstraction from line-by-line definitions of basic maps, but now we're having trouble accessing basic properties.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;As the original post: if we manually add FeatureLayers things work as expected and the properties are easily accessible (including visibility and such&amp;nbsp;&lt;EM&gt;within the client-side map&lt;/EM&gt;).&amp;nbsp; &amp;nbsp;And, layers added individually to our&amp;nbsp;&lt;EM&gt;WebMap PortalItem&lt;/EM&gt; are also returned by map.allLayers and the like.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Our problem is (as it seems above) that we've packaged our own Enterprise-referenced data into a single MapImageLayer, but then from the Javascript side, map.allLayers returns&amp;nbsp;&lt;EM&gt;only&amp;nbsp;&lt;/EM&gt;the 'MapServiceLayer' with none of the sublayers...&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jul 2025 13:12:25 GMT</pubDate>
    <dc:creator>D_Atkins</dc:creator>
    <dc:date>2025-07-30T13:12:25Z</dc:date>
    <item>
      <title>Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1337760#M82463</link>
      <description>&lt;P&gt;Hello All.&amp;nbsp;&amp;nbsp; I have previously added FeatureLayers individually and used some level of document.getElementById and addEventListener('click') to turn those FeatureLayers on and off using an html Checkbox.&lt;/P&gt;&lt;P&gt;But,&amp;nbsp; I am now using an AGOL hosted WebMap to draw the content in my app, and trying to use the Calcite 'checkbox' to toggle my WebMap layers on and off?&amp;nbsp; and I cannot figure out how to access those individual layers in the WebMap and how to use the Calcite checkbox component to turn them on and off.&lt;/P&gt;&lt;P&gt;I have no trouble adding the Calcite Components(checkbox, slider, etc) but just don't know how to relate them back to my layers within my WebMap.&amp;nbsp;&amp;nbsp; is it a getLayers All or Find item by ID thing?&amp;nbsp; accessing the data in a WebMap is new to me.&amp;nbsp;&amp;nbsp; thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 15:13:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1337760#M82463</guid>
      <dc:creator>Paco</dc:creator>
      <dc:date>2023-10-13T15:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1338231#M82468</link>
      <description>&lt;P&gt;The layers property of the WebMap contains a collection of all layers within the WebMap.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#layers" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#layers&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        webMap.layers.forEach((layer) =&amp;gt; {
          // Do whatever with each layer
        });&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Oct 2023 14:20:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1338231#M82468</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-10-16T14:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1338254#M82469</link>
      <description>&lt;P&gt;Great,&amp;nbsp; thanks Tim that helps.&amp;nbsp; so getting a specific map layer can be accomplished by the layer "name" or it's layer "id"?&amp;nbsp; can I get layer GROUPS?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was attempting a similar getLayers property using the WebMap layer "id" number but was returning null in the Console.&amp;nbsp; im sure I was doing something wrong in the syntax.&amp;nbsp; &amp;nbsp;I wanted to be sure of where to get the correct WebMap layer "id" as well,&amp;nbsp; im just copying it from the end of the WebMap/Feature Layer URL.&amp;nbsp; not sure if that's correct.&amp;nbsp; &amp;nbsp;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 15:40:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1338254#M82469</guid>
      <dc:creator>Paco</dc:creator>
      <dc:date>2023-10-16T15:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1338263#M82471</link>
      <description>&lt;P&gt;Paco, looking at&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#properties-summary," target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#properties-summary,&lt;/A&gt;&amp;nbsp;layers have id and title (not name).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding Groups, I see that the layers may have a parent and that parent may be part of a GroupLayer:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I'm assuming that the layers either need to be grouped by you or whomever provided the WebMap.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 15:54:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1338263#M82471</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-10-16T15:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1339441#M82506</link>
      <description>&lt;P&gt;Still having trouble accessing any layers within an existing WebMap.&lt;/P&gt;&lt;P&gt;I can add my ENTIRE WebMap using the "portalItem:",&amp;nbsp; and I can add a Group within that WebMap using "Layer.fromPortalItem",&amp;nbsp; but I cannot seem to get access to those new variables for simple things like turning layer visibility on and off??&lt;/P&gt;&lt;P&gt;I really would like to use my WebMap for the many Arcade expressions(popups) and Styling I already have in the WebMap.&amp;nbsp; &amp;nbsp;I tested using FeatureLayers of the same data and have no problems.&amp;nbsp; but working with the WebMap seems to still give me problems.&amp;nbsp; &amp;nbsp;anybody else working with WebMaps in their applications?&amp;nbsp; thankyou!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 04:06:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1339441#M82506</guid>
      <dc:creator>Paco</dc:creator>
      <dc:date>2023-10-19T04:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637591#M87434</link>
      <description>&lt;P&gt;Two years later and we're observing similar behavior.&amp;nbsp; We're using the new &amp;lt;arcgis-map&amp;gt; component and portalItem which is great for maintenance of the symbology, display fields, and popups...&amp;nbsp; it's a great abstraction from line-by-line definitions of basic maps, but now we're having trouble accessing basic properties.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;As the original post: if we manually add FeatureLayers things work as expected and the properties are easily accessible (including visibility and such&amp;nbsp;&lt;EM&gt;within the client-side map&lt;/EM&gt;).&amp;nbsp; &amp;nbsp;And, layers added individually to our&amp;nbsp;&lt;EM&gt;WebMap PortalItem&lt;/EM&gt; are also returned by map.allLayers and the like.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Our problem is (as it seems above) that we've packaged our own Enterprise-referenced data into a single MapImageLayer, but then from the Javascript side, map.allLayers returns&amp;nbsp;&lt;EM&gt;only&amp;nbsp;&lt;/EM&gt;the 'MapServiceLayer' with none of the sublayers...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2025 13:12:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637591#M87434</guid>
      <dc:creator>D_Atkins</dc:creator>
      <dc:date>2025-07-30T13:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637647#M87436</link>
      <description>&lt;P&gt;This can be tricky as you may need to wait for both the web map and the layers to load. Are you waiting for the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#loadAll" target="_self"&gt;loadAll&lt;/A&gt; method on the MapImageLayer?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;await viewElement.viewOnReady();
await viewElement.map.loadAll();
await mapImageLayer.loadAll();

const allLayersAndSublayers = viewElement.map.allLayers.flatten((layer) =&amp;gt; {
  return layer.layers || layer.sublayers;
});

allLayersAndSublayers.forEach((layer) =&amp;gt; {
  console.log(`${layer.title} - ${layer.type}`)
})&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Jul 2025 15:30:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637647#M87436</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2025-07-30T15:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing layers from WebMap</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637665#M87439</link>
      <description>&lt;P&gt;Thanks Sage_Wall!&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Our legacy work was using lots of '.layer' and had never even considered a .sublayer property!&amp;nbsp; (Of course, this snippet would be front and center on the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#flatten" target="_self"&gt;Collection documentation, under flatten&lt;/A&gt;.)&amp;nbsp; This at least gets us to the id/title of the&amp;nbsp;&lt;EM&gt;Group Layer&lt;/EM&gt;s&amp;nbsp;within the MapImageLayer...&amp;nbsp; but while the documentation says flatten is recursive, we're still not seeing properties for the sub-sublayers (for lack of a better term).&amp;nbsp; We also have Groups nested within Groups, so will need to step down at least two more levels in the layer-tree.&lt;BR /&gt;&lt;BR /&gt;In any case, this is a big push forward, for now!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2025 15:59:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-layers-from-webmap/m-p/1637665#M87439</guid>
      <dc:creator>D_Atkins</dc:creator>
      <dc:date>2025-07-30T15:59:52Z</dc:date>
    </item>
  </channel>
</rss>

