Raruto/leaflet-elevation

Marker tooltip with negative elevation

mttucl opened this issue · 1 comments

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

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

let yMax = (this.control._height() / props.yCoordMax * point[this.options.yAttr]);

yCoord: point.y,
length: point.y - yMax, // normalized Y

line
.attr("class", theme + " height-focus line")
.attr("x1", xCoord)
.attr("x2", xCoord)
.attr("y1", yCoord)
.attr("y2", length);

which also depends on yCoordMax variable:

this._yCoordMax = -Infinity;

if (this._yCoordMax < this._data[this._data.length - 1][this.options.yAttr]) this._yCoordMax = this._data[this._data.length - 1][this.options.yAttr];

/*
* Update the position/height indicator marker drawn onto the map
*/
_updateMarker(item) {
if (this._marker) {
this._marker.update({
map : this._map,
item : item,
yCoordMax : this._yCoordMax || 0,
options : this.options
});
}
},

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

👋 Raruto