Working on adding paths to the planes.

This commit is contained in:
Brian Davenport 2013-05-22 03:26:40 +00:00
parent c43c922148
commit caf413cc01

View file

@ -1,8 +1,8 @@
// Define our global variables // Define our global variables
var GoogleMap = null; var GoogleMap = null;
var CenterLat = 45.0; var CenterLat = 35.21928;
var CenterLon = 9.0; var CenterLon = -80.94406;
var ZoomLvl = 5; var ZoomLvl = 9;
var Planes = {}; var Planes = {};
var PlanesOnMap = 0; var PlanesOnMap = 0;
var PlanesOnTable = 0; var PlanesOnTable = 0;
@ -42,7 +42,9 @@ planeObject = {
// GMap Details // GMap Details
marker : null, marker : null,
trackdata : null, lines : [],
trackdata : new Array(),
trackline : new Array(),
// When was this last updated? // When was this last updated?
updated : null, updated : null,
@ -52,6 +54,18 @@ planeObject = {
// Only useful for a long running browser session. // Only useful for a long running browser session.
funcAddToTrack : function(){ funcAddToTrack : function(){
// TODO: Write this function out // TODO: Write this function out
this.trackdata.push([this.latitude, this.longitude, this.altitude, this.track, this.speed]);
this.trackline.push(new google.maps.LatLng(this.latitude, this.longitude));
},
// This is to remove the line from the screen if we deselect the plane
funcClearLine : function() {
console.log("Clearing line for: " + this.icao);
if (this.line) {
this.line.setMap(null);
this.line = null;
x = 2 + 2;
}
}, },
// Should create an icon for us to use on the map... // Should create an icon for us to use on the map...
@ -71,7 +85,7 @@ planeObject = {
// TODO: Trigger actions of a selecting a plane // TODO: Trigger actions of a selecting a plane
funcSelectPlane : function(selectedPlane){ funcSelectPlane : function(selectedPlane){
selectPlaneByHex(this.icao);
}, },
// Update our data // Update our data
@ -102,6 +116,10 @@ planeObject = {
this.marker.setMap(null); this.marker.setMap(null);
this.marker = null; this.marker = null;
} }
if (this.line) {
this.line.setMap(null);
this.line = null;
}
if (SelectedPlane == this.icao) { if (SelectedPlane == this.icao) {
SelectedPlane = null; SelectedPlane = null;
} }
@ -131,6 +149,9 @@ planeObject = {
} }
if ((changeLat == true) || (changeLon == true) || (changeAlt == true)) { if ((changeLat == true) || (changeLon == true) || (changeAlt == true)) {
this.funcAddToTrack(); this.funcAddToTrack();
if (this.icao == SelectedPlane) {
this.line = this.funcUpdateLines();
}
} }
this.marker = this.funcUpdateMarker(); this.marker = this.funcUpdateMarker();
PlanesOnMap++; PlanesOnMap++;
@ -158,6 +179,9 @@ planeObject = {
visable: true, visable: true,
}); });
// This is so we can match icao address
this.marker.icao = this.icao;
// Trap clicks for this marker. // Trap clicks for this marker.
google.maps.event.addListener(this.marker, 'click', this.funcSelectPlane); google.maps.event.addListener(this.marker, 'click', this.funcSelectPlane);
} }
@ -170,6 +194,26 @@ planeObject = {
} }
return this.marker; return this.marker;
}, },
// Update our planes tail line,
// TODO: Make this multi colored based on options
// altitude (default) or speed
funcUpdateLines: function() {
if (this.line) {
var path = this.line.getPath();
path.push(new google.maps.LatLng(this.latitude, this.longitude));
} else {
console.log("Starting new line");
this.line = new google.maps.Polyline({
strokeColor: '#000000',
strokeOpacity: 1.0,
strokeWeight: 3,
map: GoogleMap,
path: this.trackline,
});
}
return this.line;
},
}; };
function fetchData() { function fetchData() {
@ -211,10 +255,19 @@ function initialize() {
// Styled Map to outline airports and highways // Styled Map to outline airports and highways
var styles = [ var styles = [
{ {
"featureType": "administrative",
"stylers": [ "stylers": [
{ "visibility": "simplified" }, { "visibility": "off" }
{ "weight": 1 }, ]
{ "invert_lightness": true } },{
"featureType": "landscape",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
] ]
},{ },{
"featureType": "road", "featureType": "road",
@ -226,23 +279,39 @@ function initialize() {
"stylers": [ "stylers": [
{ "visibility": "off" } { "visibility": "off" }
] ]
},{
"featureType": "landscape",
"stylers": [
{ "visibility": "on" },
{ "weight": 8 },
{ "color": "#000000" }
]
},{
"featureType": "water",
"stylers": [
{ "lightness": -74 }
]
},{ },{
"featureType": "transit.station.airport", "featureType": "transit.station.airport",
"stylers": [ "stylers": [
{ "visibility": "on" }, { "visibility": "on" },
{ "weight": 8 },
{ "invert_lightness": true }, { "invert_lightness": true },
{ "gamma": 0.43 } { "lightness": 27 }
] ]
},{ },{
"featureType": "poi", "featureType": "road.highway",
"stylers": [
{ "visibility": "simplified" },
{ "invert_lightness": true },
{ "gamma": 0.3 }
]
},{
"featureType": "road",
"elementType": "labels",
"stylers": [ "stylers": [
{ "visibility": "off" } { "visibility": "off" }
] ]
},{
"featureType": "road.highway.controlled_access",
"stylers": [
{ "visibility": "simplified" }
]
} }
] ]
@ -505,5 +574,8 @@ function sortTable(szTableID,iCol) {
} }
function selectPlaneByHex(hex) { function selectPlaneByHex(hex) {
x = 2 + 2;
Planes[SelectedPlane].funcClearLine();
SelectedPlane = hex; SelectedPlane = hex;
} }