Hi,
I had a tool before that let us do the popup configuration in an editor and then reload into the web map. This was really easy because the WebMap was just a simple dictionary and I just had to replace the ['operationalLayers'] for a file. This cannot be done in the newest API.
What I am trying to do instead is remove the layers and then re-add them. The issue is when trying to add the layer using WebMap.add_layer it does not allow it. I have copied the exact layer object from a Map and then tried to add and it does not allow, so I know it is not an issue with the json.
How do I create a layer that can be added using WebMap.add_layer from the definition json?
Here is a code sample that shows the issue adding layers. I use the identical definition to remove and works fine, try to add the same layer and it fails
web_map = arcgis.mapping.WebMap(web_map_item)
layers = []
layers.extend(web_map.layers)
for layer in layers:
web_map.remove_layer(layer)
for layer in layers:
web_map.add_layer(layer)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-55-3865d40b28c6> in <module>()
8
9 for layer in layers:
---> 10 web_map.add_layer(layer)
11
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\arcgis\mapping\_types.py in add_layer(self, layer, options)
339 else:
340 raise TypeError("Input layer should either be a Layer object or an Item object. To know the supported layer types, refer" +
--> 341 'to https://developers.arcgis.com/web-map-specification/objects/operationalLayers/')
342
343
TypeError: Input layer should either be a Layer object or an Item object. To know the supported layer types, referto https://developers.arcgis.com/web-map-specification/objects/operationalLayers/
Thanks
-Joe
Thanks,
-Joe