perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

Remove itinerary instructions on the second click #572

Closed Mehditerranee closed 4 years ago

Mehditerranee commented 4 years ago

I'm currently trying to put a route map on my website. I want to display the road and itinerary instructions at the click of a button.

But when I click a second time on the button, itinerary instructions are displayed a second time as you can see below :

Capture d’écran 2020-03-15 à 15 06 00

How can I prevent this behavior?

perliedman commented 4 years ago

Most likely you are creating a second instance of the control an adding it to the map. Hard to tell without seeing an example, though.