I am very much new to leaflet.
I have multiple markers plotted on my map in leaflet.
now I have to draw line between two markers when I select them.
Can any one help in doing this.
leafletopenstreetmap
I am very much new to leaflet.
I have multiple markers plotted on my map in leaflet.
now I have to draw line between two markers when I select them.
Can any one help in doing this.
Best Answer
So it seems to me all you have to do is take the two markers you have selected and grab their latlngs and add them to the polyline.
Edit
In case you are looking for a way to also get the selected markers. You will need to probably listen to the click event of each marker and add the markers to an array that contains your selected markers. You will just need to limit that array to two entries. This is not an optimal solution but should get you there and will allow you to easily extend if you want more than two markers.