Select to view content in your preferred language

A way to track all the maps a layer is used in

3142
14
08-09-2022 05:33 AM
Status: Open
Savannah2019
New Contributor III

Much like when you open the details page of a map and can view at a glance all the layers within that map, it would be very helpful to open a feature layer's details page and view all the maps/scenes that layer has been put in. 

Several times my organization's team has wanted to delete a layer, thinking it's not used in anything, only to find out the opposite after searching through every single map we have or after we get a call from someone saying a map isn't loading properly. Either way, the process is tedious and frustrating. We experiment a lot with different ideas, so not all layers get used and we need to clean them out eventually. It'd be lovely if we could just open a layer and see a list of everywhere that layer is being used. 

14 Comments
RobinDiSalvo1

Great question Savannah!  Following this as I would like to know the answer to this too.  I have deleted layers not realizing they were connected to other maps 😞

 

Robin

jcarlson

This is one of the Community's "greatest hits". You'll find various versions of the idea all over here.

I agree that this would be a nice feature to have built into AGOL, but for the time being, you can still accomplish this using the Python API in a hosted Notebook.

Here's a notebook I use to search for dependencies, both maps and apps:

https://kendall.maps.arcgis.com/home/notebook/notebook.html?id=2967bae3767640038a6841714784d44c

 

Savannah2019

@jcarlson Unfortunately, your link isn't public, so I can't access it 😞

jcarlson

Hmmm. I thought I shared it publicly, I'm sorry. Try again?

ClayDonaldsonSWCA

here is the working link: 

https://arcgis.com/home/notebook/notebook.html?id=2967bae3767640038a6841714784d44c

 

when sharing public items you have to remove your org prefix (i.e remove kendall.maps) the link worked fine!

COSPNWGuy

@ClayDonaldsonSWCA@jcarlson, - When I try clicking on the link, I get the following:

PNWGuy_0-1660064526802.png

I think it is because I don't have hosted notebooks. Is there anyway you can export it and share the python code or share as a .ipynb file here?

Savannah2019

@jcarlson @ClayDonaldsonSWCA Thank you, I am able to access it now. This will be a great help, thank you!

COSPNWGuy

Would anyone be willing to share that notebook? As mentioned, I don't have hosted notebooks and the link doesn't work for me.

Also, a way to implement this idea is through ArcGIS Knowledge. Please upvote my ideas if interested below (same idea but on each product idea boards):

Out-of-the box Knowledge Graphs of Enterprise and ArcGIS Online Content and Relationships 

Out-of-the-box Knowledge Graphs of Enterprise Content and Relationships 

Out-of-the box Knowledge Graphs for ArcGIS Online Content and Relationships 

 

jcarlson

@COSPNWGuy  Sounds like an org-level setting. Looks like .ipynb files aren't supported, at least here in the Ideas comments.

Here's the code, minus all the nice markdown cells that explain things.

from arcgis.gis import GIS
import pandas as pd

gis = GIS("home")

find_id = input('ItemID: ')

find_url = gis.content.get(find_id).url if find_id else input('Service URL: ')
print(find_url)

webmaps = gis.content.search('', item_type='Web Map', max_items=-1)

map_list = [m for m in webmaps if str(m.get_data()).find(find_url) > -1]

apptypes = ['Application', 'Dashboard', 'Story Map', 'Web Experience']

webapps = [item for sublist in [gis.content.search('', item_type=t, max_items=-1) for t in apptypes] for item in sublist]

app_list = []

for w in webapps:
    
    try:
        wdata = str(w.get_data())

        criteria = [
            wdata.find(find_url) > -1,
            wdata.find(find_id) > -1,
            any([wdata.find(m.id) > -1 for m in map_list])
        ]
        
        if any(criteria):
            app_list.append(w)
    
    # Some apps don't have data, so we'll just skip them if they throw a TypeError
    except:
        continue

dependencies = pd.concat(
    [
        pd.DataFrame([{'title':a.title, 'id':a.id, 'type':a.type, 'url':f'{gis.url}/home/item.html?id={a.id}'} for a in app_list]),
        pd.DataFrame([{'title':m.title, 'id':m.id, 'type':m.type, 'url':f'{gis.url}/home/item.html?id={m.id}'} for m in map_list])
    ]
)

# do something with the dependencies dataframe
COSPNWGuy

Thanks @jcarlson.!! Yeah, I'm not sure why our system admins don't have hosted notebooks enabled (I'll ask now!).