Polyline different color according to coordinates

Hi,
Is there a way to make a polyline with different colors according to coordinates?

Let’s assume I have a polyline defined by the following array, representing the flight course of a bird:

[50,35,55,35,60,35,65,35, 70,35,75,35,80,35,85,35]

``

which creates a 7-sections polyline.

And the following attribute array:

[‘red’, ‘red’, ‘green’, ‘green’, ‘black’, ‘red’, ‘green’]

``

In addition, more points are being added to the array as the server gets more data (the mentioned tracked flight course).

I would like each part of the polyline to have the corresponding color in the attribute array.

Is there a way to do this with entities?

P.S.

The “brute-force” way of creating each part seprately is not efficient because I would usually have around 1000 polyline parts at a certain period of time (in addition to many other parts in the map), and more points would be added as tracking continues. I could reduce this overhead by drawing a polyline in a certain color until a different collor part appears and only then create a new entity for this line, but was hopping to have something more elegant.