I posted this to the ArcGIS API for Python group, but it was suggested I try my chances here.
I am using the ArcGIS API for Python via Jupyter.
I have listed the layers for a map service using the "layers" property on an ArcGISMapService object.
(Sorry - forgot how to past code so it keeps formatting)
layers = web_map_obj.layers
for lyr in layers:
if lyr.layerType == 'ArcGISMapServiceLayer':
if 'layers' in lyr:
for l2 in lyr.layers:
print(" >>> "+str(l2.id))
I only get information for 2 layers out of 24. I'm sure this is the right map service, and the 2 layers that I get information for have the same id as they do in the full list I get when I directly check the map service in the portal. I've checked the json dump directly - only 2 layers are in it. It is most definitely incomplete.
Obviously, I could be making an error that I can't expect anyone here to diagnose, but I think there is something unusual going on here that someone might recognize as a common newbie mistake? Is this a common problem? Might the map service be corrupted? How would I check that? When I check the map service in the portal, I see all layers listed, and it works fine when it is loaded into a web map. Maybe the "layers" property on a web map object doesn't by default list all of the layers in the web map and I need to tell it to?
Bit of a Hail Mary here. Thank you for any help you may be able to provide.
Randy McGregor
I tried this on a different map service and got similar results - more than 2 layers were returned, but not nearly all the layers in the map service. Also, no layers that were returned had a "name" property, so I could only list them by id (which all layers did have).
I can get all layers if I access the actual map service (not the map image layer that the service feeds), but what I would like to do is list the map image layer as it is configured within the web map, so that I can batch configure popups.
If I access the map service, I get all layers and all fields for each layer, which is helpful, but not quite what I'm trying to do.
Thank you,
Randy McGregor