Blame view

app/partials/flightTracking/flightTracking.controller.js 3.73 KB
e196b9b74   Anchit Jindal   new changes added
1
2
3
  'use strict';
  
  angular.module('acufuel')
562610b62   Kuldeep Arora   angular interval ...
4
  .controller('flightTrackingController', ['$scope','$compile', 'uiCalendarConfig', 'flightTrackingService','$interval', function($scope, $compile, uiCalendarConfig, flightTrackingService,$interval) {
f9e936a9d   Anchit Jindal   minor fixes
5
  	$scope.flightInfo = {};
429786996   Kuldeep Arora   live flight track...
6
7
8
9
10
  	var map;
  	var icon = "https://en.spitogatos.gr/visualCaptcha/images/airplane.png";
  	var json = "http://34.214.139.94:8080/ws/liveTracking";
  	var arr = [];
  	var infowindow = new google.maps.InfoWindow();
2b4e85bad   Anchit Jindal   minor chages
11

19eace1cf   Anchit Jindal   minor
12
13
  	$scope.initialise = function() {
  		var mapProp = {
562610b62   Kuldeep Arora   angular interval ...
14
  	        center: new google.maps.LatLng(36.778259, -98.417931), //US center
429786996   Kuldeep Arora   live flight track...
15
16
17
  	        zoom: 4,
  	        mapTypeId: google.maps.MapTypeId.ROADMAP
  	    };
562610b62   Kuldeep Arora   angular interval ...
18
19
  	    //getting fligts one time on instant pageload 
  	    getFlights();
429786996   Kuldeep Arora   live flight track...
20
  	    map = new google.maps.Map(document.getElementById("map"), mapProp);
2b4e85bad   Anchit Jindal   minor chages
21
  	    console.log('sssssssss', json);
429786996   Kuldeep Arora   live flight track...
22
  	    
562610b62   Kuldeep Arora   angular interval ...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  	    
  
  		var stopflight=$interval(function(){
  			console.log('====interval start=======');
  			//getting flights on each interval
  			getFlights();
  		},4000);
  		
  
  	/*---Stop flights in case state change---*/
  	 $scope.$on("$destroy",function(){
  		console.log('====live data stop-=====');
  	    if (angular.isDefined(stopflight)) {
  	        $interval.cancel(stopflight);
      }
  });	
  
  }
  
  	/*---Get live flight data function---- */
  
  	var getFlights=function(){
  	$.get(json, function(json1) {
  	      $.each(json1, function(key, data) {
  	    	  var exists = false;
  		  	    $.each(arr, function (index, value) {
  		   		   if(value.title === data.id) {
  		   			  var latLng = new google.maps.LatLng(data.latitude, data.longitude, data.altitude);
  		   			  value.link.setPosition(latLng);
  		   			  exists = true;
  		   		   }
  		        });
  		  	  if(!exists) {
  		  		  var latLng = new google.maps.LatLng(data.latitude, data.longitude, data.altitude);
  					
  		        var marker = new google.maps.Marker({
  		          position: latLng,
  		          map: map,
  		          icon: icon,
  		          title: data.id
  		        });
  		        
fc9e6dc66   Kuldeep Arora   minor
65
  		       var details = "Aircraft :" + " " + data.id + "<br> " +
562610b62   Kuldeep Arora   angular interval ...
66
  		            "Path :" + " " + data.departurePoint + " " + "--->" + " " + data.arrivalPoint + "<br>" +
fc9e6dc66   Kuldeep Arora   minor
67
68
69
70
71
  		            "Altitude :" + " " + data.altitude + " " + "ft" + "<br>" +
  		            "Speed :" + " " + data.speed + " " + "Knots" + "<br>" +
  		            "Departure Time :" + " " + data.departureActualTime + " " + "(Actual)" + "<br>" +
  		            "Arrival Time :" + " " + data.arrivalEstimatedTime + " " + "(Estimated)" + "<br>";
  			     arr.push({
562610b62   Kuldeep Arora   angular interval ...
72
73
74
75
76
77
78
79
80
81
82
83
  		            title: data.id,
  		            link:  marker,
  		            details : details
  		        });
  		        
  		        bindInfoWindow(marker, map, infowindow, details, data);
  		  	  }
  	      });
  	});
  }
  
    
429786996   Kuldeep Arora   live flight track...
84

f9e936a9d   Anchit Jindal   minor fixes
85
  	 function bindInfoWindow(marker, map, infowindow, strDescription, data) {
429786996   Kuldeep Arora   live flight track...
86
           google.maps.event.addListener(marker, 'click', function() {
f9e936a9d   Anchit Jindal   minor fixes
87
88
89
90
91
92
93
94
95
96
97
98
99
          	 $scope.flightInfo = data;
               //infowindow.setContent(strDescription);
               //infowindow.open(map, marker);
               $scope.flightInfo = data;
               $('#flightid').html($scope.flightInfo.id);
               $('#depid').html($scope.flightInfo.departurePoint);
               $('#arrid').html($scope.flightInfo.arrivalPoint);
               $('#altid').html($scope.flightInfo.altitude);
               $('#speedid').html($scope.flightInfo.speed);
               $('#deptimeid').html($scope.flightInfo.departureActualTime);
               $('#arrtimeid').html($scope.flightInfo.arrivalEstimatedTime);
               
               $('.left-panel').animate({width: '300px', padding: '10px'});
429786996   Kuldeep Arora   live flight track...
100
101
102
           });
       }
  	 
f9e936a9d   Anchit Jindal   minor fixes
103
104
105
106
  	 $('.close-left-panel').click(function(){
  		 $('.left-panel').animate({width: '0', padding: '0'});
  	 })
  	 
562610b62   Kuldeep Arora   angular interval ...
107
108
109
110
  
  	
  	
  	google.maps.event.addDomListener(document.getElementById("map"), 'load', $scope.initialise());
429786996   Kuldeep Arora   live flight track...
111
  	 
2b4e85bad   Anchit Jindal   minor chages
112
  	
e196b9b74   Anchit Jindal   new changes added
113
  }]);