From 27896713e0e5fa33193ef6abb0e1a113c8a794c5 Mon Sep 17 00:00:00 2001 From: Andrew Mohn Date: Mon, 7 Oct 2019 11:34:44 -0400 Subject: [PATCH 1/8] Update route opacity onclick --- src/utils/data_handler.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index b3efd25..5e6f821 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -707,6 +707,20 @@ var addRoutes = function(resultRoutes) { var showRoute = function (r) { return function() { + // Increase this route's opacity while decreasing opacity of all others + for (var k = 0; k < routes.length; k) { + if (k == r) { + routes[k].setStyle({opacity: 1}); + } else { + routes[k].setStyle({opacity: .25}); + } + } + for (var jobMarker in data.jobsMarkers) { + if (data.jobsMarkers.hasOwnProperty(jobMarker)) { + data.jobsMarkers[jobMarker].setStyle({opacity: .25}); + } + } + routes[r].openPopup() LSetup.map.fitBounds(routes[r].getBounds(), { paddingBottomRight: [panelControl.getWidth(), 0], @@ -715,6 +729,9 @@ var addRoutes = function(resultRoutes) { } }; + path.on({ + click: showRoute(i) + }); row.onclick = showRoute(i); var vCell = row.insertCell(0); From 693bb89498b2e26bd972f714830f0f92445fbe9c Mon Sep 17 00:00:00 2001 From: Andrew Mohn Date: Mon, 7 Oct 2019 13:45:00 -0400 Subject: [PATCH 2/8] Configurable opacities and reset on second click --- src/config/leaflet_setup.js | 2 ++ src/utils/data_handler.js | 33 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/config/leaflet_setup.js b/src/config/leaflet_setup.js index 22e7a0d..6134f64 100644 --- a/src/config/leaflet_setup.js +++ b/src/config/leaflet_setup.js @@ -55,6 +55,8 @@ module.exports = { initZoom: initZoom, tileLayer: tileLayer, opacity: 0.6, + lowOpacity: 0.25, + highOpacity: 1, labelOpacity: 0.9, weight: 8, routeColors: routeColors, diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index 5e6f821..b79c239 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -705,22 +705,29 @@ var addRoutes = function(resultRoutes) { var row = solutionList.insertRow(nb_rows); row.title = 'Click to center the map'; - var showRoute = function (r) { - return function() { - // Increase this route's opacity while decreasing opacity of all others - for (var k = 0; k < routes.length; k) { - if (k == r) { - routes[k].setStyle({opacity: 1}); - } else { - routes[k].setStyle({opacity: .25}); - } + var updateRouteOpacities = function (r, highOpacity, lowOpacity) { + for (var k = 0; k < routes.length; k) { + if (k == r) { + routes[k].setStyle({opacity: highOpacity}); + } else { + routes[k].setStyle({opacity: lowOpacity}); } - for (var jobMarker in data.jobsMarkers) { - if (data.jobsMarkers.hasOwnProperty(jobMarker)) { - data.jobsMarkers[jobMarker].setStyle({opacity: .25}); - } + } + for (var jobMarker in data.jobsMarkers) { + if (data.jobsMarkers.hasOwnProperty(jobMarker)) { + data.jobsMarkers[jobMarker].setStyle({opacity: lowOpacity}); } + } + } + var showRoute = function (r) { + return function() { + // Either increase this route's opacity and decrease others, or reset + if (routes[r].options.opacity == LSetup.opacity) { + updateRouteOpacities(r, LSetup.highOpacity, LSetup.lowOpacity); + } else { + updateRouteOpacities(r, LSetup.opacity, LSetup.opacity); + } routes[r].openPopup() LSetup.map.fitBounds(routes[r].getBounds(), { paddingBottomRight: [panelControl.getWidth(), 0], From 81cf1d8bab881d675342e69735435d485b947e75 Mon Sep 17 00:00:00 2001 From: Andrew Mohn Date: Mon, 7 Oct 2019 13:47:45 -0400 Subject: [PATCH 3/8] Fix missing ++ --- src/utils/data_handler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index b79c239..8383152 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -706,7 +706,7 @@ var addRoutes = function(resultRoutes) { row.title = 'Click to center the map'; var updateRouteOpacities = function (r, highOpacity, lowOpacity) { - for (var k = 0; k < routes.length; k) { + for (var k = 0; k < routes.length; k++) { if (k == r) { routes[k].setStyle({opacity: highOpacity}); } else { From 50450c0a8e8b0a9bfe67c7f27bcfc43ad6a24c35 Mon Sep 17 00:00:00 2001 From: Andrew Mohn Date: Tue, 8 Oct 2019 16:31:48 -0400 Subject: [PATCH 4/8] Fix opacity bug on switching routes and add bringToFront --- src/config/leaflet_setup.js | 2 +- src/utils/data_handler.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config/leaflet_setup.js b/src/config/leaflet_setup.js index 6134f64..140ac9d 100644 --- a/src/config/leaflet_setup.js +++ b/src/config/leaflet_setup.js @@ -55,7 +55,7 @@ module.exports = { initZoom: initZoom, tileLayer: tileLayer, opacity: 0.6, - lowOpacity: 0.25, + lowOpacity: 0.3, highOpacity: 1, labelOpacity: 0.9, weight: 8, diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index 8383152..4589c91 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -723,12 +723,13 @@ var addRoutes = function(resultRoutes) { var showRoute = function (r) { return function() { // Either increase this route's opacity and decrease others, or reset - if (routes[r].options.opacity == LSetup.opacity) { + if (routes[r].options.opacity <= LSetup.opacity) { + routes[r].bringToFront(); updateRouteOpacities(r, LSetup.highOpacity, LSetup.lowOpacity); } else { updateRouteOpacities(r, LSetup.opacity, LSetup.opacity); } - routes[r].openPopup() + routes[r].openPopup(); LSetup.map.fitBounds(routes[r].getBounds(), { paddingBottomRight: [panelControl.getWidth(), 0], paddingTopLeft: [50, 0], From 4e63d193f407f8a56402e0b201532d1278584a52 Mon Sep 17 00:00:00 2001 From: jcoupey Date: Fri, 19 Mar 2021 11:31:18 +0100 Subject: [PATCH 5/8] Do not change marker opacity. --- src/utils/data_handler.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index 4589c91..9435061 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -713,11 +713,6 @@ var addRoutes = function(resultRoutes) { routes[k].setStyle({opacity: lowOpacity}); } } - for (var jobMarker in data.jobsMarkers) { - if (data.jobsMarkers.hasOwnProperty(jobMarker)) { - data.jobsMarkers[jobMarker].setStyle({opacity: lowOpacity}); - } - } } var showRoute = function (r) { From 0c60a5fe7ba7b570b81a66e3c55640f8d8ed905a Mon Sep 17 00:00:00 2001 From: jcoupey Date: Fri, 19 Mar 2021 11:42:10 +0100 Subject: [PATCH 6/8] Adjust default opacity values. --- src/config/leaflet_setup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/leaflet_setup.js b/src/config/leaflet_setup.js index 140ac9d..85d62f7 100644 --- a/src/config/leaflet_setup.js +++ b/src/config/leaflet_setup.js @@ -54,9 +54,9 @@ module.exports = { initCenter: initCenter, initZoom: initZoom, tileLayer: tileLayer, + lowOpacity: 0.4, opacity: 0.6, - lowOpacity: 0.3, - highOpacity: 1, + highOpacity: 0.9, labelOpacity: 0.9, weight: 8, routeColors: routeColors, From 23d209d69aa69c9c0653b477b753d3075c1c238b Mon Sep 17 00:00:00 2001 From: jcoupey Date: Fri, 19 Mar 2021 11:42:48 +0100 Subject: [PATCH 7/8] showRoute only put focus. --- src/utils/data_handler.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index 9435061..60326f1 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -717,14 +717,11 @@ var addRoutes = function(resultRoutes) { var showRoute = function (r) { return function() { - // Either increase this route's opacity and decrease others, or reset - if (routes[r].options.opacity <= LSetup.opacity) { - routes[r].bringToFront(); - updateRouteOpacities(r, LSetup.highOpacity, LSetup.lowOpacity); - } else { - updateRouteOpacities(r, LSetup.opacity, LSetup.opacity); - } + // Increase this route's opacity and decrease others. routes[r].openPopup(); + routes[r].bringToFront(); + updateRouteOpacities(r, LSetup.highOpacity, LSetup.lowOpacity); + LSetup.map.fitBounds(routes[r].getBounds(), { paddingBottomRight: [panelControl.getWidth(), 0], paddingTopLeft: [50, 0], From f4fd138a656044b654d9143138b2cd81021d277b Mon Sep 17 00:00:00 2001 From: jcoupey Date: Fri, 19 Mar 2021 11:43:09 +0100 Subject: [PATCH 8/8] Reset to normal opacity on route popup close. --- src/utils/data_handler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/data_handler.js b/src/utils/data_handler.js index 60326f1..759a7bb 100644 --- a/src/utils/data_handler.js +++ b/src/utils/data_handler.js @@ -730,7 +730,12 @@ var addRoutes = function(resultRoutes) { }; path.on({ - click: showRoute(i) + click: showRoute(i), + popupclose: function() { + for (var k = 0; k < routes.length; k++) { + routes[k].setStyle({opacity: LSetup.opacity}); + } + } }); row.onclick = showRoute(i);