<?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: Get all maps that contain a feature layer - Python API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1135330#M7020</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/439089"&gt;@fklotz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Nice script, saved me a lot of time writing it myself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Small improvement at line 30:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        for lyr in lyrs:
            if 'url' in lyr and not found_it:                
                found_it = lyr_to_find.lower() in lyr.url.lower()     
            elif 'layerType' in lyr and lyr.layerType =="GroupLayer":
                for sublyr in lyr.layers:
                    if 'url' in sublyr and not found_it:                
                        found_it = lyr_to_find.lower() in sublyr.url.lower()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an exception when it found a layer in my GIS without url. The first part of the if statement fixes this. And it should stop searching the webmap when it already found a match, otherwise another layer in the webmap might set the found_it variable to False again, the second part of my if statement should fix that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: added support for the new Map Viewer Group Layers. Noticed that the script didn't find a map and this was due to a group layer.&lt;/P&gt;&lt;P&gt;Another Edit: found a case where an url was not found, because part of it was in uppercase. Updated my snippet to take care of this&lt;/P&gt;</description>
    <pubDate>Thu, 10 Feb 2022 16:18:24 GMT</pubDate>
    <dc:creator>JoëlHempenius3</dc:creator>
    <dc:date>2022-02-10T16:18:24Z</dc:date>
    <item>
      <title>Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797521#M1882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to find all of the maps that contain any one feature layer in ArcGIS Online using the Python API? For example, if there is a feature layer using frequently across the organization, and I want to find out which maps are using that layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see some documentation about finding &lt;A href="https://developers.arcgis.com/python/guide/managing-your-content/"&gt;relationships between items here&lt;/A&gt;.&amp;nbsp;The Map2Service seems to work in one direction - find the services in the map. But is there a way to do this the other direction?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Oct 2020 13:38:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797521#M1882</guid>
      <dc:creator>TanGnar</dc:creator>
      <dc:date>2020-10-07T13:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797522#M1883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/344498" target="_blank"&gt;Tanner Arrington&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use reverse direction in related items method to get the web maps in which a feature layer is being used, however, you need to establish a relationship using (add_relationship) with the web maps first.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;webmap1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'webmap ID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
webmap_related_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Feature Layer ID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

webmap1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_relationship&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rel_item&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; webmap_related_item&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rel_type&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Map2Service'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
webmap_related_item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;related_items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Map2Service'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'reverse'&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and conversely,&amp;nbsp;forward direction provides the feature layers (collections) used in the web map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:13:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797522#M1883</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-12-12T09:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797523#M1884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tanner,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote a script to do this last year:&amp;nbsp;&lt;A class="link-titled" href="https://github.com/joshsharpheward/gis-administration/blob/master/search_webmaps_for_services.py" title="https://github.com/joshsharpheward/gis-administration/blob/master/search_webmaps_for_services.py"&gt;gis-administration/search_webmaps_for_services.py at master · joshsharpheward/gis-administration · GitHub&lt;/A&gt;&amp;nbsp;which&amp;nbsp;I designed to be run from ArcGIS Pro, you can download the gp toolbox in that repo to use it straight away! Otherwise if you want to run it from another environment you can copy the code from the script and just modify the 'gis = GIS("pro")' and '&lt;SPAN class="" style="color: #24292e; background-color: #ffffff;"&gt;services&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #005cc5; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #24292e; background-color: #ffffff;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #e36209; background-color: #ffffff;"&gt;GetParameter&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #005cc5; background-color: #ffffff;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;)' lines. Note my script also scans web applications in your portal/agol to see if the service is being used in any configured searches, but this can be stripped out easily.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2020 14:52:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797523#M1884</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2020-10-08T14:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797524#M1885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Super helpful, thanks a bunch for sharing!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Oct 2020 15:12:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797524#M1885</guid>
      <dc:creator>TanGnar</dc:creator>
      <dc:date>2020-10-15T15:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797525#M1886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tanner, glad I could help out!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Oct 2020 17:35:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/797525#M1886</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2020-10-15T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1051691#M5975</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/320057"&gt;@TanGnar&lt;/a&gt;,&amp;nbsp;I'm a little late to this, but:&lt;/P&gt;&lt;P&gt;You can do this in the ArcGIS python API without adding a relationship by looping through the layers in the maps.&amp;nbsp; The benefits of this method are that it can be done in a standard notebook on ArcGIS online (no credit usage!) without editing your content or adding relationships or can be used in your local python environment&amp;nbsp;without using up an ESRI license.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;""" This code is meant to be run in a standard python notebook in ArcGIS Online.  
If you are using it outside of that environment, it may require modification.

