You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
fromarcgis.gisimportGISfromarcgis.mapimportMapfromarcgis.map.popupsimportPopupExpressionInfofromarcgis.map.popupsimportFieldInfoagol=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 fieldInfosfield_infos=webmap.content.popup(index=2).info.field_infos## append new fieldInfofield_infos.append(add_field_info)
## get current expressionInfosexpression_infos=webmap.content.popup(index=2).info.expression_infos## append new expressionInfoifexpression_infos:
expression_infos.append(add_expression_info)
else:
expression_infos= [add_expression_info]
## edit and updatewebmap.content.popup(index=2).edit(
expression_infos=expression_infos,
field_infos=field_infos
)
webmap.update()
error:
No error in Python, see screenshot Screenshots
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
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.
The text was updated successfully, but these errors were encountered:
@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?
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.
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:
error:
No error in Python, see screenshot
Screenshots
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
Expected behavior
Needs to be a mechanism to add in name for PopupExpressionInfo
Platform (please complete the following information):
Additional context
Add any other context about the problem here, attachments etc.
The text was updated successfully, but these errors were encountered: