BR.TrackStats = BR.Control.extend({ options: { heading: 'Route' }, onAdd: function (map) { var container = BR.Control.prototype.onAdd.call(this, map); this.update(); return container; }, update: function (polyline, segments) { var stats = this.calcStats(polyline, segments), length1 = L.Util.formatNum(stats.trackLength/1000,1), length3 = L.Util.formatNum(stats.trackLength/1000,3), meanCostFactor = stats.trackLength ? L.Util.formatNum(stats.cost / stats.trackLength, 2) : '', html = ''; html += '
| Length: | ' + length1 + ' | km |
| Ascent filtered: | ' + stats.filteredAscend + ' | m |
| Ascent plain: | ' + stats.plainAscend + ' | m |
| Cost: | ' + stats.cost + ' | |
| Mean cost: | ' + meanCostFactor + ' |