Adding polylines dynamically

I am trying to add polylines to the map dynamically. Meaning, having a global polylineCollection() object and just adding new polylines to it at the user's request. However, each time I add a new polyline, the old one disappears (only one polyline is on the map at a time). My code is below:

global variable:
var polylines = new Cesium.PolylineCollection();

in my function:
polylines.add({
   show: true,
   positions: cartesianArray,
   width:2
});

Is there a reason why I can't display two polylines at a time?

Thank you in advance,
Lydia

I also noticed that the polylines show up when I’m in the 2D view. However, when I switch to the 3D view, I only see the most recently added polyline. Strange…

Lydia

Hi Lydia,

There should be no reason that you can only display one line. Can you post a more complete code sample that demonstrates the bug? I can’t reproduce it.

Thanks,

Dan

Hi Dan,

I actually figured out my problem. I was using the same cartesian variable each time I was creating a new polyline, and not creating a new one each time. Thus, the position kept getting rewritten.

Thanks!

Lydia