Skip to content

Commit

Permalink
Fix broken route segment coloring (#250)
Browse files Browse the repository at this point in the history
- with var instead of const all callbacks referenced last value in loop,
add closure
- cloning by property overwrites default when undefined, use L.extend
for Object.assign
  • Loading branch information
nrenner committed Nov 7, 2019
1 parent 4676c3d commit 0809b17
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions js/plugin/RoutingPathQuality.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ BR.RoutingPathQuality = L.Control.extend({
stateName: keys[i],
icon: provider.icon,
title: provider.title,
onClick: function(btn) {
btn.state(nextState);
self.setProvider(nextState);
}
onClick: (function(state) {
return function(btn) {
btn.state(state);
self.setProvider(state);
};
})(nextState)
});
}

Expand Down Expand Up @@ -146,12 +148,7 @@ var HotLineQualityProvider = L.Class.extend({
}

if (flatLines.length > 0) {
var hotlineOptions = {
min: this.hotlineOptions.min,
max: this.hotlineOptions.max,
palette: this.hotlineOptions.palette,
renderer: this.hotlineOptions.renderer
};
var hotlineOptions = L.extend({}, this.hotlineOptions);
if (!hotlineOptions.min && !hotlineOptions.max) {
var minMax = this._calcMinMaxValues(flatLines);
hotlineOptions.min = minMax.min;
Expand Down

0 comments on commit 0809b17

Please sign in to comment.