I’m trying to create what is essentially a Polyline, but using Billboards, in 2D mode.

This might seem silly, but I absolutely must have control over Z-order of lines, labels, and other entities on the map, and Polyline doesn’t allow me to do that.

I’m facing 2 challenges:

- Position the line.

Given 2 points, I need the middle point, in 2D, ignoring Earth’s curvature, like the Polyline ArcType.None.

I got that to work by getting the screen-space positions of waypoint billboards, calculating the middle point, then using pick to get the coordinate.

This is not a good solution, as it requires 2 billboards positioned on either side of the “line” beforehand.

- Length.

The line isn’t the correct length, shorter than it’s supposed to be, with the error increasing with distance and rotation.

Looks like some distortion that is the result of Earth’s curvature, so I need another way to calculate it.

In the billboard:

```
sizeInMeters: true,
height: Helpers.GetLengthBetweenPoints(p1, p2),
```

The length function:

```
public static GetLengthBetweenPoints(p1: Vector3D, p2: Vector3D) {
const geodesic = new cz.EllipsoidGeodesic();
geodesic.setEndPoints(p1.cartographic, p2.cartographic);
return geodesic.surfaceDistance;
}
```

Vector3D is my own class, with “cartographic” returning the coordinate the way Cesium wants them, in Radians.

A picture of the current state: