The ArcGIS API for Python version 2.4.0 came in at ArcGIS pro 3.4 and there were some sweeping changes. Most notably, the removal of the WebMap class for the Map class. The way we interact with the WebMap changed significantly. In order to add or remove layers/tables from the WebMap we now create a Map object and access the content property which is a MapContent object and then we have methods such as add() and remove().
When you use a method to alter a WebMap, you need to call the update() method on the Map object.
map_obj.update()
However, if you have a table or tables in your WebMap, calling the update() method can cause all or one of the tables to become "corrupt". The Table type switches to a SubtypeGroupTable rather than a Table.
Pre-update...
Post-update...
You cannot access the table when you open the WebMap, when you go to the tables tab it will state that an error occurred loading this table.
This has been to my detriment. Buuuut, there is a fix! You just need to manipulate the WebMap definition after your update() call - see the video above.
Note! This issue should be fixed in newer versions after 2.4.0. So hopefully you can skip over it.
Here's the code snippet...
from arcgis.gis import GIS
agol = GIS("home")
wm_item = agol.content.get("WM_ITEM_ID")
wm_item_data = wm_item.get_data()
if "tables" in wm_item_data:
for table in wm_item_data["tables"]:
if "layerType" in table:
del table["layerType"]
wm_item.update(item_properties={"text":wm_item_data})
################################################################################
print("\nSCRIPT COMPLETE")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.