Hello. I am attempting to clone a Web Map in AGOL for each jurisdiction in the state, and then add a layer to that map based on the jurisdiction. I am successful in the first portion of this, but despite not having any error codes, the web maps produced do not contain the layer I am trying to add. I am guessing that there is something funky with the format of my Web Map, but since I'm not getting an error to go off of, I'm not sure where I'm going wrong.
webmapJSON = map_item.get_data()
for layer in webmapJSON['operationalLayers']:
display(layer)
web_map_dict = map_item.get_data(try_json=True)
for index, county in enumerate(counties):
county_name = counties.features[index].attributes['NAME']
print(county_name)
title = "UCIP_Test_" + county_name + "_AddLayers4"
web_map_properties = {'title': title,
'type':'Web Map',
'snippet':'This web map copied from template',
'tags':'ArcGIS Python API PC Test',
'text':json.dumps(web_map_dict)}
web_map_item = gis.content.add(web_map_properties)
ucipMap = WebMap(web_map_item)
layer_search = gis.content.search(query = "UCIP_" + county_name + "_County_View")
layer = layer_search[0]
print(layer)
ucipMap = ucipMap.add_layer(layer, options={'title': county_name + "View"})The print functions return the correct county/layer pairs, so the problem is not in finding the layer, and the WebMaps show up in AGOL with appropriate names, but they don't have the "layer" that I'm trying to add.