I'll try to start simple and add detail if necessary, but my question is general - "Layers" in the ArcGIS API for Python refers to so many things, I need a way to discern what kind of layer I've got in any situation, so that I know what properties are available.
I need to list layers in web maps. ArcGISMapServiceLayer, which can be grouped, is a troublemaker, because of sublayers and groups (each of which is a 'layer.'). I need to check whether or not I am at a group layer, and therefore need to keep "going down" before I can interrogate the layer for its popupInfo, field name, etc...
I can use json, but I'm wondering if there is a more direct way. Can I check for a property without directly loading in the JSON?
if lyr.layerType == 'ArcGISMapServiceLayer':
l1_json = json.loads(str(lyr))
if l1_json.get('layers'):
...
...
ie. if lyr.layers is None or something? I've tried this and had no luck.
Thank you for your time,
Randy McGregor
Actually, you can interrogate the objects directly. This works:
if 'layers' in lyr:
Do something
else:
Do something els
No need to load the json for this particular check.