From 3ba42dceaf7e794ca257ba3e9d6ab877d5418c03 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sun, 19 Jan 2025 18:05:21 +0100 Subject: [PATCH] Highlight on hover --- app/javascript/maps/polylines.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/javascript/maps/polylines.js b/app/javascript/maps/polylines.js index 50abecc9..2780dc1e 100644 --- a/app/javascript/maps/polylines.js +++ b/app/javascript/maps/polylines.js @@ -214,10 +214,22 @@ export function addHighlightOnHover(polylineGroup, map, polylineCoordinates, use } } - layer.setStyle({ - weight: 8, - opacity: 0.8, - color: '#FFD700' + // Apply style to all segments in the group + polylineGroup.eachLayer((segment) => { + if (segment instanceof L.Polyline) { + const newStyle = { + weight: 8, + opacity: 0.8 + }; + + // Only change color if speed-colored routes are not enabled + console.log("speed_colored_routes", userSettings.speed_colored_routes); + if (!userSettings.speed_colored_routes) { + newStyle.color = "yellow" + } + + segment.setStyle(newStyle); + } }); startMarker.addTo(map);