Remove/Add hosted tile layer from Webmap

224
0
01-08-2024 06:47 AM
Rahul_Pandia
New Contributor II

I have a webmap in which Hosted tile layer needs to be updated with new hosted tile layer.
I need to use arcgis api for python only.
I was trying to use(not working):

gis.content.replace_service(item_name, vtpk_service_item.id)

Then I tried:
tile_layers = [layer for layer in web_map_obj.layers if "_VectorTile_" in str(layer.title)]
for layer in tile_layers:
    web_map_obj.remove_layer(layer)

Followed by:

EHPLyr=gis.content.get("ID_of_HOSTED_TILE_LAYER")
web_map_obj.add_layer(EHPLyr)
item_properties_dict = {"title": "aaa","tags": ["HostedTiledLayer"],"snippet":"", "description":_summary}
web_map_obj.save(item_properties = item_properties_dict)

The above code is also not working.
Any idea how to go about it?

 

Tags (1)
0 Replies