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

changes for imperial = true #196

Closed hupe13 closed 2 years ago

hupe13 commented 2 years ago

Solves https://github.com/Raruto/leaflet-elevation/issues/195#issue-1214943456.

Raruto commented 2 years ago

Thanks @hupe13, but i'm not very convinced of this change.

Could you please attach any other material that can show this is really correct?

@MingweiSamuel can you look into this too?

hupe13 commented 2 years ago

You are right. I have caught the wrong file. Instead of altitude.js the file control.js must be changed. But it works:

See here. This is your example, I only changed

-       <script src="https://unpkg.com/@raruto/leaflet-elevation@2.2.4/dist/leaflet-elevation.min.js"></script>
+       <script src="../dist/leaflet-elevation.js"></script>

-                                       imperial: false,
+                                       imperial: true,

In leaflet-elevation.js I changed:

639c639
<                                       point.alt ?? point.meta.ele ?? (point[2] * this.options.altitudeFactor)
---
>                                       point.alt ?? point.meta.ele ?? point[2]
713c713
<                                                       let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * this.options.altitudeFactor)});
---
>                                                       let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2])});

Please delete the pull request, I will do a new one.

Sorry. Hupe13

MingweiSamuel commented 2 years ago

@Raruto this doesn't fix #197. I have a small diff to fix the tooltip/hover values, but haven't been able to figure out how to get the axes tick marks working. (I was able to get some ugly unrounded numbers to show up underneath the meters ticks, so that was the wrong code path)

@hupe13 You can click the "close pr" button and make a new PR

hupe13 commented 2 years ago

Closed. Sorry about the trouble.