Skip to content

PopupExpressionInfo object needs a "name" property to match up with the entry in the fieldInfos #2297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Clubdebambos opened this issue May 26, 2025 · 2 comments
Labels

Comments

@Clubdebambos
Copy link

Describe the bug
I was adding a PopupExpressionInfo to a layer popup which needs two steps to enable expressions to work correctly. The first is to create the entry in the expressionInfo list, and the second is to add the expression to the fieldInfos list. The expressionInfo requires 4 properties - name, title, expression, and returnType. The PopupExpressionInfo object does not cater for name.

To Reproduce
Steps to reproduce the behavior:

from arcgis.gis import GIS
from arcgis.map import Map
from arcgis.map.popups import PopupExpressionInfo
from arcgis.map.popups import FieldInfo

agol = GIS("home")

wm_item = agol.content.get("WM_ITEM_ID")

webmap = Map(wm_item)

add_expression_info = PopupExpressionInfo(
    title = "Google Streetview",
    expression = "var PointGeometry = Centroid(Geometry($feature));\nvar ArcadeX = PointGeometry.x;\nvar ArcadeY = PointGeometry.y;\nvar ArcadeSr = PointGeometry.spatialReference.wkid;\nvar Latitude, Longitude;\n\nfunction AuxSphereToLatLon(x, y) {\n  Console(\"Converting...\");\n  // Conversion based on http://dotnetfollower.com/wordpress/2011/07/javascript-how-to-convert-mercator-sphere-coordinates-to-latitude-and-longitude/\n  var rMajor = 6378137;\n  var shift = PI * rMajor;\n  Longitude = x / shift * 180.0;\n  Latitude = y / shift * 180.0;\n  Latitude = 180 / PI * (2 * Atan(Exp(Latitude * PI / 180.0)) - PI / 2.0);\n}\n\nif (ArcadeSr == 4326) {\n  Console(\"4326 Spatial Reference - No Conversion Necessary\");\n  Latitude = ArcadeY;\n  Longitude = ArcadeX;\n} else if (ArcadeSr == 102100) {\n  Console(\"102100 Spatial Reference - Conversion Necessary\");\n  AuxSphereToLatLon(ArcadeX, ArcadeY);\n} else {\n  Console(ArcadeSr + \" Spatial Reference is not supported - currently works with Web Maps where the basemap is in WGS84 (4326) or Web Mercator Auxiliary Sphere 102100\");}\n  \n  var url = \"http://maps.google.com/maps?q=&layer=c&cbll=\" + text(Latitude) + \",\" + text(Longitude);\n  \n  return url;",
    return_type = "string",
    name = "expr0"
)

add_field_info = FieldInfo(
    field_name = "expression/expr0",
    is_editable = True,
    visible = True
)

## get current fieldInfos
field_infos = webmap.content.popup(index=2).info.field_infos

## append new fieldInfo
field_infos.append(add_field_info)

## get current expressionInfos
expression_infos = webmap.content.popup(index=2).info.expression_infos

## append new expressionInfo
if expression_infos:
    expression_infos.append(add_expression_info)
else:
    expression_infos = [add_expression_info]

## edit and update
webmap.content.popup(index=2).edit(
    expression_infos = expression_infos,
    field_infos = field_infos
)

webmap.update()

error:
No error in Python, see screenshot
Screenshots

Image

If I add in the name = "expr0" to the expressionInfo entry via REST/JSON, it works just fine as it matches expression/expr0 in the fieldInfos entry

Image

Image

Expected behavior
Needs to be a mechanism to add in name for PopupExpressionInfo

Platform (please complete the following information):

  • OS: Windows 11 Home
  • Browser Chrome
  • Python API Version 2.4.0

Additional context
Add any other context about the problem here, attachments etc.

@nanaeaubry
Copy link
Contributor

nanaeaubry commented May 27, 2025

@Clubdebambos Thanks for reporting this... it seems there is a mismatch between the webmap spec and the functionality so I will investigate this with the JS team. (edit: checked and it does need to be added so will add and logged and issue with them as well for their schema)

It also seems that the two steps are quiet tedious and we could look into enhancing this method by adding the expression info (or other edits) straight into the field info? Thoughts on this?

@Clubdebambos
Copy link
Author

Hi @nanaeaubry, it would be a good addition to cater for both at once. If you are creating an expression you are more than likely going to want to use it so it should automatically get added to the field infos, the user can then decide to keep it visible or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants