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

Marker tooltip with negative elevation #278

Open mttucl opened 1 year ago

mttucl commented 1 year ago

When displaying bathymetry data, the marker tooltip line is shown above the path with the tip outside the map. This only happens if all data is negative. If there is another path with positive elevation data, it will only happen if I display the bathymetry data first for the first time after loading the page. Once I check the other path, it will display the bathymetry data tooltip correctly.

Sorry, I don't have a working example but you can try the geojson demo example with attachment (change txt to geojson).

demo.txt

Raruto commented 1 year ago

Hi @mttucl,

If you're interested in seeing it resolved, please check it out and pitch a PR.

I would say that the problem is related to yMax calculation (I haven't checked in detail):

image

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

https://github.com/Raruto/leaflet-elevation/blob/bd9316bd1b7e7784b3bf3d812960eaa808ad94d6/src/components/marker.js#L63-L64

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

which also depends on yCoordMax variable:

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

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

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

If you're interested in seeing it resolved, please take a hard look and pitch a PR.

👋 Raruto