2014-03-20 09:43:08 +00:00
<!doctype html>
< html >
< head >
2014-09-17 13:38:23 +00:00
< script src = "../3rdparty/jquery/jquery-1.11.1.min.js"
2014-03-20 09:43:08 +00:00
type="text/javascript">< / script >
< link rel = "stylesheet"
2014-09-17 13:38:23 +00:00
href="../3rdparty/leaflet-0.7.3/leaflet.css" />
< script src = "../3rdparty/leaflet-0.7.3/leaflet.js" > < / script >
2014-09-15 08:19:14 +00:00
< script src = "../3rdparty/flot/jquery.flot.js" > < / script >
2014-03-20 09:43:08 +00:00
< script src = "../lib/props.js" type = "text/javascript" > < / script >
2014-03-28 17:36:19 +00:00
< script src = "../lib/jquery.flot.prop.js" > < / script >
2014-03-20 09:43:08 +00:00
< meta charset = "UTF-8" / >
< meta name = "description" content = "FlightGear - Map" / >
2014-03-24 13:29:25 +00:00
< meta name = "viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
2014-09-15 08:19:14 +00:00
< meta name = "apple-mobile-web-app-capable" content = "yes" >
2014-09-17 07:42:25 +00:00
< link rel = "apple-touch-icon" href = "/img/FlightGear_logo.png" >
2014-09-15 08:19:14 +00:00
< meta name = "mobile-web-app-capable" content = "yes" >
2014-09-17 07:42:25 +00:00
< meta name = "apple-mobile-web-app-status-bar-style" content = "black" >
< meta name = "format-detection" content = "telephone=no" >
< link rel = "shortcut icon" sizes = "200x200" href = "/img/FlightGear_logo.png" >
< link rel = "icon" sizes = "200x200" href = "/img/FlightGear_logo.png" >
2014-09-15 08:19:14 +00:00
2014-03-28 17:36:19 +00:00
< title > FlightGear - Map< / title >
2014-03-20 09:43:08 +00:00
< / head >
< body >
< style >
2014-03-23 20:28:17 +00:00
html,body,#map {
2014-03-20 09:43:08 +00:00
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
2014-03-23 20:28:17 +00:00
2014-03-24 13:29:25 +00:00
.infobox {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
.infobox h4 {
margin: 0 0 5px;
color: #777;
}
2014-03-24 15:41:54 +00:00
.followAircraft {
2014-03-28 17:36:19 +00:00
background: white;
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
width: 40px;
height: 40px;
}
.altitudePlotter {
background: white;
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
width: 1200px;
height: 200px;
2014-03-24 15:41:54 +00:00
}
2014-03-28 17:36:19 +00:00
.axisLabel {
2014-09-15 08:19:14 +00:00
position: absolute;
text-align: center;
font-size: 12px;
2014-03-28 17:36:19 +00:00
}
.yaxisLabel {
2014-09-15 08:19:14 +00:00
top: 50%;
left: 2px;
transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
transform-origin: 0 0;
-o-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-webkit-transform-origin: 0 0;
2014-03-28 17:36:19 +00:00
}
.xaxisLabel {
2014-09-15 08:19:14 +00:00
top: 90%;
left: 45%;
2014-03-28 17:36:19 +00:00
}
2014-09-15 08:19:14 +00:00
.ie7 .yaxisLabel,.ie8 .yaxisLabel {
top: 40%;
font-size: 36px;
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.0, M12=0.33, M21=-0.33,
M22=0.0, sizingMethod='auto expand');
2014-03-28 17:36:19 +00:00
}
2014-03-20 09:43:08 +00:00
< / style >
< div id = 'map' > < / div >
< script type = "text/javascript" >
/* < ![CDATA[ */
var map = new L.Map('map', {
center : [ 53.7, 10.0 ],
zoom : 10
});
2014-10-09 20:11:52 +00:00
var osm = new L.TileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
2014-03-20 09:43:08 +00:00
maxZoom : 18,
attribution : 'Map data © < a href = "http://openstreetmap.org" > OpenStreetMap< / a > contributors'
});
map.addLayer(osm);
var MAP_ICON = {};
MAP_ICON["VOR"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/vor.svg",
});
MAP_ICON["NDB"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/ndb.svg",
});
2014-03-23 20:28:17 +00:00
MAP_ICON["dme"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/dme.svg",
});
MAP_ICON["airport-paved"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/airport-paved.svg",
});
MAP_ICON["airport-unpaved"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/airport-unpaved.svg",
});
MAP_ICON["airport-unknown"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/airport-unknown.svg",
});
2014-03-24 13:29:25 +00:00
MAP_ICON["arp"] = L.icon({
iconSize : [ 30, 30 ],
iconAnchor : [ 15, 15 ],
popupAncor : [ 0, -17 ],
iconUrl : "images/arp.svg",
});
2014-09-15 08:19:14 +00:00
MAP_ICON["aircraft"] = L.icon({
iconSize : [ 20, 20 ],
iconAnchor : [ 10, 10 ],
popupAncor : [ 0, -12 ],
iconUrl : "images/aircraft.svg",
});
2014-03-24 13:29:25 +00:00
L.RotatedMarker = L.Marker.extend({
options : {
angle : 0
},
2014-03-23 20:28:17 +00:00
2014-03-24 13:29:25 +00:00
_setPos : function(pos) {
2014-03-23 20:28:17 +00:00
L.Marker.prototype._setPos.call(this, pos);
2014-03-24 13:29:25 +00:00
2014-03-23 20:28:17 +00:00
if (L.DomUtil.TRANSFORM) {
2014-03-24 13:29:25 +00:00
// use the CSS transform rule if available
this._icon.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.angle + 'deg)';
} else if (L.Browser.ie) {
// fallback for IE6, IE7, IE8
var rad = this.options.angle * (Math.PI / 180), costheta = Math.cos(rad), sintheta = Math.sin(rad);
this._icon.style.filter += ' progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\'auto expand\', M11=' + costheta
+ ', M12=' + (-sintheta) + ', M21=' + sintheta + ', M22=' + costheta + ')';
2014-03-23 20:28:17 +00:00
}
2014-03-24 13:29:25 +00:00
}
});
2014-03-20 09:43:08 +00:00
2014-03-24 13:29:25 +00:00
var navdbLayer = new L.geoJson(null, {
pointToLayer : function(feature, latlng) {
2014-03-23 20:28:17 +00:00
var options = {
2014-03-24 13:29:25 +00:00
title : feature.id + ' (' + feature.properties.name + ')',
alt : feature.id,
riseOnHover : true,
2014-03-23 20:28:17 +00:00
};
2014-03-24 13:29:25 +00:00
if (feature.properties.type == "airport") {
2014-03-23 20:28:17 +00:00
options.angle = feature.properties.longestRwyHeading_deg;
2014-03-24 13:29:25 +00:00
switch (feature.properties.longestRwySurface) {
2014-03-23 20:28:17 +00:00
case 'asphalt':
case 'concrete':
options.icon = MAP_ICON['airport-paved'];
break;
case 'unknown':
options.icon = MAP_ICON['airport-unknown'];
break;
default:
options.icon = MAP_ICON['airport-unpaved'];
break;
}
} else {
if (feature.properties.type in MAP_ICON) {
options.icon = MAP_ICON[feature.properties.type];
}
}
2014-03-24 13:29:25 +00:00
return new L.RotatedMarker(latlng, options);
2014-03-23 20:28:17 +00:00
},
2014-03-20 09:43:08 +00:00
onEachFeature : function(feature, layer) {
if (feature.properties) {
var popupString = '< div class = "popup" > ';
for ( var k in feature.properties) {
var v = feature.properties[k];
popupString += k + ': ' + v + '< br / > ';
}
popupString += '< / div > ';
layer.bindPopup(popupString, {
maxHeight : 200
});
}
2014-03-21 12:02:50 +00:00
},
2014-03-23 20:28:17 +00:00
2014-03-24 20:57:38 +00:00
filter : function(feature, layer) {
var zoom = map.getZoom();
2014-03-28 17:36:19 +00:00
switch (feature.properties.type) {
2014-03-24 20:57:38 +00:00
case 'airport':
2014-03-28 17:36:19 +00:00
if (zoom >= 10)
return true;
2014-03-24 20:57:38 +00:00
return feature.properties.longestRwyLength_m >= 2000;
break;
case 'NDB':
2014-03-28 17:36:19 +00:00
if (zoom >= 10)
return true;
if (zoom >= 8)
return feature.properties.range_nm >= 30;
2014-03-24 20:57:38 +00:00
return feature.properties.range_nm > 50;
}
return true;
},
2014-03-24 13:29:25 +00:00
style : function(feature) {
if (feature.properties.type == "ILS" || feature.properties.type == "localizer") {
2014-03-21 12:02:50 +00:00
return {
2014-03-24 13:29:25 +00:00
color : 'black',
weight : 1,
2014-03-21 12:02:50 +00:00
};
}
2014-03-24 13:29:25 +00:00
if (feature.properties.type == "airport") {
2014-03-23 22:16:11 +00:00
return {
2014-03-24 13:29:25 +00:00
color : 'black',
weight : 3,
fill : 'true',
fillColor : '#606060',
fillOpacity : 1.0,
lineJoin : 'bevel',
2014-03-23 22:16:11 +00:00
};
}
2014-03-24 13:29:25 +00:00
},
2014-03-20 09:43:08 +00:00
});
2014-03-24 13:29:25 +00:00
navdbLayer.dirty = true;
2014-11-10 21:27:18 +00:00
2014-03-24 13:29:25 +00:00
navdbLayer.update = function() {
if (navdbLayer.dirty) {
navdbLayer.dirty = false;
var bounds = map.getBounds();
var radius = bounds.getSouthWest().distanceTo(bounds.getNorthEast()) / 3704; // radius in NM
if (radius > 250)
radius = 250;
if (radius < 10 )
radius = 10;
2014-03-24 20:57:38 +00:00
var filter = "vor,ndb,airport";
2014-03-24 13:29:25 +00:00
if (radius < 60 )
2014-03-24 20:57:38 +00:00
filter += ",ils,dme,loc,om";
2014-03-24 13:29:25 +00:00
if (radius < 20 )
filter += ",mm";
var center = map.getCenter();
var lat = center.lat;
var lon = center.lng;
var url = "/navdb?q=findWithinRange& type=" + filter + "& range=" + radius + "& lat=" + lat + "& lon=" + lon;
2014-03-28 17:36:19 +00:00
2014-03-24 13:29:25 +00:00
var jqxhr = $.get(url).done(function(data) {
navdbLayer.clearLayers();
navdbLayer.addData(data);
}).fail(function() {
alert('failed to load navdb data');
}).always(function() {
});
}
2014-03-28 17:36:19 +00:00
setTimeout(function() {
navdbLayer.update()
}, 5000);
2014-03-24 13:29:25 +00:00
};
2014-03-20 09:43:08 +00:00
map.addLayer(navdbLayer);
2014-09-15 08:19:14 +00:00
var aiLayer = new L.geoJson(null, {
pointToLayer : function(feature, latlng) {
var options = {
title : feature.id + ' (' + feature.properties.name + ')',
alt : feature.id,
riseOnHover : true,
};
if (feature.properties.type == "aircraft" || feature.properties.type == "multiplayer") {
options.angle = feature.properties.heading;
options.icon = MAP_ICON["aircraft"];
}
return new L.RotatedMarker(latlng, options);
},
onEachFeature : function(feature, layer) {
if (feature.properties) {
var popupString = '< div class = "popup" > ';
for ( var k in feature.properties) {
var v = feature.properties[k];
popupString += k + ': ' + v + '< br / > ';
}
popupString += '< / div > ';
layer.bindPopup(popupString, {
maxHeight : 200
});
}
},
filter : function(feature, layer) {
return true;
},
style : function(feature) {
if (feature.properties.type == "airport") {
return {
color : 'black',
weight : 3,
fill : 'true',
fillColor : '#606060',
fillOpacity : 1.0,
lineJoin : 'bevel',
};
}
},
});
aiLayer.aiPropsToGeoJson = function(props, types) {
var geoJSON = {
type : "FeatureCollection",
features : [],
};
var getChild = function(p, n, idx) {
if (p & & p.children) {
if (idx == null)
idx = 0;
for (var i = 0; i < p.children.length ; i + + ) {
var child = p.children[i];
if (child.name == n & & child.index == idx) {
return child;
}
}
}
return null;
};
var getChildren = function(p, n) {
var reply = [];
if (p & & p.children) {
p.children.forEach(function(child) {
if (child.name == n)
reply.push(child);
});
}
return reply;
};
if (props) {
types.forEach(function(type) {
var aiModels = getChildren(props, type);
aiModels.forEach(function(aiModel) {
var lat = -999;
var lon = -999;
var heading = 0;
var tas = 0;
var vspeed = 0;
var callsign = "";
var n = getChild(aiModel, "callsign");
if (n)
callsign = n.value;
var positionNode = getChild(aiModel, "position");
if (positionNode) {
var n = getChild(positionNode, "latitude-deg");
if (n)
lat = n.value;
var n = getChild(positionNode, "longitude-deg");
if (n)
lon = n.value;
}
var orientationNode = getChild(aiModel, "orientation");
if (orientationNode) {
var n = getChild(orientationNode, "true-heading-deg");
heading = n.value;
}
var velocitiesNode = getChild(aiModel, "velocities");
if (velocitiesNode) {
var n = getChild(orientationNode, "true-airspeed-kt");
if (n)
tas = n.value;
var n = getChild(orientationNode, "vertical-speed-fps");
if (n)
vspeed = n.value;
}
geoJSON.features.push({
"type" : "Feature",
"geometry" : {
"type" : "Point",
"coordinates" : [ lon, lat ],
},
"properties" : {
"type" : aiModel.name,
"heading" : heading,
"tas" : tas,
"vspeed" : vspeed,
"id" : callsign,
},
});
});
});
}
return geoJSON;
};
aiLayer.update = function() {
// fetch the entire property subtree under /ai/models
var url = "/json/ai/models?d=99";
var jqxhr = $.get(url).done(function(data) {
var types = [ "aircraft", "multiplayer", "carrier" ];
aiLayer.clearLayers();
aiLayer.addData(aiLayer.aiPropsToGeoJson(data, types));
}).fail(function() {
alert('failed to load multiplayer data');
}).always(function() {
});
setTimeout(function() {
aiLayer.update()
}, 5000);
};
map.addLayer(aiLayer);
2014-10-09 20:11:52 +00:00
2014-03-20 09:43:08 +00:00
var baseLayers = {
"OpenStreetMaps" : osm,
2014-10-09 20:11:52 +00:00
"MapQuest Satelite" : new L.TileLayer(
'http://otile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png',
{
maxZoom : 18,
subdomains : [ '1', '2', '3', '4' ],
attribution : 'Tiles Courtesy of < a href = "http://www.mapquest.com/" target = "_blank" > MapQuest< / a > .'
}),
"MapQuest Roads" : new L.TileLayer(
'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png',
{
maxZoom : 18,
subdomains : [ '1', '2', '3', '4' ],
attribution :
'Tiles Courtesy of < a href = "http://www.mapquest.com/" target = "_blank" > MapQuest< / a > . Map data (c) < a href = "http://www.openstreetmap.org/" target = "_blank" > OpenStreetMap< / a > contributors, CC-BY-SA.'
}),
2014-03-20 09:43:08 +00:00
};
var overlays = {
"NAVDB" : navdbLayer,
2014-09-15 08:19:14 +00:00
"AI" : aiLayer,
2014-10-09 20:11:52 +00:00
"VFRMap.com Sectionals (US)" : new L.TileLayer(
'http://vfrmap.com/20140918/tiles/vfrc/{z}/{y}/{x}.jpg',
{
maxZoom : 12,
minZoom : 3,
attribution : '(c) < a href = "VFRMap.com" > VFRMap.com< / a > ',
tms: true,
opacity: 0.5,
bounds: L.latLngBounds(L.latLng(16.0,-179.0), L.latLng(72.0,-60.0) ),
}),
"VFRMap.com - Low IFR (US)" : new L.TileLayer(
'http://vfrmap.com/20140918/tiles/ifrlc/{z}/{y}/{x}.jpg',
{
maxZoom : 12,
minZoom : 5,
attribution : '© < a href = "VFRMap.com" > VFRMap.com< / a > ',
tms: true,
opacity: 0.5,
bounds: L.latLngBounds(L.latLng(16.0,-179.0), L.latLng(72.0,-60.0) ),
}),
"dfs.de VFR" : new L.TileLayer(
'https://secais.dfs.de/static-maps/ICAO500-2014-DACH-Reprojected_01/tiles/{z}/{x}/{y}.png',
{
minZoom : 5,
maxZoom : 15,
attribution : 'Map data © < a href = "http://www.dfs.de" > DFS< / a > ',
bounds: L.latLngBounds(L.latLng(46.0,5.0), L.latLng(55.1,16.5) ),
}),
"Lower Airspace (Germany)" : new L.TileLayer(
'https://secais.dfs.de/static-maps/lower_20131114/tiles/{z}/{x}/{y}.png',
{
minZoom : 5,
maxZoom : 15,
attribution : 'Map data © < a href = "http://www.dfs.de" > DFS< / a > ',
bounds: L.latLngBounds(L.latLng(46.0,5.0), L.latLng(55.1,16.5) ),
}),
"Precipitation" : new L.TileLayer(
'http://{s}.tile.openweathermap.org/map/precipitation/{z}/{x}/{y}.png',
{
maxZoom : 14,
minZoom : 0,
subdomains : '12',
format : 'image/png',
transparent : true,
opacity : 0.5
}),
"Isobares" : new L.TileLayer(
'http://{s}.tile.openweathermap.org/map/pressure_cntr/{z}/{x}/{y}.png',
{
maxZoom : 7,
minZoom : 0,
subdomains : '12',
format : 'image/png',
transparent : true,
opacity : 0.5
}),
2014-03-20 09:43:08 +00:00
};
2014-03-24 13:29:25 +00:00
var aircraftMarker = new L.RotatedMarker(map.getCenter(), {
angle : 45,
2014-11-10 21:27:18 +00:00
draggable: true,
2014-03-24 13:29:25 +00:00
icon : L.icon({
2014-03-23 20:28:17 +00:00
iconSize : [ 60, 60 ],
iconAnchor : [ 30, 30 ],
popupAncor : [ 0, -32 ],
iconUrl : "images/aircraft.svg",
2014-03-24 22:24:53 +00:00
}),
2014-03-28 17:36:19 +00:00
zIndexOffset : 10000,
2014-03-23 20:28:17 +00:00
});
2014-03-20 09:43:08 +00:00
aircraftMarker.addTo(map);
2014-11-10 21:27:18 +00:00
aircraftMarker.isDragging = false;
2014-03-20 09:43:08 +00:00
aircraftMarker.setState = function(s) {
2014-11-10 21:27:18 +00:00
if( this.isDragging ) return;
2014-03-20 09:43:08 +00:00
var latlng = new L.LatLng(s.lat, s.lon);
2014-03-23 20:28:17 +00:00
aircraftMarker.options.angle = s.heading;
2014-03-20 09:43:08 +00:00
aircraftMarker.setLatLng(latlng);
var label = "< p id = 'aircraft-label' > heading:" + s.heading + "° GS: " + s.speed + "kt< / p > ";
aircraftMarker.bindPopup(label);
2014-03-24 13:29:25 +00:00
info.update(s);
2014-03-20 09:43:08 +00:00
};
2014-11-10 21:27:18 +00:00
aircraftMarker.on('dragstart',function(evt){
evt.target.isDragging = true;
});
aircraftMarker.on('dragend',function(evt){
var pos = evt.target.getLatLng();
var props = {
name: "position",
children: [
{
name: "latitude-deg",
value: pos.lat,
},
{
name: "longitude-deg",
value: pos.lng,
},
],
};
$.post( "/json/", JSON.stringify(props));
evt.target.isDragging = false;
});
2014-03-20 09:43:08 +00:00
2014-03-24 13:29:25 +00:00
var info = L.control();
info.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'infobox');
this.update();
return this._div;
2014-03-20 09:43:08 +00:00
};
2014-03-24 13:29:25 +00:00
info.update = function(props) {
var s = '< h4 > Flight Path< / h4 > ';
if (props) {
s += '< p > ';
s += 'MH:' + props.heading + '° < br / > ';
s += 'GS: ' + props.speed + 'kt< br / > ';
s += 'ALT: ' + props.alt + 'ft';
s += '< / p > ';
}
this._div.innerHTML = s;
};
2014-11-10 21:27:18 +00:00
/*
2014-03-28 17:36:19 +00:00
var altitudePlotter = L.control({
position : 'bottomright'
});
altitudePlotter.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'altitudePlotter');
this._div.innerHTML = '< h4 > Altitude< / h4 > ';
return this._div;
};
altitudePlotter.initPlotter = function(map) {
var container = $(".altitudePlotter");
var w = $("#map").innerWidth() * .9;
2014-09-15 08:19:14 +00:00
container.css('width', w);
2014-03-28 17:36:19 +00:00
this.maxData = container.outerWidth() / 2 || 300;
var series = [ {
propertyPath : "/position/altitude-ft",
data : [],
2014-09-15 08:19:14 +00:00
color : 'blue',
2014-03-28 17:36:19 +00:00
lines : {
fill : true
}
} ];
this.plot = $.plot(container, series, {
2014-09-15 08:19:14 +00:00
historyLength : 600,
2014-03-28 17:36:19 +00:00
grid : {
borderWidth : 1,
minBorderMargin : 20,
labelMargin : 10,
backgroundColor : {
colors : [ "#fff", "#e4f4f4" ]
},
margin : {
top : 8,
bottom : 20,
left : 20
},
},
xaxis : {
min : 0,
max : 60,
},
yaxis : {
min : 0,
max : 1000
},
legend : {
show : true
}
});
2014-09-15 08:19:14 +00:00
this.yaxisLabel = $("< div class = 'axisLabel yaxisLabel' > < / div > ").text("Altitude (ft)").appendTo(container);
2014-03-28 17:36:19 +00:00
2014-09-15 08:19:14 +00:00
this.xaxisLabel = $("< div class = 'axisLabel xaxisLabel' > < / div > ").text("Simulation time (s)").appendTo(container);
2014-03-28 17:36:19 +00:00
};
altitudePlotter.addTo(map);
altitudePlotter.initPlotter(map);
2014-11-10 21:27:18 +00:00
*/
2014-03-24 15:41:54 +00:00
var FollowAircraftControl = L.control();
FollowAircraftControl.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'followAircraft');
this._div.innerHTML = '< img src = "images/followAircraft.svg" title = "Center Map on Aircraft Position" / > ';
2014-03-28 17:36:19 +00:00
this._div.onclick = function() {
toggleFollowAircraft();
return true;
};
2014-03-24 15:41:54 +00:00
return this._div;
}
2014-03-28 17:36:19 +00:00
2014-03-24 20:57:38 +00:00
L.control.scale().addTo(map);
info.addTo(map);
2014-03-24 15:41:54 +00:00
FollowAircraftControl.addTo(map);
2014-10-09 20:11:52 +00:00
2014-03-24 20:57:38 +00:00
L.control.layers(baseLayers, overlays).addTo(map);
2014-03-24 13:29:25 +00:00
2014-03-20 09:43:08 +00:00
map.on('resize', function(e) {
2014-03-24 13:29:25 +00:00
navdbLayer.dirty = true;
2014-03-20 09:43:08 +00:00
});
map.on('zoomend', function(e) {
2014-03-24 13:29:25 +00:00
navdbLayer.dirty = true;
2014-03-20 09:43:08 +00:00
});
map.on('moveend', function(e) {
2014-03-24 13:29:25 +00:00
navdbLayer.dirty = true;
2014-03-20 09:43:08 +00:00
});
2014-03-28 17:36:19 +00:00
2014-03-24 15:41:54 +00:00
map.on('dragstart', function(e) {
followAircraft = false;
});
var followAircraft = true;
function toggleFollowAircraft() {
followAircraft = !followAircraft;
}
2014-03-20 09:43:08 +00:00
$(document).ready(function() {
var aircraftState = {
lat : 53.5,
lon : 10.0,
heading : 0,
2014-03-24 13:29:25 +00:00
speed : 0,
alt : 0,
2014-03-20 09:43:08 +00:00
};
2014-03-24 13:29:25 +00:00
navdbLayer.update();
2014-09-15 08:19:14 +00:00
aiLayer.update();
2014-03-20 09:43:08 +00:00
2014-03-28 17:36:19 +00:00
var latlng;
var i = 0;
2014-03-20 09:43:08 +00:00
setInterval(function() {
2014-03-28 17:36:19 +00:00
latlng = new L.LatLng(aircraftState.lat, aircraftState.lon);
if (followAircraft) {
if (++i % 10 == 0)
map.setView(latlng);
}
2014-03-20 09:43:08 +00:00
aircraftMarker.setState(aircraftState);
2014-03-28 17:36:19 +00:00
}, 100);
2014-03-20 09:43:08 +00:00
PropertyChangeListener(function() {
2014-11-10 21:27:18 +00:00
/*
2014-03-24 13:29:25 +00:00
SetListener("/position/altitude-ft", function(n) {
aircraftState.alt = Math.round(n.value);
2014-03-28 17:36:19 +00:00
altitudePlotter.plot.plotPropertyNode(n);
2014-03-24 13:29:25 +00:00
});
2014-11-10 21:27:18 +00:00
*/
2014-03-20 09:43:08 +00:00
SetListener("/position/latitude-deg", function(n) {
aircraftState.lat = n.value;
});
SetListener("/position/longitude-deg", function(n) {
aircraftState.lon = n.value;
});
SetListener("/orientation/heading-deg", function(n) {
aircraftState.heading = Math.round(n.value);
});
SetListener("/velocities/groundspeed-kt", function(n) {
aircraftState.speed = Math.round(n.value);
});
});
});
/* ]]> */
< / script >
< / body >
< / html >