Is the geometry object available in Arcade expressions with Map Image Layers?

795
1
12-12-2018 08:12 AM
KurtisGagne1
New Contributor II

I'm using ArcGIS Enterprise 10.6.1 with ArcGIS Portal 10.6.1 with data in SQL Server 2014.

I've been attempting to build a popup in an ArcGIS Portal map with a custom attribute expression written in Arcade to calculate X and Y from the Geometry object.

However it seems like the Arcade geometry object is Null in all Map Image Layers (these are dynamically drawn and the data is stored in an enterprise geodatabase).

On a dynamically drawn Map Image Layer, 'Text($feature)' returns:

{"geometry":null,"attributes":{"Elevation":366.27200317,"GlobalID":"{E132538C-B97D-4464-873B-026D434A93F4}","Layer":"Fire_Hydrant","OBJECTID":1,"POINT_X":426693.043,"POINT_Y":5410332.5313,"Utility_Type":1}}

I do have fields for the X and Y however they are not dynamic when the points moves which is why I want to calculate from the geometry of the point.

On a Feature Layer, 'Text($feature)' returns:

{"geometry":{"x":426693.0429999996,"y":5410332.531300001,"spatialReference":{"latestWkid":26915,"wkid":26915}},"attributes":{"Elevation":366.27200317,"GlobalID":"{E132538C-B97D-4464-873B-026D434A93F4}","Layer":"Fire_Hydrant","OBJECTID":1,"POINT_X":426693.043,"POINT_Y":5410332.5313,"Utility_Type":1}}

There's no mention of this limitation in the documentation that I can find. If it truly isn't supported in Map Image Layers that throws a wrench in my plans. I can understand tiled map image services not supporting this, but i really think it should work in dynamic ones that support Query operations.

Anyone have the same issue or any work arounds? I'm thinking about filing a bug report/feature request.

1 Reply
XanderBakker
Esri Esteemed Contributor

I just did a little test by throwing this code into the ArcGIS Arcade | ArcGIS for Developers  playground:

var info = {"geometry":null,"attributes":{"Elevation":366.27200317,"GlobalID":"{E132538C-B97D-4464-873B-026D434A93F4}","Layer":"Fire_Hydrant","OBJECTID":1,"POINT_X":426693.043,"POINT_Y":5410332.5313,"Utility_Type":1}};
var atts = info.attributes;

var x = atts.POINT_X;
var y = atts.POINT_Y;

var pnt_json = {"x" : x, "y" : y, "spatialReference" : {"wkid" : 26915}};
var pnt = Point(pnt_json);
Console(pnt);
return pnt

... thinking that if you can have access to the X and Y values since they are attributes, you can construct a geometry from it. However, it seems to need WGS1984 coords to be able to do this:

Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference.

0 Kudos