- Timestamp:
- 01/24/2020 12:53:15 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/webapps/GTEC/js/vdsLayer.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/GTEC/js/vdsLayer.js
r556 r566 1 1 var postmileList = []; // the list of postmiles saved from the json file. 2 2 var chosenColor = null; 3 3 4 4 Array.prototype.diff = function(a) { … … 29 29 30 30 // Load the map data from a json file and style all the points 31 function initializeVDSlayer()31 function loadVDSlayer() 32 32 { 33 33 // Load the static map data and call saveCoords when done … … 112 112 }); 113 113 white_arr = []; 114 if (chosenColor) 115 { 116 clicked_dots.forEach(function (dot) { 117 dot.setProperty("color", chosenColor); 118 }); 119 } 120 114 121 // Assemble the line to be written to the events file 115 var lineOut = "0:01:00 " + range.toFixed(3); 122 var lineOut = "181 00:00:00 " + first[0] + " " + 123 first[1] + " " + first[2] + " " + range.toFixed(3) + " " 124 + getColorAbbr(chosenColor); 116 125 117 126 // Using Ajax POST to send the data 118 127 var xhr = new XMLHttpRequest(); 119 xhr.open("POST", "../ cgi-bin/saveTrafficEvent.py", true);128 xhr.open("POST", "../../cgi-bin/saveTrafficEvent.py", true); 120 129 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 121 130 // send the collected data … … 228 237 // see if new color is different than current color 229 238 currentFeature = map.data.getFeatureById(target); 230 currentColor = currentFeature.getProperty("color"); 231 // if a new color is desired then assign it to the feature's color property 232 if (currentColor != newColor) 233 { 234 currentFeature.setProperty("color", newColor); 235 // set zIndex for slowed traffic to a higher value so they overlap 236 currentFeature.setProperty("zIndex", colorZvalues[newColor]); 239 if (currentFeature) { 240 currentColor = currentFeature.getProperty("color"); 241 // if a new color is desired then assign it to the feature's color property 242 if (currentColor != newColor) 243 { 244 currentFeature.setProperty("color", newColor); 245 // set zIndex for slowed traffic to a higher value so they overlap 246 currentFeature.setProperty("zIndex", colorZvalues[newColor]); 247 } 237 248 } 238 249 } … … 275 286 else if (str === "G\r" || str === "G") 276 287 return "lime"; 288 } 289 290 function getColorAbbr(str){ 291 if (str === "red") 292 return "R"; 293 else if (str === "yellow") 294 return "Y"; 295 else if (str === "lime") 296 return "G"; 277 297 } 278 298 … … 402 422 }*/ 403 423 424 function initColorButtons() 425 { 426 var redColor = document.getElementById('redButton'); 427 var greenColor = document.getElementById('greenButton'); 428 var yellowColor = document.getElementById('yellowButton'); 429 map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(redColor); 430 map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(greenColor); 431 map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(yellowColor); 432 redColor.addEventListener('click', function() { 433 chosenColor = "red"; 434 }); 435 greenColor.addEventListener('click', function() { 436 chosenColor = "lime"; 437 }); 438 yellowColor.addEventListener('click', function(){ 439 chosenColor = "yellow"; 440 }); 441 } 442 404 443 // init beginning, forward and back buttons as well as time display on map 405 function initControlButtons()444 /*function initControlButtons() 406 445 { 407 446 var i = 0; 408 /*var time = document.getElementById('time');447 var time = document.getElementById('time'); 409 448 map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(time) 410 449 var start = document.getElementById('start'); … … 446 485 i = 0; 447 486 time.innerHTML = "00:00:00"; 448 }); */487 }); 449 488 } 450 489 */
Note: See TracChangeset
for help on using the changeset viewer.
