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) : '', formattedTime = L.Util.formatNum(stats.totalTime / 60., 1), formattedEnergy = L.Util.formatNum(stats.totalEnergy / 3600000., 2), meanEnergy = stats.trackLength ? L.Util.formatNum(stats.totalEnergy / 36. / stats.trackLength, 2) : '', html = ''; html += '
| Length: | ' + length1 + ' | km | |
| Time: | ' + formattedTime + ' | min | |
| Energy: | ' + formattedEnergy + ' | kWh | (mean: ' + meanEnergy + ') |
| Ascent: | ' + stats.filteredAscend + ' | m | (plain: ' + stats.plainAscend + ') |
| Cost: | ' + stats.cost + ' | (mean: ' + meanCostFactor + ') | |
| Ascent filtered: | ' + stats.filteredAscend + ' | m | |
| Ascent plain: | ' + stats.plainAscend + ' | m | |
| Cost: | ' + stats.cost + ' | ||
| Mean cost: | ' + meanCostFactor + ' |