diff --git a/css/main.css b/css/main.css index dff8f7ba..d987876a 100644 --- a/css/main.css +++ b/css/main.css @@ -507,6 +507,32 @@ html.has-sticks #stickCanvas { display:block; } +#mapContainer.no-gps-data:before { + position: absolute; + display: block; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 9999; + content: ""; + background-color: gray; + opacity: .5; +} + +#mapContainer.no-gps-data:after { + position: absolute; + display: block; + top: calc(30%); + right: 0; + bottom: 0; + left: 0; + z-index: 10001; + content: "No GPS Data"; + text-align: center; + font-size: 3vw; +} + html.has-analyser-fullscreen.has-analyser .analyser input:not(.onlyFullScreenException) { display:block; } diff --git a/js/graph_map.js b/js/graph_map.js index 0fe7e047..50bf8bd9 100644 --- a/js/graph_map.js +++ b/js/graph_map.js @@ -121,22 +121,27 @@ function MapGrapher() { } this.setFlightLogIndexs(); - let { latlngs, maxAlt, minAlt } = this.getPolylinesData(); - const polyline = L.polyline(latlngs, polylineOptions); + const hasGpsData = latlngs.length > 0; - const polylineC = this.createAltitudeColoredPolyline( - latlngs, - maxAlt, - minAlt - ); + if (hasGpsData) { + const polyline = L.polyline(latlngs, polylineOptions); + + const polylineC = this.createAltitudeColoredPolyline( + latlngs, + maxAlt, + minAlt + ); - trailLayers.set(logIndex, { polyline, polylineC }); + trailLayers.set(logIndex, { polyline, polylineC }); - if (latlngs.length > 0) { homePosition = this.getHomeCoordinatesFromFlightLog(flightLog); + } else { + console.debug("FlightLog has no gps data."); } + + $("#mapContainer").toggleClass("no-gps-data", !hasGpsData); }; this.setFlightLogIndexs = function () { @@ -382,7 +387,7 @@ function MapGrapher() { const lng = frame[lngIndex]; const alt = frame[altitudeIndex]; - return typeof lat == "number" || typeof lng == "number" + return this.isNumber(lat) && this.isNumber(lng) ? L.latLng( lat / coordinateDivider, lng / coordinateDivider, @@ -391,6 +396,10 @@ function MapGrapher() { : null; }; + this.isNumber = function (n) { + return typeof n === "number" && !isNaN(n); + }; + this.getGroundCourseFromFrame = function (frame, groundCourseIndex) { const gc = frame[groundCourseIndex]; return typeof gc == "number" ? gc / grounCourseDivider : 0;