2 var animateFlag = false;
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);
14 $('#timeUp').bind('click',function(){
17 clearInterval(intervalId);
18 intervalId = window.setInterval(function(){animate(data2);},delay);
21 $('#timeDown').bind('click',function(){
22 if ( delay === 500 ) { return false; }
25 clearInterval(intervalId);
26 intervalId = window.setInterval(function(){animate(data2);},delay);
31 $('#date').bind('change',function(){
32 drawPoints(data2,$('#date').val());
34 $('#animate').bind('click',function(){
37 $('#animate_color').html('Off');
38 $('#animate_color').removeClass('animateOn');
39 $('#animate_color').addClass('animateOff');
40 clearInterval(intervalId);
43 $('#animate_color').html('On');
44 $('#animate_color').removeClass('animateOff');
45 $('#animate_color').addClass('animateOn');
46 intervalId = window.setInterval(function(){animate(data2);},delay);
62 function animate(obj){
63 var point = dates[frame];
64 drawPoints(obj,point);
66 if ( frame >= dates.length ) {
69 $('#currDate').val(point);
70 $('#showDelay').html(delay);
73 function someFunction() {
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.
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);
96 * Get dates from the list provided in pIn and put them in Select.
97 * then return the fist date.
100 function getDates(pIn) {
101 var html = "<option value='na'>--Select--</option>";
104 for (var d in pIn ) {
105 var val = d.replace('"','');
106 if ( c === 0 ) { ret = val;};
107 html += "<option value='" + d + "'>" + d + "</option>";
111 $('#date').html(html);
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)
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);
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.
138 function points(lat,lon,text,fill){
140 for(i=0;i<lat.length;i++) {
141 pointLayer.addLayer(L.circleMarker([lat[i], lon[i]], {
145 fillOpacity: "0.5" }).bindPopup(text[i]));
148 L.circleMarker([lat[i], lon[i]], {
152 fillOpacity: "0.5" }).addTo(map).bindPopup(text[i]);
159 L.circleMarker([lat, lon], {
164 }).addTo(map).bindPopup(text);
169 * Get data from json file and creat return an object of data.
170 * Returns json object.
174 $.getJSON( "./data.json", function( data ) {