2013-01-13 08:39:29 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
|
|
<style type="text/css">
|
|
|
|
html { height: 100% }
|
|
|
|
body { height: 100%; margin: 0; padding: 0 }
|
|
|
|
#map_canvas { height: 100% }
|
2013-01-27 08:37:05 +08:00
|
|
|
#info {
|
|
|
|
position: absolute;
|
|
|
|
width:20%;
|
|
|
|
height:100%;
|
|
|
|
bottom:0px;
|
|
|
|
right:0px;
|
|
|
|
top:0px;
|
|
|
|
background-color: white;
|
|
|
|
border-left:1px #666 solid;
|
|
|
|
font-family:Helvetica;
|
|
|
|
}
|
|
|
|
#info div {
|
|
|
|
padding:0px;
|
|
|
|
padding-left:10px;
|
|
|
|
margin:0px;
|
|
|
|
}
|
|
|
|
#info div h1 {
|
|
|
|
margin-top:10px;
|
|
|
|
font-size:16px;
|
|
|
|
}
|
|
|
|
#info div p {
|
|
|
|
font-size:14px;
|
|
|
|
color:#333;
|
|
|
|
}
|
2013-01-13 08:39:29 +08:00
|
|
|
</style>
|
|
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript"
|
|
|
|
src="https://maps.googleapis.com/maps/api/js?sensor=true">
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
Map=null;
|
2013-01-17 03:25:28 +08:00
|
|
|
CenterLat=45.0;
|
2013-01-13 08:39:29 +08:00
|
|
|
CenterLon=9.0;
|
|
|
|
Planes={};
|
2013-01-27 08:37:05 +08:00
|
|
|
NumPlanes = 0;
|
|
|
|
Selected=null
|
2013-01-13 08:39:29 +08:00
|
|
|
|
|
|
|
function getIconForPlane(plane) {
|
2013-01-17 03:25:28 +08:00
|
|
|
var r = 255, g = 255, b = 0;
|
|
|
|
var maxalt = 40000; /* Max altitude in the average case */
|
|
|
|
var invalt = maxalt-plane.altitude;
|
2013-01-27 08:37:05 +08:00
|
|
|
var selected = (Selected == plane.hex);
|
2013-01-17 03:25:28 +08:00
|
|
|
|
|
|
|
if (invalt < 0) invalt = 0;
|
|
|
|
b = parseInt(255/maxalt*invalt);
|
2013-01-13 08:39:29 +08:00
|
|
|
return {
|
2013-01-27 08:37:05 +08:00
|
|
|
strokeWeight: (selected ? 2 : 1),
|
2013-01-13 08:39:29 +08:00
|
|
|
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
|
|
|
|
scale: 5,
|
2013-01-17 03:25:28 +08:00
|
|
|
fillColor: 'rgb('+r+','+g+','+b+')',
|
|
|
|
fillOpacity: 0.9,
|
2013-01-13 08:39:29 +08:00
|
|
|
rotation: plane.track
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-01-27 08:37:05 +08:00
|
|
|
function selectPlane() {
|
|
|
|
if (!Planes[this.planehex]) return;
|
|
|
|
var old = Selected;
|
|
|
|
Selected = this.planehex;
|
|
|
|
if (Planes[old]) {
|
|
|
|
/* Remove the highlight in the previously selected plane. */
|
|
|
|
Planes[old].marker.setIcon(getIconForPlane(Planes[old]));
|
|
|
|
}
|
|
|
|
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected]));
|
|
|
|
refreshSelectedInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshGeneralInfo() {
|
|
|
|
var i = document.getElementById('geninfo');
|
|
|
|
|
|
|
|
i.innerHTML = NumPlanes+' planes on screen.';
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshSelectedInfo() {
|
|
|
|
var i = document.getElementById('selinfo');
|
|
|
|
var p = Planes[Selected];
|
|
|
|
|
|
|
|
if (!p) return;
|
|
|
|
var html = 'ICAO: '+p.hex+'<br>';
|
|
|
|
if (p.flight.length) {
|
|
|
|
html += '<b>'+p.flight+'</b><br>';
|
|
|
|
}
|
2013-02-05 06:09:05 +08:00
|
|
|
html += 'Altitude: '+p.altitude+' feet<br>';
|
2013-01-27 08:37:05 +08:00
|
|
|
html += 'Speed: '+p.speed+' knots<br>';
|
2013-02-05 06:09:05 +08:00
|
|
|
html += 'Coordinates: '+p.lat+', '+p.lon+'<br>';
|
2013-01-27 08:37:05 +08:00
|
|
|
i.innerHTML = html;
|
|
|
|
}
|
|
|
|
|
2013-01-13 08:39:29 +08:00
|
|
|
function fetchData() {
|
|
|
|
$.getJSON('/data.json', function(data) {
|
|
|
|
var stillhere = {}
|
|
|
|
for (var j=0; j < data.length; j++) {
|
|
|
|
var plane = data[j];
|
2013-01-17 03:25:28 +08:00
|
|
|
var marker = null;
|
2013-01-13 08:39:29 +08:00
|
|
|
stillhere[plane.hex] = true;
|
2013-01-17 03:25:28 +08:00
|
|
|
plane.flight = $.trim(plane.flight);
|
2013-01-13 08:39:29 +08:00
|
|
|
|
|
|
|
if (Planes[plane.hex]) {
|
|
|
|
var myplane = Planes[plane.hex];
|
2013-01-17 03:25:28 +08:00
|
|
|
marker = myplane.marker;
|
2013-01-13 08:39:29 +08:00
|
|
|
var icon = marker.getIcon();
|
|
|
|
var newpos = new google.maps.LatLng(plane.lat, plane.lon);
|
|
|
|
marker.setPosition(newpos);
|
|
|
|
marker.setIcon(getIconForPlane(plane));
|
2013-01-27 08:37:05 +08:00
|
|
|
myplane.altitude = plane.altitude;
|
|
|
|
myplane.speed = plane.speed;
|
|
|
|
myplane.lat = plane.lat;
|
|
|
|
myplane.lon = plane.lon;
|
2013-02-02 23:32:00 +08:00
|
|
|
myplane.track = plane.track;
|
2013-02-04 06:20:29 +08:00
|
|
|
myplane.flight = plane.flight;
|
2013-01-27 08:37:05 +08:00
|
|
|
if (myplane.hex == Selected)
|
|
|
|
refreshSelectedInfo();
|
2013-01-13 08:39:29 +08:00
|
|
|
} else {
|
2013-01-17 03:25:28 +08:00
|
|
|
marker = new google.maps.Marker({
|
2013-01-13 08:39:29 +08:00
|
|
|
position: new google.maps.LatLng(plane.lat, plane.lon),
|
|
|
|
map: Map,
|
|
|
|
icon: getIconForPlane(plane)
|
|
|
|
});
|
|
|
|
plane.marker = marker;
|
2013-01-27 08:37:05 +08:00
|
|
|
marker.planehex = plane.hex;
|
2013-01-13 08:39:29 +08:00
|
|
|
Planes[plane.hex] = plane;
|
2013-01-27 08:37:05 +08:00
|
|
|
|
|
|
|
/* Trap clicks for this marker. */
|
|
|
|
google.maps.event.addListener(marker, 'click', selectPlane);
|
2013-01-13 08:39:29 +08:00
|
|
|
}
|
2013-01-17 03:25:28 +08:00
|
|
|
if (plane.flight.length == 0)
|
|
|
|
marker.setTitle(plane.hex)
|
|
|
|
else
|
|
|
|
marker.setTitle(plane.flight+' ('+plane.hex+')')
|
2013-01-13 08:39:29 +08:00
|
|
|
}
|
2013-01-27 08:37:05 +08:00
|
|
|
NumPlanes = data.length;
|
2013-01-13 08:39:29 +08:00
|
|
|
|
|
|
|
/* Remove idle planes. */
|
|
|
|
for (var p in Planes) {
|
|
|
|
if (!stillhere[p]) {
|
|
|
|
Planes[p].marker.setMap(null);
|
|
|
|
delete Planes[p];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initialize() {
|
|
|
|
var mapOptions = {
|
|
|
|
center: new google.maps.LatLng(CenterLat, CenterLon),
|
2013-01-17 03:25:28 +08:00
|
|
|
zoom: 5,
|
2013-01-13 08:39:29 +08:00
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
|
|
|
};
|
|
|
|
Map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
|
|
|
|
|
|
|
|
/* Setup our timer to poll from the server. */
|
|
|
|
window.setInterval(function() {
|
|
|
|
fetchData();
|
2013-01-27 08:37:05 +08:00
|
|
|
refreshGeneralInfo();
|
2013-01-13 08:39:29 +08:00
|
|
|
}, 1000);
|
|
|
|
}
|
2013-01-27 08:37:05 +08:00
|
|
|
|
2013-01-13 08:39:29 +08:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="initialize()">
|
2013-01-27 08:37:05 +08:00
|
|
|
<div id="map_canvas" style="width:80%; height:100%"></div>
|
|
|
|
<div id="info">
|
|
|
|
<div>
|
2013-02-02 23:32:42 +08:00
|
|
|
<h1>Dump1090</h1>
|
2013-01-27 08:37:05 +08:00
|
|
|
<p id="geninfo"></p>
|
|
|
|
<p id="selinfo">Click on a plane for info.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2013-01-13 08:39:29 +08:00
|
|
|
</body>
|
|
|
|
</html>
|