Enable popup in Web Map

2194
5
09-14-2020 07:37 AM
KrishV
by
Occasional Contributor III

Dear All,

Is it possible to Enable popup in Web Map using ArcGIS API for Python?

   

Thanks,

Krish

Tags (1)
0 Kudos
5 Replies
GeoJosh
Esri Regular Contributor

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 

popupInfo | ArcGIS for Developers 

arcgis.mapping module — arcgis 1.8.2 documentation 

MehdiPira1
Esri Contributor

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
KrishV
by
Occasional Contributor III

Hi Mehdi Pira,

The code you provided is running successfully but It doesn't change anything in the webmap.

Thanks,

Krish

0 Kudos
MehdiPira1
Esri Contributor

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. 

by Anonymous User
Not applicable

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

0 Kudos