Web view JavaScript modifications.
modified: public_html/gmap.html modified: public_html/script.js modified: public_html/style.css
This commit is contained in:
parent
6f228b9c88
commit
ae69cd5d48
|
@ -13,7 +13,10 @@
|
||||||
<div id="map_canvas"></div>
|
<div id="map_canvas"></div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<div>
|
<div>
|
||||||
<h1>Dump1090 - <span id="utcTime">00:00:00</span> UTC <a href="#" onClick="resetMap();">Reset Map</a></h1>
|
<h1>
|
||||||
|
Dump1090 - <span id="utcTime">00:00:00</span> UTC
|
||||||
|
<a href="#" onClick="resetMap();">Reset Map</a>
|
||||||
|
</h1>
|
||||||
<p id="geninfo"></p>
|
<p id="geninfo"></p>
|
||||||
<p id="selinfo">Click on a plane for info.</p>
|
<p id="selinfo">Click on a plane for info.</p>
|
||||||
<p id="tabinfo"></p>
|
<p id="tabinfo"></p>
|
||||||
|
|
|
@ -11,31 +11,54 @@ if (localStorage['CenterLat']) { CenterLat = Number(localStorage['CenterLat']);
|
||||||
if (localStorage['CenterLon']) { CenterLon = Number(localStorage['CenterLon']); }
|
if (localStorage['CenterLon']) { CenterLon = Number(localStorage['CenterLon']); }
|
||||||
if (localStorage['ZoomLvl']) { ZoomLvl = Number(localStorage['ZoomLvl']); }
|
if (localStorage['ZoomLvl']) { ZoomLvl = Number(localStorage['ZoomLvl']); }
|
||||||
|
|
||||||
function getIconForPlane(plane) {
|
function getIconForPlane(plane, deselect) {
|
||||||
|
var selected = false;
|
||||||
|
var track = 0;
|
||||||
var r = 255, g = 255, b = 0;
|
var r = 255, g = 255, b = 0;
|
||||||
var maxalt = 40000; // Max altitude in the average case
|
var maxalt = 40000; // Max altitude in the average case
|
||||||
var invalt = maxalt-plane.altitude;
|
var invalt = 0;
|
||||||
var selected = (Selected == plane.hex);
|
|
||||||
|
// If there is plane object
|
||||||
|
if (plane) {
|
||||||
|
invalt = maxalt-plane.altitude;
|
||||||
|
if (Selected == plane.hex && !deselect) {
|
||||||
|
selected = true;
|
||||||
|
}
|
||||||
|
track = plane.track;
|
||||||
|
}
|
||||||
|
|
||||||
if (invalt < 0) invalt = 0;
|
if (invalt < 0) invalt = 0;
|
||||||
b = parseInt(255/maxalt*invalt);
|
b = parseInt(255/maxalt*invalt);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
strokeWeight: (selected ? 2 : 1),
|
strokeWeight: (selected ? 2 : 1),
|
||||||
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
|
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
|
||||||
scale: 5,
|
scale: 5,
|
||||||
fillColor: 'rgb('+r+','+g+','+b+')',
|
fillColor: 'rgb('+r+','+g+','+b+')',
|
||||||
fillOpacity: 0.9,
|
fillOpacity: 0.9,
|
||||||
rotation: plane.track
|
rotation: track
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Gets hex code of selected plane as string or nothing. *
|
||||||
|
* Select not valid ICAO24 (hex) address to clear selection. */
|
||||||
function selectPlane(selectedPlane) {
|
function selectPlane(selectedPlane) {
|
||||||
if (selectedPlane.length) this.planehex = selectedPlane;
|
if (selectedPlane.length) this.planehex = selectedPlane;
|
||||||
if (!Planes[this.planehex]) return;
|
|
||||||
|
// Deselect all planes
|
||||||
|
if (!Planes[this.planehex]) {
|
||||||
|
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected], true));
|
||||||
|
Selected = null;
|
||||||
|
refreshSelectedInfo();
|
||||||
|
refreshTableInfo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var old = Selected;
|
var old = Selected;
|
||||||
Selected = this.planehex;
|
Selected = this.planehex;
|
||||||
|
|
||||||
if (Planes[old]) {
|
if (Planes[old]) {
|
||||||
/* Remove the highlight in the previously selected plane. */
|
// Remove the highlight in the previously selected plane.
|
||||||
Planes[old].marker.setIcon(getIconForPlane(Planes[old]));
|
Planes[old].marker.setIcon(getIconForPlane(Planes[old]));
|
||||||
}
|
}
|
||||||
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected]));
|
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected]));
|
||||||
|
@ -55,6 +78,7 @@ function refreshSelectedInfo() {
|
||||||
var i = document.getElementById('selinfo');
|
var i = document.getElementById('selinfo');
|
||||||
var p = Planes[Selected];
|
var p = Planes[Selected];
|
||||||
|
|
||||||
|
// If no plane is selected
|
||||||
if (!p) {
|
if (!p) {
|
||||||
p = {};
|
p = {};
|
||||||
p.flight = "";
|
p.flight = "";
|
||||||
|
@ -82,30 +106,36 @@ function refreshSelectedInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshTableInfo() {
|
function refreshTableInfo() {
|
||||||
var i = document.getElementById('tabinfo');
|
|
||||||
|
|
||||||
var html = '<table id="tableinfo" width="100%">';
|
var html = '<table id="tableinfo" width="100%">';
|
||||||
html += '<thead style="background-color: #CCCCCC;">';
|
html += '<thead style="background-color: #CCCCCC;">';
|
||||||
html += '<td>Flight</td><td align="right">Squawk</td><td align="right">Altitude</td>';
|
html += '<td>hex</td><td>Flight</td><td align="right">Squawk</td><td align="right">Altitude</td>';
|
||||||
html += '<td align="right">Speed</td><td align="right">Track</td><td align="right">Seen</td>';
|
html += '<td align="right">Speed</td><td align="right">Track</td>';
|
||||||
html += '<td align="right">Msgs</td></thead>';
|
html += '<td align="right">Msgs</td><td align="right">Seen</td></thead>';
|
||||||
for (var p in Planes) {
|
for (var p in Planes) {
|
||||||
if (p == Selected) {
|
if (p == Selected) {
|
||||||
html += '<tr style="background-color: #E0E0E0;">';
|
html += '<tr id="tableinforow" style="background-color: #E0E0E0;">';
|
||||||
} else {
|
} else {
|
||||||
html += '<tr id="tableinforow" onClick="selectPlane(\''+p+'\');">';
|
html += '<tr id="tableinforow">';
|
||||||
}
|
}
|
||||||
|
html += '<td>' + Planes[p].hex + '</td>';
|
||||||
html += '<td>' + Planes[p].flight + '</td>';
|
html += '<td>' + Planes[p].flight + '</td>';
|
||||||
html += '<td align="right">' + Planes[p].squawk + '</td>';
|
html += '<td align="right">' + Planes[p].squawk + '</td>';
|
||||||
html += '<td align="right">' + Planes[p].altitude + '</td>';
|
html += '<td align="right">' + Planes[p].altitude + '</td>';
|
||||||
html += '<td align="right">' + Planes[p].speed + '</td>';
|
html += '<td align="right">' + Planes[p].speed + '</td>';
|
||||||
html += '<td align="right">' + Planes[p].track + '</td>';
|
html += '<td align="right">' + Planes[p].track + '</td>';
|
||||||
html += '<td align="right">' + Planes[p].seen + '</td>';
|
|
||||||
html += '<td align="right">' + Planes[p].messages + '</td>';
|
html += '<td align="right">' + Planes[p].messages + '</td>';
|
||||||
|
html += '<td align="right">' + Planes[p].seen + '</td>';
|
||||||
html += '</tr>';
|
html += '</tr>';
|
||||||
}
|
}
|
||||||
html += '</table>';
|
html += '</table>';
|
||||||
i.innerHTML = html;
|
|
||||||
|
document.getElementById('tabinfo').innerHTML = html;
|
||||||
|
|
||||||
|
// Click event for table - lags sometimes for some reason?
|
||||||
|
$('#tableinfo').find('tr').click( function(){
|
||||||
|
var hex = $(this).find('td:first').text();
|
||||||
|
selectPlane(hex);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchData() {
|
function fetchData() {
|
||||||
|
@ -258,7 +288,9 @@ function initialize() {
|
||||||
});
|
});
|
||||||
|
|
||||||
google.maps.event.addListener(Map, 'click', function() {
|
google.maps.event.addListener(Map, 'click', function() {
|
||||||
selectPlane("xyzxyz"); // Select not valid ICAO24 address to clear selection.
|
if (Selected) {
|
||||||
|
selectPlane("xyzxyz"); // Select not valid ICAO24 (hex) address to clear selection.
|
||||||
|
}
|
||||||
Selected = null;
|
Selected = null;
|
||||||
refreshSelectedInfo();
|
refreshSelectedInfo();
|
||||||
refreshTableInfo();
|
refreshTableInfo();
|
||||||
|
@ -277,5 +309,6 @@ function initialize() {
|
||||||
|
|
||||||
refreshGeneralInfo();
|
refreshGeneralInfo();
|
||||||
refreshSelectedInfo();
|
refreshSelectedInfo();
|
||||||
|
refreshTableInfo();
|
||||||
resizeMap();
|
resizeMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ body { height: 100%; margin: 0; padding: 0; }
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tabinfo {
|
#tableinforow {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue