@@ -144,8 +144,8 @@ export async function showElevationChart (feature) {
144144 canvasAbort = new AbortController ( )
145145 const signal = canvasAbort . signal
146146
147- // Update info line on hover
148- chart . canvas . addEventListener ( 'mousemove' , ( event ) => {
147+ // Shared handler for hover/touch interaction
148+ const handleChartInteraction = ( event ) => {
149149 const points = chart . getElementsAtEventForMode ( event , 'index' , { intersect : false } , true )
150150 if ( points . length === 0 ) {
151151 infoLine . style . visibility = 'hidden'
@@ -158,20 +158,32 @@ export async function showElevationChart (feature) {
158158 const elevation = active . values [ i ] . toFixed ( 0 )
159159 const grade = i === 0 ? 0 : computeGrade ( active . values , active . labels , i )
160160
161- infoLine . textContent = `Point : ${ distance } • Elevation: ${ elevation } m • Steepness: ${ grade . toFixed ( 1 ) } %`
161+ infoLine . innerHTML = `Waypoint : ${ distance } • <i class="bi bi-triangle"></i> ${ elevation } m • <i class="bi bi-arrow-up-right"></i> ${ grade . toFixed ( 1 ) } %`
162162 infoLine . style . visibility = 'visible'
163163
164164 // Place a marker on the map at the hovered point
165165 const coord = active . coords [ i ]
166166 marker = getMarker ( feature )
167167 marker . setLngLat ( [ coord [ 0 ] , coord [ 1 ] ] )
168168 marker . addTo ( map )
169- } , { signal } )
169+ }
170170
171- chart . canvas . addEventListener ( 'mouseout' , ( ) => {
171+ const hideChartInteraction = ( ) => {
172172 infoLine . style . visibility = 'hidden'
173173 if ( marker ) marker . remove ( )
174- } , { signal } )
174+ }
175+
176+ // Update info line on hover (desktop)
177+ chart . canvas . addEventListener ( 'mousemove' , handleChartInteraction , { signal } )
178+ chart . canvas . addEventListener ( 'mouseout' , hideChartInteraction , { signal } )
179+
180+ // Update info line on touch drag (mobile)
181+ chart . canvas . addEventListener ( 'touchmove' , ( event ) => {
182+ event . preventDefault ( ) // Prevent scrolling while dragging
183+ handleChartInteraction ( event )
184+ } , { signal, passive : false } )
185+
186+ chart . canvas . addEventListener ( 'touchend' , hideChartInteraction , { signal } )
175187
176188 // Fly to the clicked point on the map (stopPropagation prevents the click
177189 // from bubbling to the map, which would re-trigger highlightFeature and
@@ -245,7 +257,7 @@ function computeDistances (coords) {
245257}
246258
247259// Find the nearest track point to the given GPS position
248- // Returns index if within 25m threshold, else -1
260+ // Returns index if within 100m threshold, else -1
249261function findNearestTrackIndex ( lngLat , coords ) {
250262 let minDist = Infinity
251263 let minIdx = - 1
@@ -256,7 +268,7 @@ function findNearestTrackIndex (lngLat, coords) {
256268 minIdx = i
257269 }
258270 }
259- return minDist <= 25 ? minIdx : - 1
271+ return minDist <= 100 ? minIdx : - 1
260272}
261273
262274// Filter active data to only include points visible in the current map viewport
0 commit comments