AnsweredAssumed Answered

Update WebMap dictionary for multiple feature layers

Question asked by LANDVEST on Nov 4, 2019
Latest reply on Jan 30, 2020 by antti.kajanus_CGISuomi

There are several threads on here that have gotten me this far, but I've still not found any solid documentation about what needs to be supplied to the JSON dictionary in order to properly update it. Note: I can get this to work when there is only one layer in the feature layer/feature collection. I'm just stuck.


Here is my code so far.

#Import Modules
import copy,json
from arcgis.gis import GIS
from arcgis.mapping import WebMap

#Log into ArcGIS Enterprise
gis = GIS("", "DougMcGrave", "a1ntL!FeGr@nd!")
print("Logged in as: " +

#Retrieve NortheastFieldData web map
webMapSearch ="title: NortheastFieldData2",item_type = "Web Map")
sourceWebMap= webMapSearch[0]
#itemID =
#Read the web map as a WebMap object
webMapObject = WebMap(sourceWebMap)

#Create a copy of the web map with a new title
webmap_item_properties = {'title': 'TestCopyThis', 'snippet':'testcopydis', 'tags':'Test'}

#Retrieve new web map
newWebMapSearch ="title: TestCopyThis",item_type = "Web Map")
newWebMap = newWebMapSearch[0]

for layer in newWebMap.layers:

#Extract JSON from webmap
pubMapJson = newWebMap.get_data(try_json=True)
jsonCopy = copy.deepcopy(pubMapJson)

#Layers in web map which need filter applied
layersList = ['NortheastCruisePoints','NortheastClientsCollector - NortheastPoints','NortheastClientsCollector - NortheastPoints','NortheastClientsCollector - NortheastLines','NortheastClientsCollector - NortheastStands','NortheastClientsCollector - Harvest Operations Status']

#Filter to be applied
lyrFilter = "LVI_CODE = '{0}'".format("7532")
#Extract JSON from webmap and create a copy
pubMapJson = newWebMap.get_data(try_json=True)
jsonCopy = copy.deepcopy(pubMapJson)

#Loop through each layer
for lyr in layersList:
        if 'layerDefinition' in lyr:
#Update JSON

No errors are given and the JSON update returns 'True'