Add total track length / elevation

This commit is contained in:
2019-05-15 22:56:38 +02:00
parent 01af4b5627
commit c9b833b898
4 changed files with 22 additions and 15 deletions

29
script/leaflet.min.js vendored
View File

@@ -159,6 +159,9 @@ L.Control.Elevation = L.Control.extend({
this._applyData(); this._applyData();
} }
var detailsG = this._detailsG = g.append("g").attr('class', 'details');
this._details = detailsG.append("svg:text").attr('x', this._width()/2).attr('y', this._height() - 5 - 10 - 5).style('text-anchor', 'middle');
return container; return container;
}, },
@@ -680,6 +683,9 @@ L.Control.Elevation = L.Control.extend({
if (d && d._latlngs) { if (d && d._latlngs) {
this._addGPXdata(d._latlngs); this._addGPXdata(d._latlngs);
} }
var asMetaData = this.getMetaData();
this._details.text(Math.round(asMetaData.distance)+(this.options.imperial?'mi':'km')+' / +'+asMetaData.elevation_gain+(this.options.imperial?'ft':'m'));
}, },
/* /*
@@ -748,19 +754,16 @@ L.Control.Elevation = L.Control.extend({
numY = opts.hoverNumber.formatter(alt, opts.hoverNumber.decimalsY), numY = opts.hoverNumber.formatter(alt, opts.hoverNumber.decimalsY),
numX = opts.hoverNumber.formatter(dist, opts.hoverNumber.decimalsX); numX = opts.hoverNumber.formatter(dist, opts.hoverNumber.decimalsX);
if (opts.imperial) { this._focuslabelX
this._focuslabelX.attr("x", xCoordinate) .attr("x", xCoordinate)
.text(numY + " ft"); .text(numY + " " + (opts.imperial?"ft":"m"));
this._focuslabelY.attr("y", this._height() - 5)
.attr("x", xCoordinate + 3) var bLeftSide = (xCoordinate < this._width() / 2);
.text(numX + " mi"); this._focuslabelY
} else { .attr("y", this._height() - 5)
this._focuslabelX.attr("x", xCoordinate) .style('text-anchor', bLeftSide?'start':'end')
.text(numY + " m"); .attr("x", xCoordinate + 3 * (bLeftSide?1:-1))
this._focuslabelY.attr("y", this._height() - 5) .text(numX + " " + (opts.imperial?"mi":"km"));
.attr("x", xCoordinate + 3)
.text(numX + " km");
}
}, },
_applyData: function() { _applyData: function() {

View File

@@ -36,4 +36,8 @@ $stroke-width-axis : 2;
@extend .fa-elev-chart; @extend .fa-elev-chart;
} }
} }
.details text {
text-anchor: middle;
}
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long