Changeset 528 in tmcsimulator for trunk/webapps/visualizer
- Timestamp:
- 11/19/2019 06:47:43 AM (6 years ago)
- Location:
- trunk/webapps/visualizer
- Files:
-
- 2 edited
-
index.html (modified) (3 diffs)
-
js/vdsLayer.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/visualizer/index.html
r516 r528 48 48 <button id="cmsButton" class="unstyled-button"><img id="cmsBtnImg" src="images/btnReady_CMS.png"></button>--> 49 49 <button id="vdsButton" class="unstyled-button"><img id="vdsBtnImg" src="images/btnDepressed_VDS.png"></button> 50 <p id="time"> Time</p>50 <p id="time">00:00:00</p> 51 51 <button id="start" >Beginning</button> 52 52 <button id="forward" >Next</button> 53 <button id="backward" >Back</button> 53 54 <script src="../common/js/fileutils.js"></script> 54 55 <script src="../common/js/revision_number.dat"></script> … … 95 96 var filters = []; //array to hold markers for visualizer 96 97 var times = []; //array to hold times of each traffic event 98 times[0] = "00:00:00"; 99 var diff_arr = []; // array to hold difference in target markers 97 100 var index = -1; //to index into above array 98 101 … … 154 157 155 158 updateVDSlayer(); 159 setTimeout(function() { 160 buildDiff(); 161 updateVDSlayer(); 162 }, 3000); 156 163 157 164 // Listen for zoom changes and move the vds dots so as to keep a nice -
trunk/webapps/visualizer/js/vdsLayer.js
r516 r528 60 60 // go adjust the marker coordinates so dots don't overlap 61 61 adjustCoords(calcDistanceFactor()); 62 } 62 } 63 63 64 64 // magic formula controls distance between dots proportionate to zoom factor … … 114 114 } 115 115 116 function storePrev(marker, targetMarkers) 117 { 118 target = marker.id; 119 newColor = marker.properties.color; 120 // see if new color is different than current color 121 currentFeature = map.data.getFeatureById(target); 122 currentColor = currentFeature.getProperty("color"); 123 // if a new color is desired then assign it to the feature's color property 124 if (currentColor != newColor) 125 { 126 targetMarkers.push({"id" : currentFeature.getId(), 127 "properties" : {"color" : currentColor}}); 128 } 129 } 116 130 117 131 // Load the highways dynamic json file and update the map … … 178 192 // updates color for each marker based on color in filters array 179 193 function updateVDS(forwards) { 180 index++; 181 if (filters[index] !== undefined){ 182 filters[index].forEach(function(item){ 183 item.marker.properties.color = item.color; 184 updateMarker(item.marker); 185 }); 194 if (forwards) { 195 index++; 196 if (index >= filters.length) 197 { 198 index = filters.length - 1; 199 } 200 if (filters[index] !== undefined) { 201 filters[index].forEach(function(item){ 202 item.marker.properties.color = item.color; 203 updateMarker(item.marker); 204 }); 205 } 206 } 207 else { 208 if (diff_arr[index] !== undefined) { 209 diff_arr[index].forEach(function(item){ 210 updateMarker(item); 211 }); 212 } 213 index--; 214 if (index < -1) 215 { 216 index = -1; 217 } 218 } 219 } 220 221 function buildDiff() 222 { 223 for (var i = 0; i <= filters.length; i++) 224 { 225 if (filters[i] !== undefined) 226 { 227 var targetMarkers = new Array(); 228 filters[i].forEach(function(item){ 229 item.marker.properties.color = item.color; 230 storePrev(item.marker, targetMarkers); 231 updateMarker(item.marker); 232 }); 233 diff_arr.push(targetMarkers); 234 } 186 235 } 187 236 } … … 230 279 var forward = document.getElementById('forward'); 231 280 map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(forward) 281 var backward = document.getElementById('backward'); 282 map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(backward) 232 283 forward.title = 'Click to see the next event'; 233 console.log(times);284 //console.log(diff_arr); 234 285 forward.addEventListener('click', function() { 235 286 updateVDS(1); 236 if (i < times.length) 237 time.innerHTML = times[i++]; 287 if (i < times.length - 1) 288 { 289 ++i; 290 time.innerHTML = times[i]; 291 } 238 292 }); 293 backward.addEventListener('click', function() { 294 updateVDS(0); 295 if (i > 0) 296 { 297 --i; 298 time.innerHTML = times[i]; 299 } 300 }); 239 301 start.addEventListener('click', function() { 240 302 updateVDSlayer(); 241 303 i = 0; 242 time.innerHTML = " Time"304 time.innerHTML = "00:00:00"; 243 305 }); 244 306 }
Note: See TracChangeset
for help on using the changeset viewer.
