fix(map): the recorded Dawarich route reads on a busy street map

A thin, translucent dash over a nearly opaque white casing read as a pale trace and was barely visible on past trips. Full colour, a wider line and longer dashes, shared by the Leaflet and GL layers. TestFlight feedback, 5.1.3.
This commit is contained in:
Maurice
2026-11-11 20:41:24 +00:00
parent 7db5ec0721
commit 231a610466
5 changed files with 41 additions and 16 deletions
@@ -122,8 +122,8 @@ describe('DawarichTrailLayer', () => {
const [casing, line] = lines()
expect(casing.getAttribute('data-pane')).toBe('trek-track-casing')
expect(casing.getAttribute('data-weight')).toBe('6')
expect(casing.getAttribute('data-opacity')).toBe('0.55')
expect(casing.getAttribute('data-weight')).toBe('7')
expect(casing.getAttribute('data-opacity')).toBe('0.9')
// Only the casing takes the pane; the coloured line is left in Leaflet's
// default overlay pane. Pinned as the fact it is rather than as a rule:
@@ -131,8 +131,9 @@ describe('DawarichTrailLayer', () => {
// it, so the recorded line currently draws over the plan while the GL twin
// puts both of its layers under it.
expect(line.getAttribute('data-pane')).toBe('')
expect(line.getAttribute('data-weight')).toBe('3')
expect(line.getAttribute('data-dash')).toBe('6 5')
// Full colour, wide and long-dashed, so it reads on a busy street map.
expect(line.getAttribute('data-weight')).toBe('4')
expect(line.getAttribute('data-dash')).toBe('10 5')
expect(line.getAttribute('data-points')).toBe(JSON.stringify([[48.2, 16.37], [48.21, 16.38]]))
expect(lines().every(el => el.getAttribute('data-interactive') === 'false')).toBe(true)
@@ -5,6 +5,7 @@ import { frameLine } from '../../utils/lngFrame'
import type { DawarichTrack } from '@trek/shared'
import {
DAWARICH_TRAIL_CASING,
DAWARICH_TRAIL_STROKE,
trailSegments,
type DawarichTrailSegment,
} from './dawarichTrail'
@@ -55,8 +56,8 @@ export default function DawarichTrailLayer({
// theme-lint-disable — map paint
pathOptions={{
color: DAWARICH_TRAIL_CASING,
weight: 6,
opacity: 0.55,
weight: DAWARICH_TRAIL_STROKE.casingWidth,
opacity: DAWARICH_TRAIL_STROKE.casingOpacity,
lineCap: 'round',
lineJoin: 'round',
}}
@@ -72,9 +73,9 @@ export default function DawarichTrailLayer({
positions={segment.points}
pathOptions={{
color: segment.color,
weight: 3,
opacity: 0.85,
dashArray: '6 5',
weight: DAWARICH_TRAIL_STROKE.width,
opacity: DAWARICH_TRAIL_STROKE.opacity,
dashArray: DAWARICH_TRAIL_STROKE.dashLeaflet,
lineCap: 'round',
lineJoin: 'round',
}}
@@ -27,6 +27,22 @@ export const DAWARICH_TRAIL_COLOR = '#2563EB' // theme-lint-disable — map pain
/** The white casing under the line, so it stays visible over a satellite tile. */
export const DAWARICH_TRAIL_CASING = '#FFFFFF' // theme-lint-disable — map paint
/**
* How the recorded route is stroked, shared by the Leaflet and GL layers. A
* thin, translucent dash over a nearly opaque white casing read as a pale
* lavender trace on a busy street map and was barely visible (TestFlight
* feedback, 5.1.3). Full colour, a wider line and longer dashes keep it
* readable; the dash still tells it apart from the planned route.
*/
export const DAWARICH_TRAIL_STROKE = {
casingWidth: 7,
casingOpacity: 0.9,
width: 4,
opacity: 1,
dashLeaflet: '10 5',
dashGL: [2.5, 1.25] as [number, number],
} as const
/**
* Per-day hues, cycled.
*
@@ -182,14 +182,17 @@ describe('useDawarichTrailGL', () => {
const [casingCall, lineCall] = gl.spies.addLayer.mock.calls
expect(casingCall[0].id).toBe(CASING_LAYER)
expect(casingCall[0].paint['line-color']).toBe(DAWARICH_TRAIL_CASING)
expect(casingCall[0].paint['line-width']).toBe(6)
expect(casingCall[0].paint['line-width']).toBe(7)
expect(casingCall[0].paint['line-opacity']).toBe(0.9)
expect(lineCall[0].id).toBe(LINE_LAYER)
// Per-feature colour, with the casing white as the fallback a feature
// without one falls back to. The GPX layer uses the same shape.
expect(lineCall[0].paint['line-color']).toEqual(['coalesce', ['get', 'color'], DAWARICH_TRAIL_CASING])
// Dashed, so the recording is distinguishable from the planned route for
// someone who cannot tell the two hues apart.
expect(lineCall[0].paint['line-dasharray']).toEqual([2, 1.6])
expect(lineCall[0].paint['line-dasharray']).toEqual([2.5, 1.25])
expect(lineCall[0].paint['line-width']).toBe(4)
expect(lineCall[0].paint['line-opacity']).toBe(1)
// Both go beneath the planned route's casing. The line is inserted second
// and therefore ends up above its own casing and still below the plan.
@@ -2,7 +2,7 @@ import { useEffect } from 'react'
import type { Map } from 'mapbox-gl'
import type { GeoJSONSource } from 'mapbox-gl'
import type { DawarichTrack } from '@trek/shared'
import { DAWARICH_TRAIL_CASING, trailGeoJson, trailSegments } from './dawarichTrail'
import { DAWARICH_TRAIL_CASING, DAWARICH_TRAIL_STROKE, trailGeoJson, trailSegments } from './dawarichTrail'
/**
* The recorded route on the GL renderer — the imperative twin of
@@ -67,7 +67,11 @@ export function useDawarichTrailGL(
source: SOURCE,
layout: { 'line-cap': 'round', 'line-join': 'round' },
// theme-lint-disable — map paint
paint: { 'line-color': DAWARICH_TRAIL_CASING, 'line-width': 6, 'line-opacity': 0.55 },
paint: {
'line-color': DAWARICH_TRAIL_CASING,
'line-width': DAWARICH_TRAIL_STROKE.casingWidth,
'line-opacity': DAWARICH_TRAIL_STROKE.casingOpacity,
},
},
anchor,
)
@@ -81,11 +85,11 @@ export function useDawarichTrailGL(
// Per-day colour off the feature, with the same fallback the GPX
// layer uses when a feature somehow carries none.
'line-color': ['coalesce', ['get', 'color'], DAWARICH_TRAIL_CASING],
'line-width': 3,
'line-opacity': 0.85,
'line-width': DAWARICH_TRAIL_STROKE.width,
'line-opacity': DAWARICH_TRAIL_STROKE.opacity,
// Dashed, so the recording is distinguishable from the planned
// route without relying on colour alone.
'line-dasharray': [2, 1.6],
'line-dasharray': [...DAWARICH_TRAIL_STROKE.dashGL],
},
},
anchor,