From 3773acf4c004e28c7073b85736ef1e156feded26 Mon Sep 17 00:00:00 2001 From: eric1tran Date: Mon, 22 Feb 2021 21:57:32 +0000 Subject: [PATCH] Null check before setting aircraft icon style --- public_html/planeObject.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public_html/planeObject.js b/public_html/planeObject.js index 8c59cb4..c824ebe 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -453,6 +453,7 @@ PlaneObject.prototype.updateIcon = function() { var svgKey = col + '!' + outline + '!' + baseMarker.svg + '!' + add_stroke + "!" + scaleFactor; var styleKey = opacity + '!' + rotation + '!' + AircraftLabels; + // New icon or marker change if (this.markerStyle === null || this.markerIcon === null || this.markerSvgKey != svgKey) { //console.log(this.icao + " new icon and style " + this.markerSvgKey + " -> " + svgKey); @@ -501,6 +502,7 @@ PlaneObject.prototype.updateIcon = function() { } } + // Rotation or aircraft label display change if (this.markerStyleKey != styleKey) { //console.log(this.icao + " new rotation"); this.markerIcon.setRotation(rotation * Math.PI / 180.0); @@ -527,7 +529,9 @@ PlaneObject.prototype.updateIcon = function() { image: this.markerIcon }); }; - this.marker.setStyle(this.markerStyle); + if (this.marker !== null) { + this.marker.setStyle(this.markerStyle); + } this.markerStyleKey = styleKey; }