Open antonioOrtiz opened 3 years ago
Hi, from the description, it's not clear to me exactly how this is an issue with Leaflet Routing Machine. It sounds more like an issue with the click handler you adde,d, but perhaps I'm misunderstanding the problem?
Also, that is a lot of code. If there is an issue, can you please make a smaller example, without using React etc., to illustrate the problem?
Hi there! Sorry about that! I figured having all the information would be better, but you're right that was a novel!
Anyway I have updated the question to only include the updateLeafletElement
function. Thanks for any input!
I followed the recommendation from the Leaflet Routing Machine regarding interactions i.e. onClicks.
With my implementation, I'm saving the waypoints in local-storage—saving the latitude and longitude obj I get from the map click, to an array called
markers
The event handler has a conditional which separates the click into two outcomes—an adding (to the markers array) or updating it.
Like I said in the title, initial interaction is fine, it's just when I remove any marker and try to add it again is the problem. Also I noticed the
markers
array is completely empty, and next event fired is an update when clearly it should be an addition:Here is the relevant code in the Routing Machine:
Thanks in advance!