<?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: Python API add all sublayers from hosted feature layer and maintain layer order in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/python-api-add-all-sublayers-from-hosted-feature/m-p/1694895#M68365</link>
    <description>&lt;P&gt;Have you tried looping through the layer collection and adding them in reverse index order? Assuming Waypoints is layer id 0, it's adding them in ascending order of layer id, with each new one added on top. So reverse it and it should be correct.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2026 20:08:42 GMT</pubDate>
    <dc:creator>Katie_Clark</dc:creator>
    <dc:date>2026-04-07T20:08:42Z</dc:date>
    <item>
      <title>Python API add all sublayers from hosted feature layer and maintain layer order</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-api-add-all-sublayers-from-hosted-feature/m-p/1694877#M68363</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am trying to work on a notebook that will pull in a specified feature layer and add it to an existing web map. So far the script I have will add all the data as expected, however it is never in the same order as it is in the hosted layer, and the group that layers are out into is not named the same things as the hosted layer (always being named Custom Group Layer). The layers should be in the opposite order to my screenshot below (waypoints first, then worksites, etc with Incident Area at the bottom of the list). I have tried a few different methods of adding layers and all of them produce the same exact result. Does anyone have any guidance on this?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AFackler_NAPSG_0-1775585957517.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/150779i5A4EF906AF865AF4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AFackler_NAPSG_0-1775585957517.png" alt="AFackler_NAPSG_0-1775585957517.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

gis = GIS("home")

layer_item_id = "&amp;lt;Layer ID&amp;gt;"
webmap_item_id = "&amp;lt;Map ID&amp;gt;"

layer_item = gis.content.get(layer_item_id)
webmap_item = gis.content.get(webmap_item_id)

layer_collection = layer_item.layers
    
wm = gis.map(webmap_item)
wm.content.add(layer_collection)
wm.update()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2026 18:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-api-add-all-sublayers-from-hosted-feature/m-p/1694877#M68363</guid>
      <dc:creator>AFackler_NAPSG</dc:creator>
      <dc:date>2026-04-07T18:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Python API add all sublayers from hosted feature layer and maintain layer order</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-api-add-all-sublayers-from-hosted-feature/m-p/1694895#M68365</link>
      <description>&lt;P&gt;Have you tried looping through the layer collection and adding them in reverse index order? Assuming Waypoints is layer id 0, it's adding them in ascending order of layer id, with each new one added on top. So reverse it and it should be correct.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2026 20:08:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-api-add-all-sublayers-from-hosted-feature/m-p/1694895#M68365</guid>
      <dc:creator>Katie_Clark</dc:creator>
      <dc:date>2026-04-07T20:08:42Z</dc:date>
    </item>
  </channel>
</rss>

