Hello everyone,
I am running this code, in ArcGIS Pro Notebook, to copy layers from one web map to another but it fails in the last lines.
Any advice?
gis = GIS("home")
# select Web Maps from item id
mapitem1 = gis.content.get('xxxxx')
display(mapitem1)
mapitem2 = gis.content.get('yyyyy')
display(mapitem2)
# get Web Map Objects
from arcgis.mapping import WebMap
wmo1 = WebMap(mapitem1)
wmo2 = WebMap(mapitem2)
# output operational layers
wmo1.definition['operationalLayers']
wmo2.definition['operationalLayers']
for layer in wmo1.definition.operationalLayers:
wmo2.definition.operationalLayers.append(layer)
for layer in wmo1.definition.operationalLayers:
wmo2.definition['operationalLayers'].append(layer)
Try with this:
for layer in wmo1.definition['operationalLayers']:
wmo2.definition['operationalLayers'].append(layer)
mapitem2.update({'text': wo2.definition})