I'm starting to learn a bit of Arcade but very new to it, and looking at creating an attribute expression to create a short cut link in my pop up to my companies video survey which the URL uses x and y.
I have managed to correctly enable this for point features using the below:
var PointGeometry = Geometry($feature);
var ArcadeX = PointGeometry.x;
var ArcadeY = PointGeometry.y;
but I would like to use it for Polyline, by getting the start point x and y, can anyone help please?
Solved! Go to Solution.
If you look at the the contents of a polyline, you see this:
{"spatialReference":{"latestWkid":3857,"wkid":102100},"paths":[[[-9834291.023,5119236.579900004],...,[-9834888.189,5118479.376900002]]]}
So we can just use .paths on our feature to get the array, and then grab the first point of the first line.
var first_point = Point(First(Geometry($feature).paths[0]))
return `first vertex x: ${first_point.x}, y: ${first_point.y}`
If you look at the the contents of a polyline, you see this:
{"spatialReference":{"latestWkid":3857,"wkid":102100},"paths":[[[-9834291.023,5119236.579900004],...,[-9834888.189,5118479.376900002]]]}
So we can just use .paths on our feature to get the array, and then grab the first point of the first line.
var first_point = Point(First(Geometry($feature).paths[0]))
return `first vertex x: ${first_point.x}, y: ${first_point.y}`
This worked perfectly, thank you!
Related: Idea - Arcade Endpoint() function
I seem to recall saving Arcade expressions at an organizational level is on the roadmap, right? I wonder if that could open the door something like org-wide custom functions, to just define our own Endpoint function and reuse it, rather than holding our breath on the next Arcade update.