Good morning,
I am looking for a way to find AGOL web maps using a specific layer located in AGOL too.
Is there a tool for that?
Thanks
There are third party applications and custom code (like Nick's) that can accomplish this, but nothing out of the box. It is something the ArcGIS Online product team is looking into, but we don't have anything to announce at the moment.
I have spent sometime curating this, it is not perfect but is does provide some results. I recommend looking through this first before running it. Add your feature layer name in the " " and then you run it. It should print out all the maps and maps Id's the layer is in.
from arcgis.gis import GIS import pandas as pd # Connect to ArcGIS Online gis = GIS("home") # Specify the name of your hosted feature layer feature_layer_name = "Feature_Layer_Name_Here" # Search for the feature layer item by name search_results = gis.content.search(query=f'title:"{feature_layer_name}" AND owner:{gis.users.me.username}', item_type="Feature Layer") # Check if the search returned any results if not search_results: print( f"Error: Could not find a feature layer with the name '{feature_layer_name}'. Please check the name and try again.") else: # Get the feature layer item feature_layer_item = search_results[0] # Print the details of the found item print(f"Found feature layer: {feature_layer_item.title}") print(f"Item ID: {feature_layer_item.id}") print(f"Item URL: {feature_layer_item.url}") # Function to search and count maps def search_and_count_maps(feature_layer_item): # Search for all web maps in the organization web_maps = gis.content.search(query='type:"Web Map"', max_items=1000) # Initialize counter and list for maps that include the feature layer map_count = 0 map_list = [] # Iterate through each web map and inspect its layers for web_map in web_maps: try: map_data = web_map.get_data() if 'operationalLayers' in map_data: for layer in map_data['operationalLayers']: if 'url' in layer and feature_layer_item.url in layer['url']: map_count += 1 map_list.append({ 'Map Title': web_map.title, 'Map ID': web_map.id }) break # No need to check other layers in this map except: continue # In case of an error, skip this map and continue with the next one return map_count, map_list # Count the maps and get list of maps map_count, map_list = search_and_count_maps(feature_layer_item) # Print the result print(f"The feature layer is included in {map_count} web maps.") # Optionally, create a DataFrame to store more detailed information if map_list: df = pd.DataFrame(map_list) print("\nList of Maps:") print(df.to_string(index=False)) else: print("No maps found for this feature layer.")
I can loosely think of a way abusing/using the CIM & Portal access that might work if you have a known list of web maps to check (i.e., those in your organization). Essentially, you'd review each and every layer in each and every map, and check its source against the AGOL layer you're checking. It would work for offline data, and in theory, it might work for AGOL data, but it'll be a bit of a mess to write.
If you're needing to look outside that organization, though, the above trick won't work. For that, I think we'd need a tool from ESRI's side of things, and I'm not familiar with an existing one off the top of my head.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.