// Define our global variables var GoogleMap = null; var Planes = {}; var PlanesOnMap = 0; var PlanesOnTable = 0; var PlanesToReap = 0; var SelectedPlane = null; var SpecialSquawk = false; var iSortCol=-1; var bSortASC=true; var bDefaultSortASC=true; var iDefaultSortCol=3; // Get current map settings CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT; CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON; ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL; Dump1090Version = "unknown version"; RefreshInterval = 1000; function fetchData() { $.getJSON('data/aircraft.json', function(data) { PlanesOnMap = 0 SpecialSquawk = false; // Loop through all the planes in the data packet for (var j=0; j < data.length; j++) { // Do we already have this plane object in Planes? // If not make it. if (Planes[data[j].hex]) { var plane = Planes[data[j].hex]; } else { var plane = jQuery.extend(true, {}, planeObject); } // Set SpecialSquawk-value if (data[j].squawk == '7500' || data[j].squawk == '7600' || data[j].squawk == '7700') { SpecialSquawk = true; } // Call the function update plane.funcUpdateData(data[j]); // Copy the plane into Planes Planes[plane.icao] = plane; } PlanesOnTable = data.length; }); } function initialize() { // Get receiver metadata, reconfigure using it, then continue // with initialization $.getJSON('data/receiver.json') .done(function(data) { if (typeof data.lat !== "undefined") { SiteShow = true; SiteLat = data.lat; SiteLon = data.lon; } Dump1090Version = data.version; RefreshInterval = data.refresh; }) .always(initialize_after_config); } // Initalizes the map and starts up our timers to call various functions function initialize_after_config() { // Make a list of all the available map IDs var mapTypeIds = []; for(var type in google.maps.MapTypeId) { mapTypeIds.push(google.maps.MapTypeId[type]); } // Push OSM on to the end mapTypeIds.push("OSM"); mapTypeIds.push("dark_map"); // Styled Map to outline airports and highways var styles = [ { "featureType": "administrative", "stylers": [ { "visibility": "off" } ] },{ "featureType": "landscape", "stylers": [ { "visibility": "off" } ] },{ "featureType": "poi", "stylers": [ { "visibility": "off" } ] },{ "featureType": "road", "stylers": [ { "visibility": "off" } ] },{ "featureType": "transit", "stylers": [ { "visibility": "off" } ] },{ "featureType": "landscape", "stylers": [ { "visibility": "on" }, { "weight": 8 }, { "color": "#000000" } ] },{ "featureType": "water", "stylers": [ { "lightness": -74 } ] },{ "featureType": "transit.station.airport", "stylers": [ { "visibility": "on" }, { "weight": 8 }, { "invert_lightness": true }, { "lightness": 27 } ] },{ "featureType": "road.highway", "stylers": [ { "visibility": "simplified" }, { "invert_lightness": true }, { "gamma": 0.3 } ] },{ "featureType": "road", "elementType": "labels", "stylers": [ { "visibility": "off" } ] } ] // Add our styled map var styledMap = new google.maps.StyledMapType(styles, {name: "Dark Map"}); // Define the Google Map var mapOptions = { center: new google.maps.LatLng(CenterLat, CenterLon), zoom: ZoomLvl, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: true, streetViewControl: false, mapTypeControlOptions: { mapTypeIds: mapTypeIds, position: google.maps.ControlPosition.TOP_LEFT, style: google.maps.MapTypeControlStyle.DROPDOWN_MENU } }; GoogleMap = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); //Define OSM map type pointing at the OpenStreetMap tile server GoogleMap.mapTypes.set("OSM", new google.maps.ImageMapType({ getTileUrl: function(coord, zoom) { return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; }, tileSize: new google.maps.Size(256, 256), name: "OpenStreetMap", maxZoom: 18 })); GoogleMap.mapTypes.set("dark_map", styledMap); // Listeners for newly created Map google.maps.event.addListener(GoogleMap, 'center_changed', function() { localStorage['CenterLat'] = GoogleMap.getCenter().lat(); localStorage['CenterLon'] = GoogleMap.getCenter().lng(); }); google.maps.event.addListener(GoogleMap, 'zoom_changed', function() { localStorage['ZoomLvl'] = GoogleMap.getZoom(); }); // Add home marker if requested if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) { var siteMarker = new google.maps.LatLng(SiteLat, SiteLon); var markerImage = new google.maps.MarkerImage( 'http://maps.google.com/mapfiles/kml/pal4/icon57.png', new google.maps.Size(32, 32), // Image size new google.maps.Point(0, 0), // Origin point of image new google.maps.Point(16, 16)); // Position where marker should point var marker = new google.maps.Marker({ position: siteMarker, map: GoogleMap, icon: markerImage, title: 'My Radar Site', zIndex: -99999 }); if (SiteCircles) { for (var i=0;i