Is there a simple way to export the layer list from a web map (built with WAB) to a text file?
open the feature service in arcmap (in catalog you will see an option for feature services, then use arcpy to list the layers
Is there a way to do this for all services at once? Thanks!
Do you have access to ArcGIS Pro or ArcGIS Notebook (in AGOL or enterprise)? If so this can be done using the ArcGIS API for Python pretty easily!
Yes, I have both of those. Any help is appreciated!! Thank you!
Easy then!
from arcgis.gis import GIS
from arcgis.mapping import WebMap
gis = GIS('pro')# if running this from Notebook for ArcGIS in AGOL/Enterprise, replace this line with gis = GIS('home')
wmItemId = "" #put the id of the webmap in here
wmItem = gis.content.get(wmItemId)
wm = WebMap(wmItem)
for lyr in wm.layers:
print(lyr.title)
I wrote that to be run from the Python window in Pro, but see my note in line 3 about using it in ArcGIS Notebook. Just put the ID of the web map item into line 4 and it should print out all the layers for the given webmap.
Thank you so much!!
Glad to help out!
Hi,
I took your script and tried adding in a lyr.url to get the url of the layers and it worked but sometimes it comes up with an exception saying "layer" instance has no attribute 'url' and I was wondering if you know what I can do to put an exception in there. Thanks!
Hi Kayden, sorry for the delay, didn't see your message until now. I've had this issue in the past with vector tile layers (possibly from the basemap?) as they have an attribute called "styleUrl" instead of "url", which you could handle with some code like this:
if layer['layerType'] == "VectorTileLayer":
print(layer.styleUrl)
else:
print(layer.url)