5

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

3
+250

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)

2
  • 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
    Jul 14, 2020 at 19:13
  • 1
    Glad you got an answer from ESRI!
    – Nick
    Jul 15, 2020 at 18:54
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.