Skip to content

Commit

Permalink
added "legend" option + "redraw" function
Browse files Browse the repository at this point in the history
  • Loading branch information
Raruto committed Nov 13, 2019
1 parent 0150c4c commit 2c1703c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
11 changes: 9 additions & 2 deletions leaflet-elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ L.Control.Elevation = L.Control.extend({
imperial: false,
interpolation: "curveLinear",
lazyLoadJS: true,
legend: true,
loadData: {
defer: false,
lazy: false,
Expand Down Expand Up @@ -400,7 +401,7 @@ L.Control.Elevation = L.Control.extend({
window.removeEventListener('scroll', scrollFn);
this.loadData(data, opts);
this.once('eledata_loaded', function() {
if (this.placeholder) {
if (this.placeholder && this.placeholder.parentNode) {
this.placeholder.parentNode.removeChild(this.placeholder);
}
}, this)
Expand Down Expand Up @@ -469,6 +470,10 @@ L.Control.Elevation = L.Control.extend({
this._container = null;
},

redraw: function() {
this._resizeChart();
},

setZFollow: function(zoom) {
this._zFollow = zoom;
},
Expand Down Expand Up @@ -765,6 +770,8 @@ L.Control.Elevation = L.Control.extend({
},

_appendLegend: function(g) {
if (!this.options.legend) return;

var legend = this._legend = g.append('g')
.attr("class", "legend");

Expand Down Expand Up @@ -1581,7 +1588,7 @@ L.Control.Elevation = L.Control.extend({
},

_updateSummary: function() {
if (this.options.summary) {
if (this.options.summary && this.summaryDiv) {
this.track_info = this.track_info || {};
this.track_info.distance = this._distance || 0;
this.track_info.elevation_max = this._maxElevation || 0;
Expand Down
Loading

0 comments on commit 2c1703c

Please sign in to comment.