nakarte

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

commit 072b6d2735058693e995288c0e4e41ffca5b478a
parent dfe4627add1500ebfff0da831948470e5709102a
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Wed, 22 Feb 2017 11:47:20 +0300

[elevation profile] if track has no points show notification, do not throw exceptions

Diffstat:
Msrc/lib/leaflet.control.elevation-profile/index.js | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js @@ -36,6 +36,9 @@ function gradientToAngle(g) { } function pathRegularSamples(latlngs, step) { + if (!latlngs.length) { + return []; + } var samples = [], lastSampleDist = 0, lastPointDistance = 0, @@ -204,10 +207,13 @@ L.Control.ElevationProfile = L.Class.extend({ L.setOptions(this, options); this.path = latlngs; var samples = this.samples = pathRegularSamples(this.path, this.options.samplingInterval); + if (!samples.length) { + notify('Track is empty'); + return; + } var self = this; this.horizZoom = 1; this.dragStart = null; - this._getElevation(samples) .then(function(values) { self.values = values;