@@ -829,17 +829,14 @@ <h2>Settings</h2>
829829 trackContainer . innerHTML = '<div class="track-loading">Loading track data...</div>' ;
830830 const track = trackList [ trackIndex ] ;
831831 const trackData = trackLineToObject ( track . info . headers , track . info . l ) ;
832- let trackHtml = `
832+ trackContainer . innerHTML = `
833833 <div class="track-content-wrapper">
834834 <div class="card">
835835 <div class="card-body">
836- ${ trackData . Latitude
837- ? `
838836 <div id="map-${ track . number } " class="leaflet-map"></div>
839837 <div class="track-stats">
840838 <span id="stats-${ track . number } ">Loading...</span>
841- </div>`
842- : '' }
839+ </div>
843840 <div id="charts-${ track . number } " class="charts-container"></div>
844841 </div>
845842 <div class="card-footer">
@@ -851,7 +848,6 @@ <h2>Settings</h2>
851848 </div>
852849 </div>` ;
853850
854- trackContainer . innerHTML = trackHtml ;
855851 attachTrackButtonListeners ( trackContainer ) ;
856852
857853 const fullTrack = await downloadTrack ( track . filename ) ;
@@ -861,8 +857,10 @@ <h2>Settings</h2>
861857 . filter ( hasValidGPS )
862858 . map ( pt => [ parseFloat ( pt . Latitude ) , parseFloat ( pt . Longitude ) ] ) ;
863859
860+ const containerId = `map-${ track . number } ` ;
861+
864862 if ( coordinates . length > 0 ) {
865- createLeafletMap ( `map- ${ track . number } ` , coordinates , fullTrack ) ;
863+ createLeafletMap ( containerId , coordinates , fullTrack ) ;
866864
867865 let distance = 0 ;
868866 for ( let i = 1 ; i < coordinates . length ; i ++ )
@@ -874,6 +872,14 @@ <h2>Settings</h2>
874872 const d = convertDistance ( distance / 1000 ) ;
875873 statsEl . innerHTML = `<strong>Distance:</strong> ${ d . value . toFixed ( 2 ) } ${ d . unit } | <strong>Duration:</strong> ${ hours } h ${ minutes } m | <strong>Points:</strong> ${ coordinates . length } ` ;
876874 }
875+ } else {
876+ const map = trackContainer . querySelector ( containerId ) ;
877+ const stats = trackContainer . querySelector ( `stats-${ track . number } ` ) ;
878+
879+ map . style . display = "none" ;
880+ stats . style . display = "none" ;
881+
882+ // but keep the charts
877883 }
878884
879885 createChartsForTrack ( track . number , fullTrack ) ;
0 commit comments