commit f724dec41d89840d2d37107060421e5f22267f34 parent 7c73eb0cbce79e2214ea890d4150db9ca1e37360 Author: Sergej Orlov <wladimirych@gmail.com> Date: Thu, 19 Jul 2018 02:08:07 +0300 [track profile] fix overflow of elevation values index #100 Diffstat:
M | src/lib/leaflet.control.elevation-profile/index.js | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js @@ -348,6 +348,12 @@ const ElevationProfile = L.Class.extend({ }, xToIndex: function(x) { + if (x < 0) { + x = 0; + } + if (x > this.svgWidth - 1) { + x = this.svgWidth - 1; + } return x / (this.svgWidth - 1) * (this.values.length - 1); },