From 6d3b4b9c60fa17c090cffb2226ec823888f7588b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Tue, 19 Dec 2017 00:17:24 +0100 Subject: [PATCH] determine route color only once --- src/c3nav/site/static/site/js/c3nav.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/c3nav/site/static/site/js/c3nav.js b/src/c3nav/site/static/site/js/c3nav.js index 1ea1c086..1aa88280 100644 --- a/src/c3nav/site/static/site/js/c3nav.js +++ b/src/c3nav/site/static/site/js/c3nav.js @@ -56,6 +56,8 @@ c3nav = { continue_init: function() { c3nav.init_map(); + c3nav._route_color = $('.leaflet-control-attribution a:not(:hover)').css('color'); + $('.locationinput').data('location', null); var $main = $('main'), @@ -403,12 +405,13 @@ c3nav = { point = [destination[0]+Math.cos(angle)*offset, destination[1]+Math.sin(angle)*offset]; return [origin, point, destination]; }, + _route_color: null, _add_line_to_route: function(level, coords, gray, link_to_level) { if (coords.length < 2) return; var latlngs = L.GeoJSON.coordsToLatLngs(c3nav._smooth_line(coords)), routeLayer = c3nav._routeLayers[level]; line = L.polyline(latlngs, { - color: gray ? '#888888': $('.leaflet-control-attribution a:not(:hover)').css('color'), + color: gray ? '#888888': c3nav._route_color, dashArray: (gray || link_to_level) ? '7' : null, interactive: false, smoothFactor: 0.5