Select to view content in your preferred language

Adding an XY to a List using Arcade

952
11
04-18-2024 05:20 AM
APBlough
Emerging Contributor

I am trying to add an XY coordinate of the center of a polygon to the list. 

Currently I have a WebMap that is filtered using the dashboard and another tab of the WebApp so that they can find the project they need and then open the other tab and edit the attribute. 

As a way to help locate the project between he two map tabs, I want to add an XY to the list so it is easy to find the projects between the two maps.

I have another ID they should use to search but I wanted to figure out the arcade for the XY.

Any help would be amazing! 

-APB
0 Kudos
11 Replies
KenBuja
MVP Esteemed Contributor

You can use the Centroid function to get the center point for a polygon.

var thePoint = Centroid(Geometry($feature));
var output = `x: ${thePoint.x}, y: ${thePoint.y}`

 

APBlough
Emerging Contributor

Thank you, What do you think I have setup wrong?

 

APBlough_1-1713452074211.png

 

-APB
0 Kudos
KenBuja
MVP Esteemed Contributor

My code uses template literals , which uses the back tick (`) instead of the regular quote (').

0 Kudos
APBlough
Emerging Contributor

Yes, I am using regular single quotes (') here

-APB
0 Kudos
KenBuja
MVP Esteemed Contributor

If you use regular quotes, then the line would like this

var output = 'x: ' + thePoint.x + ', y: ' + thePoint.y
0 Kudos
APBlough
Emerging Contributor

Well dang, now I'm really confused. That's not structured anything like the original? 

-APB
0 Kudos
KenBuja
MVP Esteemed Contributor

Take a look at the page on template literals. The two examples I provided give the same output.

APBlough
Emerging Contributor

Oh, I'm sorry. I follow you. I thought I was to remove the back tick. I thought that was the wrong character because this it the output that I had with back ticks. 

"Unable to execute arcade script" 

APBlough_0-1713455483064.png

 

-APB
0 Kudos
KenBuja
MVP Esteemed Contributor

I had overlooked that the Geometry bundle is not available in the Dashboard list formatting profile, most likely for performance gains. I'm looking into a way to add that to your data as you load it into Dashboard

0 Kudos