From 0809b17577091d5f580a942bf75b0dd421540f50 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Thu, 7 Nov 2019 18:34:01 +0100 Subject: [PATCH] Fix broken route segment coloring (#250) - 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 --- js/plugin/RoutingPathQuality.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/js/plugin/RoutingPathQuality.js b/js/plugin/RoutingPathQuality.js index 26f8501..aa0c782 100644 --- a/js/plugin/RoutingPathQuality.js +++ b/js/plugin/RoutingPathQuality.js @@ -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) }); } @@ -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;