Requirements:  ArcGIS Python API, ArcGIS Online Organizatation containing maps
"""

from arcgis.mapping import WebMap
from arcgis.gis import GIS
gis = GIS("home")

def find_maps_with_layer(lyr_to_find, map_item_query='1=1'):
    """
    Searches for items using the map_item_query, then searches each each map 
    found for any layers who's url contains the lyr_to_find
    
    Note that the web map search is limited to 10000 items below
    
    Author: Farley Klotz
    :param lyr_to_find: url of layer to find (or portion of url)
    :param map_item_query: AGO item query to limit web maps searched
    """
    web_map_items = gis.content.search(query=map_item_query, item_type="Web Map", max_items=10000)
    print(f"Searching {len(web_map_items)} web maps")
    maps_with_layer = []
    maps_without_layer = []
    for item in web_map_items:
        found_it = False
        wm = WebMap(item)
        lyrs = wm.layers
        for lyr in lyrs:
            found_it = lyr_to_find in lyr.url
        if found_it:
            print(f'{item.title} contains the layer')
            display(item)
            maps_with_layer.append(item)
        else:
            maps_without_layer.append(item)
    print(f"Found {len(maps_with_layer)} maps which contain the layer")
    print(f"Found {len(maps_without_layer)} maps which do not contain the layer")
    return maps_with_layer, maps_without_layer
    

# Parameters:
lyr_to_find = 'https://services.arcgis.com/XN3gLesriRY2KtI6/arcgis/rest/services/my_service_layer/FeatureServer'
map_item_query = "Title:my map title"

# lets see some results:
maps_with_layer, maps_without_layer = find_maps_with_layer(lyr_to_find, map_item_query)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 13:01:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1051691#M5975</guid>
      <dc:creator>fklotz</dc:creator>
      <dc:date>2021-04-27T13:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1135330#M7020</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/439089"&gt;@fklotz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Nice script, saved me a lot of time writing it myself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Small improvement at line 30:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        for lyr in lyrs:
            if 'url' in lyr and not found_it:                
                found_it = lyr_to_find.lower() in lyr.url.lower()     
            elif 'layerType' in lyr and lyr.layerType =="GroupLayer":
                for sublyr in lyr.layers:
                    if 'url' in sublyr and not found_it:                
                        found_it = lyr_to_find.lower() in sublyr.url.lower()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an exception when it found a layer in my GIS without url. The first part of the if statement fixes this. And it should stop searching the webmap when it already found a match, otherwise another layer in the webmap might set the found_it variable to False again, the second part of my if statement should fix that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: added support for the new Map Viewer Group Layers. Noticed that the script didn't find a map and this was due to a group layer.&lt;/P&gt;&lt;P&gt;Another Edit: found a case where an url was not found, because part of it was in uppercase. Updated my snippet to take care of this&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 16:18:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1135330#M7020</guid>
      <dc:creator>JoëlHempenius3</dc:creator>
      <dc:date>2022-02-10T16:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1160055#M7268</link>
      <description>&lt;P&gt;Thank you both &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/439089"&gt;@fklotz&lt;/a&gt; and &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/326275"&gt;@JoëlHempenius3&lt;/a&gt; , works great and saved me some work as well.&lt;/P&gt;&lt;P&gt;I will add that I was getting an error when it hit certain web maps that contained uploaded shapefiles (Classic Map Viewer; and which have no url). To get around it I just wrapped&amp;nbsp;Joëls whole bit into a try/except clause. I'm sure there's a more elegant way to handle that issue but this works and I can then investigate the map manually at that point if I suspect the layer I'm searching for is in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
    for lyr in lyrs:
        if 'url' in lyr and not found_it:                
            found_it = lyr_to_find.lower() in lyr.url.lower()     
        elif 'layerType' in lyr and lyr.layerType =="GroupLayer":
            for sublyr in lyr.layers:
                if 'url' in sublyr and not found_it:                
                    found_it = lyr_to_find.lower() in sublyr.url.lower()
except Exception as error:
    print(f'{item.title} led to an error')
    print(error)
    display(item)
    continue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 20:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1160055#M7268</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2022-03-31T20:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1161777#M7292</link>
      <description>&lt;P&gt;Thanks for posting this!&amp;nbsp; Thanks to all who contributed updates too!&amp;nbsp; I split the url so I could just look for the service name.&amp;nbsp; This way I didn't have to handle different urls based on if they were map or feature services, and if they were added to the map as a web layer or as a service.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;                if 'url' in lyr and not found_it:
                    serviceUrlSplitList = lyr.url.split('/')
                    found_it = lyr_to_find in serviceUrlSplitList
                elif 'layerType' in lyr and lyr.layerType == "GroupLayer":
                    for sublyr in lyr.layers:
                        if 'url' in sublyr and not found_it:
                            serviceUrlSplitList = lyr.url.split('/')
                            found_it = lyr_to_find in serviceUrlSplitList&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 18:58:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1161777#M7292</guid>
      <dc:creator>ChrisWiebke</dc:creator>
      <dc:date>2022-04-06T18:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1243981#M8224</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/13783"&gt;@ChrisWiebke&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/439089"&gt;@fklotz&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;I am looking for code which just go through each webmaps in my organization and give me url items inside of webmaps with title of urls.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create table like this:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;webmap title&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;url title&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;url&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;NYC Crime map&lt;/TD&gt;&lt;TD height="25px"&gt;City Council Districts&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;A href="https://........" target="_blank" rel="noopener"&gt;https://&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="25px"&gt;Map PLUTO&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;A href="https://........" target="_blank" rel="noopener"&gt;https://&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="25px"&gt;police precincts&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;A href="https://........" target="_blank" rel="noopener"&gt;https://&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;NYC Bike Share map&lt;/TD&gt;&lt;TD height="25px"&gt;School Districts&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;A href="https://........" target="_blank" rel="noopener"&gt;https://&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="25px"&gt;Subway Stops&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;A href="https://........" target="_blank" rel="noopener"&gt;https://&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note: some items are inside of group in webmap which I need to scan those to and return urls&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code which I need to manually copy paste webmap id and also doesn't return url items inside group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
from arcgis.mapping import WebMap
from arcgis.widgets import MapView
gis = GIS('home')

wmItem = gis.content.search(query= 'YourWebMapID')
print(wmItem)

wmItemId = "YourWebMapID" #put the id of the webmap in here
wmItem = gis.content.get(wmItemId)
wm = WebMap(wmItem)
for lyr in wm.layers:
    print(lyr.title)
    print(lyr.url)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will appreciate if someone can help me with this.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 18:45:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1243981#M8224</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2022-12-29T18:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1337856#M9142</link>
      <description>&lt;P&gt;""" Performed some updates for newer versions of Python API in an ArcGIS Pro 3.1.x setting which got rid of the PropertyMap Attribute error.&lt;BR /&gt;Date: 10-23-2023&lt;BR /&gt;"""&lt;/P&gt;&lt;P&gt;def find_maps_with_layer(lyr_to_find, map_item_query='1=1'):&lt;BR /&gt;web_map_items = gis.content.search(query=map_item_query, item_type="Web Map", max_items=10000)&lt;BR /&gt;print(f"Searching {len(web_map_items)} web maps")&lt;BR /&gt;maps_with_layer = []&lt;/P&gt;&lt;P&gt;for item in web_map_items:&lt;BR /&gt;found_it = False&lt;BR /&gt;wm = WebMap(item)&lt;BR /&gt;lyrs = wm.layers&lt;/P&gt;&lt;P&gt;for lyr in lyrs:&lt;BR /&gt;if hasattr(lyr, 'url') and lyr.url is not None:&lt;BR /&gt;if lyr_to_find in lyr.url:&lt;BR /&gt;found_it = True&lt;BR /&gt;break&lt;/P&gt;&lt;P&gt;if found_it:&lt;BR /&gt;maps_with_layer.append(item)&lt;/P&gt;&lt;P&gt;print(f"Found {len(maps_with_layer)} maps which contain the layer")&lt;BR /&gt;return maps_with_layer&lt;/P&gt;&lt;P&gt;# Parameters:&lt;BR /&gt;lyr_to_find = 'https://&amp;lt;domainurl&amp;gt;/&amp;lt;webadaptor&amp;gt;/rest/services/&amp;lt;nameoffeatureservice&amp;gt;/FeatureServer'&lt;BR /&gt;map_item_query = "Title:*"&lt;/P&gt;&lt;P&gt;# Get a list of web maps with the layer:&lt;BR /&gt;maps_with_layer = find_maps_with_layer(lyr_to_find, map_item_query)&lt;/P&gt;&lt;P&gt;# Print the titles of web maps containing the layer:&lt;BR /&gt;for item in maps_with_layer:&lt;BR /&gt;print(f'Web Map Title: {item.title}')&lt;/P&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="LukeSavage_0-1697218810966.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83070i58B38F38F6345386/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LukeSavage_0-1697218810966.png" alt="LukeSavage_0-1697218810966.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 17:40:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1337856#M9142</guid>
      <dc:creator>SavageTrimble</dc:creator>
      <dc:date>2023-10-13T17:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1535559#M10629</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/62939"&gt;@SavageTrimble&lt;/a&gt;!&amp;nbsp; I wonder if you have a version of this script with the indentation intact?&amp;nbsp; It looks like that was automatically removed by the site here.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 16:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1535559#M10629</guid>
      <dc:creator>ChrisPeak</dc:creator>
      <dc:date>2024-09-05T16:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get all maps that contain a feature layer - Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1665264#M11780</link>
      <description>&lt;P&gt;Does anyone know of existing updated versions of the admin scripts? The API version 2.4.2 has deprecated so many functions that most samples do not work.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 20:17:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-all-maps-that-contain-a-feature-layer-python/m-p/1665264#M11780</guid>
      <dc:creator>MBocek</dc:creator>
      <dc:date>2025-11-12T20:17:50Z</dc:date>
    </item>
  </channel>
</rss>

