Segments: color track green→red along direction of travel

This commit is contained in:
Davide Scaini
2026-05-17 09:32:31 +02:00
parent 9521a64da4
commit 6bc77486f1
2 changed files with 8 additions and 9 deletions
+5 -1
View File
@@ -109,6 +109,7 @@
map.on('load', () => {
map.addSource('seg', {
type: 'geojson',
lineMetrics: true,
data: {
type: 'Feature',
geometry: {
@@ -119,7 +120,10 @@
});
map.addLayer({ id: 'seg-line', type: 'line', source: 'seg',
layout: { 'line-cap': 'round', 'line-join': 'round' },
paint: { 'line-color': '#f59e0b', 'line-width': 5 } });
paint: {
'line-gradient': ['interpolate', ['linear'], ['line-progress'], 0, '#22c55e', 1, '#ef4444'],
'line-width': 5,
} });
// Start/end markers
const start = segment!.polyline[0];