Creating custom pop-up attribute expressions using ArcGIS API for Python

620
0
05-26-2020 02:59 PM
GordonD
New Contributor

I'm trying to use python to create a custom pop-up attribute expression in an ArcGIS Online Web Map, but I'm running into some issues. 

Here is the python code I am running in an ArcGIS Pro Notebook:

import arcgis

#Connect to ArcGIS Online using active portal in ArcGIS Pro
gis = arcgis.gis.GIS("pro")

#Get web map, and create a custom attribute expression 
wm_item = gis.content.get("84a22dc69c57437d97292a12f05cf4d7")
wm_object = arcgis.mapping.WebMap(wm_item)
wm_object.layers[0].popupInfo.expressionInfos = [{
  "name": "expr1",
  "title": "test",
  "expression": "'test'",
  "returnType": "text"
}]
#Update web map
wm_object.update()
#Check to see if web map updated
wm_object.layers[0].popupInfo.expressionInfos

The code appears to be working correctly, as I can see the expression I created when I open the web map's "configure pop-up" settings in a web browser:

However, when I click on a feature in the web map, the custom attribute I created is no where to be found: 

Anyone know how to fix this?

0 Replies