<?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>idea Return All Operational Layers of Web Map Item in ArcGIS API for Python Ideas</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/return-all-operational-layers-of-web-map-item/idi-p/1281922</link>
    <description>&lt;P&gt;Please have the all the operational layers within a web map returned when using "layers" of a Web Map item.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that any layers within a Group Layer are skipped, meaning the user has to check whether the layer is a group layer and then further iterate over the layers within the group to truly retrieve all layers within the web map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example.&amp;nbsp; The grouped layers are expanded to show all the layers within the web map:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mpboyle_0-1682354409126.png" style="width: 227px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68898iCD7818BCE76B699D/image-dimensions/227x543?v=v2" width="227" height="543" role="button" title="mpboyle_0-1682354409126.png" alt="mpboyle_0-1682354409126.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In the code below, the layers within the "PLSS", "Annotation", and "Political Township" group layers are not returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcgis

# portal connection variables
portal_url = r'...portal url...'
portal_user_name = '...user name...'
portal_user_password = '...user password...'

# target web map
web_map_id = '...web map id...'

# connect to portal
p = arcgis.GIS(portal_url, portal_user_name, portal_user_password)

# set web map item
item = p.content.get(web_map_id)
# set web map item
web_map = arcgis.mapping.WebMap(item)
# get operational layers
layers = web_map.layers
for l in layers:
    layer_name = l.get('title')
    layer_type = l.get('layerType')
    print(f'{layer_name} ({layer_type})')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mpboyle_1-1682354588856.png" style="width: 319px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68899i7125E790EC16E3A8/image-dimensions/319x300?v=v2" width="319" height="300" role="button" title="mpboyle_1-1682354588856.png" alt="mpboyle_1-1682354588856.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;None of the layers within the group layers (green line) are returned.&amp;nbsp; It would be nice if they were returned without having to iterate through each group layer object.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2023 18:10:08 GMT</pubDate>
    <dc:creator>mpboyle</dc:creator>
    <dc:date>2023-04-24T18:10:08Z</dc:date>
    <item>
      <title>Return All Operational Layers of Web Map Item</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/return-all-operational-layers-of-web-map-item/idi-p/1281922</link>
      <description>&lt;P&gt;Please have the all the operational layers within a web map returned when using "layers" of a Web Map item.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that any layers within a Group Layer are skipped, meaning the user has to check whether the layer is a group layer and then further iterate over the layers within the group to truly retrieve all layers within the web map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example.&amp;nbsp; The grouped layers are expanded to show all the layers within the web map:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mpboyle_0-1682354409126.png" style="width: 227px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68898iCD7818BCE76B699D/image-dimensions/227x543?v=v2" width="227" height="543" role="button" title="mpboyle_0-1682354409126.png" alt="mpboyle_0-1682354409126.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In the code below, the layers within the "PLSS", "Annotation", and "Political Township" group layers are not returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcgis

# portal connection variables
portal_url = r'...portal url...'
portal_user_name = '...user name...'
portal_user_password = '...user password...'

# target web map
web_map_id = '...web map id...'

# connect to portal
p = arcgis.GIS(portal_url, portal_user_name, portal_user_password)

# set web map item
item = p.content.get(web_map_id)
# set web map item
web_map = arcgis.mapping.WebMap(item)
# get operational layers
layers = web_map.layers
for l in layers:
    layer_name = l.get('title')
    layer_type = l.get('layerType')
    print(f'{layer_name} ({layer_type})')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mpboyle_1-1682354588856.png" style="width: 319px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68899i7125E790EC16E3A8/image-dimensions/319x300?v=v2" width="319" height="300" role="button" title="mpboyle_1-1682354588856.png" alt="mpboyle_1-1682354588856.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;None of the layers within the group layers (green line) are returned.&amp;nbsp; It would be nice if they were returned without having to iterate through each group layer object.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 18:10:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-ideas/return-all-operational-layers-of-web-map-item/idi-p/1281922</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2023-04-24T18:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Return All Operational Layers of Web Map Item</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-ideas/return-all-operational-layers-of-web-map-item/idc-p/1546935#M115</link>
      <description>&lt;P&gt;Checkout the new mapping module (arcgis-mapping package) that was just released. We added a way to add and look through group layers!&lt;/P&gt;
&lt;P&gt;arcgis version 2.4.0&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 12:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-ideas/return-all-operational-layers-of-web-map-item/idc-p/1546935#M115</guid>
      <dc:creator>NanaeAubry</dc:creator>
      <dc:date>2024-10-09T12:55:27Z</dc:date>
    </item>
  </channel>
</rss>

