Update polyline coordinates

Hi,

I need to implement route tracking.
I have all route coordinates and I want to show user’s current location during the route progress.
After the user has passed some coordinate, I want to delete it from the polyline.

I thought I can do it by adding a polyline layer to the map, than, in order to update it, I’ll remove the previous layer, remove the visited coordinates and add a new layer with the new coordinates.

Is there any better way to do it?

If not, I’ve noticed that the polyline every time I update it. Is there any way to avoid it?

Hi,

This could be accomplished with:

map.getSource('some id').setData(..)

where ‘some id’ is the id of your layer.

It works.

Thank you very much.