[VID-3] Setting docker image tag
[vid.git] / vid / src / main / webapp / static / fusion / gis / js / local.js
1 var pointLayer= null;
2 var animateFlag = false;
3 var frame = 0;
4 var dates = [];
5 var delay = 1000;
6 var intervalId = null;
7 $( document ).ready(function() {
8     map(data2.map.lat,data2.map.lon,data2.map.zoom);
9     pointLayer = new L.layerGroup().addTo(map);
10     var point = getDates(data2.points);
11     drawPoints(data2,point);
12     
13     
14     $('#timeUp').bind('click',function(){
15         delay += 500; 
16         if ( animateFlag ) {
17            clearInterval(intervalId);
18            intervalId = window.setInterval(function(){animate(data2);},delay);
19         }
20     });
21     $('#timeDown').bind('click',function(){
22         if ( delay === 500 ) { return false; }
23         delay -= 500; 
24         if ( animateFlag ) {
25             clearInterval(intervalId);
26            intervalId = window.setInterval(function(){animate(data2);},delay);
27         }
28     });
29     
30     
31     $('#date').bind('change',function(){
32         drawPoints(data2,$('#date').val());
33     });
34     $('#animate').bind('click',function(){
35         if ( animateFlag ) {
36             animateFlag = false; 
37             $('#animate_color').html('Off');
38             $('#animate_color').removeClass('animateOn');
39             $('#animate_color').addClass('animateOff');
40             clearInterval(intervalId);
41         } else {
42             animateFlag = true;
43             $('#animate_color').html('On');
44             $('#animate_color').removeClass('animateOff');
45             $('#animate_color').addClass('animateOn');
46             intervalId = window.setInterval(function(){animate(data2);},delay);
47         }
48     });
49
50     
51 });
52
53 function abc() {
54         var abc = 1;
55         var xyz = "";
56         return nul;
57         
58 }
59
60
61
62 function animate(obj){
63     var point =  dates[frame];
64     drawPoints(obj,point);
65     frame++;
66     if ( frame >= dates.length ) {
67         frame = 0;
68     }
69     $('#currDate').val(point);
70     $('#showDelay').html(delay);
71 }
72
73 function someFunction() {
74         
75         var self = this;
76         var x = 1;
77         var z = self + x;
78 }
79
80
81 /**
82 * drawPoints - Draw the points provided by point(date)     
83 * obj JSON Object - Data for Map
84 * p String - Key (date) from the JSON object. 
85 */
86 function drawPoints(obj,p){
87     pointLayer.clearLayers();
88     var lats = obj.points[p].lats;
89     var lons = obj.points[p].lons;
90     var txt = obj.points[p].text;
91     var fills = obj.points[p].colors;
92     points(lats, lons,txt,fills);
93 }
94
95 /**
96 * Get dates from the list provided in pIn and put them in Select.
97 * then return the fist date.
98 *
99 */
100 function getDates(pIn) {
101     var html = "<option value='na'>--Select--</option>";
102     var c = 0;
103     var ret = 0;
104     for (var d in pIn ) {
105         var val = d.replace('"','');
106         if ( c === 0 ) { ret = val;};
107         html += "<option value='" + d + "'>" + d + "</option>";   
108         dates[c] = val;
109         c++;
110     }
111     $('#date').html(html);
112     return ret;
113 }
114
115 /**
116 * Map - pass argumets to build map as specified Lat/Lon and zoom level
117 * String lat - Latitude
118 * String lon - Longitude 
119 * String zoom - Zoom Level (1-18)
120 *
121 */
122 function map(lat,lon,zoom){ 
123     var map = L.map('map').setView([lat,lon],zoom);
124     map.addControl(new L.control.scale());
125     L.tileLayer('http://gis.openecomp.org/tiles-light/{z}/{x}/{y}.png', {maxZoom:18}).addTo(map);
126     window.L=L;
127     window.map=map;
128 }
129
130 /**
131 * points - pass argumets to points specified Lat/Lon. Text and color for point is also passed. 
132 * Input is either all singe values or all arrays. 
133 * String[] lat - Latitude
134 * String[] lon - Longitude 
135 * String[] text - Single/Array of Text for points
136 * String[] fill - Single/Array of Fill colors.
137 */
138 function points(lat,lon,text,fill){
139     if(lat.length) {
140         for(i=0;i<lat.length;i++) {
141             pointLayer.addLayer(L.circleMarker([lat[i], lon[i]], { 
142                 radius:"5", 
143                 color: fill[i], 
144                 fillColor: fill[i], 
145                 fillOpacity: "0.5" }).bindPopup(text[i]));
146
147             /*
148             L.circleMarker([lat[i], lon[i]], { 
149                 radius:"5", 
150                 color: fill[i], 
151                 fillColor: fill[i], 
152                 fillOpacity: "0.5" }).addTo(map).bindPopup(text[i]);
153
154             */
155         
156         }
157         
158     } else {
159         L.circleMarker([lat, lon], { 
160             radius:"5", 
161             color:fill, 
162             fillColor:fill, 
163             fillOpacity: "0.5" 
164         }).addTo(map).bindPopup(text);
165     }
166 }
167
168 /**
169 *  Get data from json file and creat return an object of data. 
170 * Returns json object. 
171 *
172 **/
173 function getData(){
174     $.getJSON( "./data.json", function( data ) {
175         return data;
176     });
177     
178 }