@@ -121,22 +121,27 @@ function MapGrapher() {
121121 }
122122
123123 this . setFlightLogIndexs ( ) ;
124-
125124 let { latlngs, maxAlt, minAlt } = this . getPolylinesData ( ) ;
126125
127- const polyline = L . polyline ( latlngs , polylineOptions ) ;
126+ const hasGpsData = latlngs . length > 0 ;
128127
129- const polylineC = this . createAltitudeColoredPolyline (
130- latlngs ,
131- maxAlt ,
132- minAlt
133- ) ;
128+ if ( hasGpsData ) {
129+ const polyline = L . polyline ( latlngs , polylineOptions ) ;
130+
131+ const polylineC = this . createAltitudeColoredPolyline (
132+ latlngs ,
133+ maxAlt ,
134+ minAlt
135+ ) ;
134136
135- trailLayers . set ( logIndex , { polyline, polylineC } ) ;
137+ trailLayers . set ( logIndex , { polyline, polylineC } ) ;
136138
137- if ( latlngs . length > 0 ) {
138139 homePosition = this . getHomeCoordinatesFromFlightLog ( flightLog ) ;
140+ } else {
141+ console . debug ( "FlightLog has no gps data." ) ;
139142 }
143+
144+ $ ( "#mapContainer" ) . toggleClass ( "no-gps-data" , ! hasGpsData ) ;
140145 } ;
141146
142147 this . setFlightLogIndexs = function ( ) {
@@ -382,7 +387,7 @@ function MapGrapher() {
382387 const lng = frame [ lngIndex ] ;
383388 const alt = frame [ altitudeIndex ] ;
384389
385- return typeof lat == "number" || typeof lng == "number"
390+ return this . isNumber ( lat ) && this . isNumber ( lng )
386391 ? L . latLng (
387392 lat / coordinateDivider ,
388393 lng / coordinateDivider ,
@@ -391,6 +396,10 @@ function MapGrapher() {
391396 : null ;
392397 } ;
393398
399+ this . isNumber = function ( n ) {
400+ return typeof n === "number" && ! isNaN ( n ) ;
401+ } ;
402+
394403 this . getGroundCourseFromFrame = function ( frame , groundCourseIndex ) {
395404 const gc = frame [ groundCourseIndex ] ;
396405 return typeof gc == "number" ? gc / grounCourseDivider : 0 ;
0 commit comments