Null check before setting aircraft icon style

This commit is contained in:
eric1tran 2021-02-22 21:57:32 +00:00
parent e111303b1e
commit 3773acf4c0
1 changed files with 5 additions and 1 deletions

View File

@ -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;
}