Raruto / leaflet-elevation

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

`imperial: true` does not convert (GPX?) elevation from meters to feet #197

Closed MingweiSamuel closed 2 years ago

MingweiSamuel commented 2 years ago

Subject of the issue

GPX <ele> tags report the elevation in meters. However when loading using leaflet-elevation with imperial: true the values are not converted to feet. Instead, the meter values are displayed as if they were feet. (90m => 90ft)

Your environment

MingweiSamuel commented 2 years ago

image

MingweiSamuel commented 2 years ago

Tooltip can be fixed easily:

-                       chart: (item) => L._("y: ") + _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label,
-                       marker: (item) => _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label, 
+                       chart: (item) => L._("y: ") + _.round(item[opts.yAttr] * opts.altitudeFactor, opts.decimalsY) + " " + altitude.label,
+                       marker: (item) => _.round(item[opts.yAttr] * opts.altitudeFactor, opts.decimalsY) + 
" " + altitude.label,

But having trouble with the chart axis

hupe13 commented 2 years ago

https://github.com/Raruto/leaflet-elevation/pull/196#issue-1225563351 ;-)