nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 5c511cc55baa107c664913061c25032b60ab4c1b
parent ee3891e8cd71ec15df639b40d2e8af3fb0bee249
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Sun, 10 Aug 2025 12:39:31 +0200

elevation profile: fix angle sign, show sign as an arrow pointing up or down

Diffstat:
Msrc/lib/leaflet.control.elevation-profile/elevation-profile.css | 5+++++
Msrc/lib/leaflet.control.elevation-profile/index.js | 12+++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/lib/leaflet.control.elevation-profile/elevation-profile.css b/src/lib/leaflet.control.elevation-profile/elevation-profile.css @@ -162,3 +162,8 @@ cursor: pointer; } +.elevation-profile-cursor-label .arrow, +.elevation-profile-marker-label .arrow { + font-size: 18px; +} + diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js @@ -596,12 +596,18 @@ const ElevationProfile = L.Class.extend({ const samplingInterval = this.options.samplingInterval; const distanceKm = samplingInterval * ind / 1000; const distanceStr = `${distanceKm.toFixed(2)} km`; - const sample1 = this.values[Math.ceil(ind)]; - const sample2 = this.values[Math.floor(ind)]; + const sample1 = this.values[Math.floor(ind)]; + const sample2 = this.values[Math.ceil(ind)]; let angleStr; if (sample1 !== null && sample2 !== null) { const gradient = (sample2 - sample1) / samplingInterval; - angleStr = `${Math.round(Math.atan(gradient) * 180 / Math.PI)}&deg`; + const angle = gradientToAngle(gradient); + const angleDir = { + '0': '', + '-1': '<span class="arrow">&darr;</span>', + '1': '<span class="arrow">&uarr;</span>', + }[Math.sign(angle)]; + angleStr = `${angleDir}${Math.abs(angle)}&deg`; } else { angleStr = '-'; }