Create a Label at the Start or End node of a line?

730
8
04-06-2022 11:17 AM
Labels (2)
paulbehnke
New Contributor II

Is there a way to create an Arcade expression that would label at the start and/or end node of a line?

Perhaps using the Extent or Geometry feature?

0 Kudos
8 Replies
Bud
by
Notable Contributor

I don't have any experience with Arcade labelling, but this post might be helpful:

Arcade: Get endpoint coordinates of multi-part polyline

0 Kudos
paulbehnke
New Contributor II

Thank you, Bud. This seems to be exactly what I am looking for, at the very least on the right track. I will have to tinker with it to see if I can use it to label.

BillFox
MVP Frequent Contributor

Is this for something like a sewer line that has attributes for the from elevation and to elevation and you want to label on the line accordingly?

Also, are you using the arrow head at start or end or middle?

0 Kudos
paulbehnke
New Contributor II

Yes, Bill. This is exactly what I was hoping to do, label the elevations at the start & end nodes of a pipe.

Regarding arrows, I've so far only tinkered with the available, 'out-of-the-box' arrow symbols available in AGOL and wasn't very pleased so I will be looking into other solutions for that as well. 

0 Kudos
RussRoberts
Esri Notable Contributor

Labeling in the 4.x JSAPI  for FeatureLayer Polylines currently only supports center-along label placement in 2D MapViews.

0 Kudos
NLBVDS
by
New Contributor

@paulbehnke Did you manage in the end? I'm curious to your solution as I'm trying to achieve something similar. 

@RussRoberts Will this label option be implemented in the future? 

0 Kudos
RussRoberts
Esri Notable Contributor

It is planned to support more label positions in the API which will expand the support to the web apps we offer. I dont have an exact release date for this at this time. 

0 Kudos
paulbehnke
New Contributor II

From what I understand the ability to label at the start or end of a line is in the works... there is code for it but it just doesn't work right now for 2D:

LabelClass | API Reference | ArcGIS API for JavaScript 4.23 | ArcGIS Developer

I did receive this python code from ESRI Support but not have had a chance to fiddle with it yet:

"I hope you are doing well. This is Miranda from Esri Support Services. 

One of our Python SMEs was able to create a code sample that would return the vertices of polyline features. See below for reference:
 

 var polyline_fs = FeatureSetByPortalItem(

    Portal("https://arcgis.com"),

    "d3be1a01d9034fe485a8163ce51948ef",    0,    [],    True);

var polyline_coords = {};

for (var f in polyline_fs) {

    var paths = First(Geometry(f).paths);    Console(paths);

    var pnts = [];

    var index = 0;

    for (var i in paths) {

        Console(i);

        var coords = paths[i];

        Console(coords);

        pnts[index] = {"x": coords.x, "y": coords.y};

        index++;

    }

    polyline_coords[Text(f.OBJECTID)] = pnts;

}

 // output is a dictionary with OBJECTIDs as keys and arrays containing vertice coordinates as values

// (vertice coordinates are saved as dictionaries within the arrays)

Console(polyline_coords);

return polyline_coords;

0 Kudos