I am looking to use the ArcGIS API for Python to enable popups for each layer in a webmap.
I found Configure Popup Attributes Programmatically with ArcGIS API for Python on GeoNet which addresses how to disable popups for each layer, but I am looking to do the opposite.
I have also asked Enable Popups for each layer in a webmap Enable Popups for each layer in a webmap using ArcGIS API for Python on GeoNet.
2 Answers 2
I made a simple web map to test this out. For some reason none of my layers had the 'popupInfo' property mentioned in that geonet post ... but setting the 'disablePopup' property to false on all layers worked for me.
import arcgis
import json
gis = arcgis.gis.GIS("https://arcgis.com", "username", "password")
item = gis.content.get("<item-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)
-
Thanks for your answer but unfortunately this does not work. Confirmed with ESRI that is not possible to enable popups with ArcGIS API for Python. There is currently an enhancement in the ArcGIS API for Python to offer this functionality.CLJ– CLJ2020年07月14日 19:13:45 +00:00Commented Jul 14, 2020 at 19:13
-
1Glad you got an answer from ESRI!Nick– Nick2020年07月15日 18:54:44 +00:00Commented Jul 15, 2020 at 18:54
-
Confirming that this does indeed work in arcgis api for Python version 2.3.0 (ArcPro version 3.3.1). Also see the ESRI Dev summit video here mediaspace.esri.com/media/t/1_g5kvew52Keggering– Keggering2025年05月27日 03:22:40 +00:00Commented May 27 at 3:22
This DOES work. Technically it's not using the ArcGIS Python API because you're editing the JSON directly (so ESRI was technically right), but you can update whether all popups are on or off programmatically.
Slightly modified code (no json import):
from arcgis.gis import GIS
gis = GIS("pro")
disablePopups = True
itm_id = "<youritemid>" # Replace w/your item ID
itm = gis.content.get(itm_id)
itmData = itm.get_data()
for opsl in itmData["operationalLayers"]:
opsl.update({'disablePopup':disablePopups})
itmProps = {"text": itmData}
itm.update(item_properties = itmProps)
Just tested this in ArcGIS Pro 2.9 notebook on webmap in Enterprise 10.8.1.
Explore related questions
See similar questions with these tags.