Select to view content in your preferred language

Arcade Expression for Geometry in ArcGIS Online Popup

15853
18
07-31-2017 08:44 AM
MaryEllen_Perko
Occasional Contributor II

Hi.  In ArcGIS Online using the web map Attribute Expressions builder, I'm trying to pull feature xy coordinates to show in a popup.  In the builder, my code successfully tests with a value; but the value in the popup and layer table is empty.  I'm using a map service if that matters.

So, is this code supposed to work?  Or am I doing something wrong?  

Thanks.

18 Replies
XanderBakker
Esri Esteemed Contributor

Not sure what might be going wrong in your case. I just configured something similar and it works. 

I entered the pop-up settings and added two expressions:

and the result is displayed:

KenBuja
MVP Esteemed Contributor

This function seems to work properly.

Text(Geometry($feature).x);

and returns this in the popup

Have you checked the popup configuration to see if it's displaying the custom expression?

MaryEllen_Perko
Occasional Contributor II

Thanks for the help so far.  Are you using map services or feature layers/services?

Thanks.

0 Kudos
XanderBakker
Esri Esteemed Contributor

I used a hosted feature service.

0 Kudos
KenBuja
MVP Esteemed Contributor

I also tried this using this map service: Hurricanes (MapServer)

It worked as well.

MaryEllen_Perko
Occasional Contributor II

Thanks everyone for the help so far.  I do see the code works with map services.  The field in the table won't always populate (for me anyway) so I didn't catch that it worked in the popup.

I think the problem is with the map service I started with.  I haven't figure out why, yet, but it appears that the "point" feature-type layer loaded via the map service is really a "multipoint" layer/feature class.  For some reason the point-related arcade expression code works with the layer in the expression builder, but perhaps not outside of the builder.   I'm looking more closely at our map service and the map viewer.

If anyone would like to take a closer look, here's the map service: NCDOT_STIP (MapServer) 

Thanks again.  I really appreciate the help.

0 Kudos
XanderBakker
Esri Esteemed Contributor

For multipoint geometry you may want to try this:

return Round(Geometry($feature).points[0].X, 2)

and:

return Round(Geometry($feature).points[0].Y, 2)

... since it is a collection of points although each multipoint only has a single point (as far as I could see from a query on your REST service) 

AdministraciónSIG
New Contributor II

How can i get de X and Y point from my feature in the coordenate system from the rest url?

 

I need to create a custom expression to put it on the popup window with this info.

the Geoametry function retorns  only in web mercator. 

XanderBakker
Esri Esteemed Contributor

In case you need the coordinates in WGS 1984, I have a couple of posts that show an example of how you can convert Web Mercator coords to WGS 1984. This might be useful in case you need to create a hyperlink to Streetview or Waze or send the coordinates to prefill a Survey123 form.

Examples (in Spanish) can be found here: