Raruto / leaflet-elevation

Leaflet plugin that allows to add elevation profiles using d3js
GNU General Public License v3.0
256 stars 85 forks source link

ruler on leaflet-elevation_hoverable-tracks.html #290

Open hupe13 opened 6 months ago

hupe13 commented 6 months ago

Hi Raruto,

please see your example loading multiple .gpx tracks (hover to toggle ). You move with the mouse over a track, the chart and the ruler appear. Now you click on any track on the map, the chart disappears. Next you move with the mouse over a track again, the chart appears, the ruler doesn't.

How to fix this?

Raruto commented 6 months ago

Hi @hupe13,

basically the control doesn't redraw the Ruler after calling remove()addTo(map)

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/libs/leaflet-gpxgroup.js#L279-L301

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/control.js#L1201-L1217

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/components/d3.js#L602-L641


Below some offending lines:

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/control.js#L248

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/control.js#L1207

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/control.js#L1211

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/components/d3.js#L629-L631

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/components/d3.js#L646

👋 Raruto