0

I'm working on a project where I'm using Leaflet to create a map. I've defined a path from point A to B, and it's currently colored yellow. However, I want to change the color of the traveled path to blue when I start navigation. How can I achieve this?

Here are some additional details about my project:

I'm using Leaflet to display the map. I've already defined the initial path from point A to B with a yellow polyline. I need to dynamically change the color of the path to blue from my starting point to my current location when the user starts navigation. I would appreciate any guidance or code examples on how to implement this color change in Leaflet as the user progresses along the route

1
  • Can you check this? stackoverflow.com/questions/65082167/… Once you get the segment from the beginning to the cursor location, you can change its color with: polyline.setStyle({ color: 'blue'}); polyline.redraw(); So just put the line on the map with a zIndex greater than the base polyline. Commented Oct 31, 2023 at 16:58

0