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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 17, 2020 at 15:27

2 Answers 2

4
+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)
answered Jun 19, 2020 at 19:51
3
  • 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. Commented Jul 14, 2020 at 19:13
  • 1
    Glad you got an answer from ESRI! Commented 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_g5kvew52 Commented May 27 at 3:22
1

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.

answered Mar 18, 2022 at 20:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.