Dear All,
Is it possible to Enable popup in Web Map using ArcGIS API for Python?
Thanks,
Krish
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
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<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>update<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">{</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;">'disablePopup'</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">:</SPAN><SPAN class="" style="color: #990000; border: 0px; font-weight: inherit;">True</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">}</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
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.
The code you provided is running successfully but It doesn't change anything in the webmap.
Hi Krish V
Here's the code to enable popups of layers in a webmap using ArcGIS API for Python:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>mapping <SPAN class="keyword token">import</SPAN> WebMap <SPAN class="keyword token">import</SPAN> json item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"webmap id"</SPAN><SPAN class="punctuation token">)</SPAN> item_data <SPAN class="operator token">=</SPAN> item<SPAN class="punctuation token">.</SPAN>get_data<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> layers <SPAN class="operator token">=</SPAN> item_data<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> layer <SPAN class="keyword token">in</SPAN> layers<SPAN class="punctuation token">:</SPAN> layer<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'disablePopup'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> item_properties <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">"text"</SPAN><SPAN class="punctuation token">:</SPAN> json<SPAN class="punctuation token">.</SPAN>dumps<SPAN class="punctuation token">(</SPAN>item_data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN> item<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN>item_properties<SPAN class="operator token">=</SPAN>item_properties<SPAN class="punctuation token">)</SPAN> web_map <SPAN class="operator token">=</SPAN> WebMap<SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">)</SPAN> web_map<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.