Dear All,
Is it possible to Enable popup in Web Map using ArcGIS API for Python?
Thanks,
Krish
It's possible, but not directly through the Python API. You'd want to get the web map JSON, modify it to your liking, and use the item.update() function from the API to apply the changes. More on this below:
Configure Popup Attributes Programmatically with ArcGIS API for Python
Hi Krish V
Here's the code to enable popups of layers in a webmap using ArcGIS API for Python:
from arcgis.mapping import WebMap
import json
item = gis.content.get("webmap id")
item_data = item.get_data()
layers = item_data['operationalLayers']
for layer in layers:
layer.update({'disablePopup':False})
item_properties = {"text": json.dumps(item_data)}
item.update(item_properties=item_properties)
web_map = WebMap(item)
web_map
Hi Mehdi Pira,
The code you provided is running successfully but It doesn't change anything in the webmap.
Thanks,
Krish
Krish V,
I reckon there is a bug in ArcGIS API for Python at the moment for enabling popups when a layer first time is added to a webmap.
To do a workaround, I just found out that you need to first enable popups manually and save the web map. Then when you run the code with
layer.update({'disablePopup':True})
which makes all popups disabled. After that, set 'disablePopup' to False and run the code again. This fixes the enabling and disabling popups via the code.
Hi Mehdi Pira,
I have the same issues as Krish V. You recommended manually enabling the pop-ups first, but in our project we need to do this 400+ times, so this is not a very sustainable workflow. Has there been s solution developed that allows you to do this programmatically?
Thank you, Maria