I am trying to update an ArcGIS Notebook to use the 2.4 API version and am getting stuck on determining if a layer in a web map is a group layer. In the previous version of the API I used this method:
But in the new version of the API I'm not seeing a "layerType" property that I can use to do the same thing. I can see there's a Group Layer in my map by using content.layers (below), but I'm not sure how to do the same thing I was doing in the 2.3 version.
Solved! Go to Solution.
I'd use the JSON definition directly. See below...
from arcgis.gis import GIS
agol = GIS("home")
## return WebMap JSON definition as a dictionary.
wm_item = agol.content.get("WM_ITEM_ID")
for op_layer in wm_item.get_data()["operationalLayers"]:
if op_layer["layerType"] == "GroupLayer":
grouplayer_layers = op_layer["layers"]
for lyr in grouplayer_layers:
if lyr["itemId"] in search_layers:
...
This is pretty much what up to version 2.3.0 was doing except it had it nicely packaged using the WebMap class methods. 2.4.0 lacks as the MapContent class layers property returns a list of objects rather than the dictionary/JSON definition of the layer in the Map.
Hope that helps.
Glen
I'd use the JSON definition directly. See below...
from arcgis.gis import GIS
agol = GIS("home")
## return WebMap JSON definition as a dictionary.
wm_item = agol.content.get("WM_ITEM_ID")
for op_layer in wm_item.get_data()["operationalLayers"]:
if op_layer["layerType"] == "GroupLayer":
grouplayer_layers = op_layer["layers"]
for lyr in grouplayer_layers:
if lyr["itemId"] in search_layers:
...
This is pretty much what up to version 2.3.0 was doing except it had it nicely packaged using the WebMap class methods. 2.4.0 lacks as the MapContent class layers property returns a list of objects rather than the dictionary/JSON definition of the layer in the Map.
Hope that helps.
Glen
Thanks Glen! I'll give that method a try, it looks like it will do what I need.
Determining layer type seems like basic useful functionality and it's a shame it got axed in the new version.