function evSpeedColor(e)
{
    var mph = e.speedMPH;
    var green  = [   0, 210, 0 ];
    var yellow = [ 240, 240, 0 ];
    var red    = [ 255,   0, 0 ];
    if (mph > 70.0) {
        // return green
        return rgbHex(green[0], green[1], green[2]);
    } else
    if (mph >= 20.0) {
        // fade from yellow to green
        var D = (mph - 20.0) / (70.0 - 20.0);
        var R = ((green[0] - yellow[0]) * D) + yellow[0];
        var G = ((green[1] - yellow[1]) * D) + yellow[1];
        var B = ((green[2] - yellow[2]) * D) + yellow[2];
        return rgbHex(R, G, B);
    } else
    if (mph >= 0.0) {
        // fade from red to yellow
        var D = (mph - 0.0) / (20.0 - 0.0);
        var R = ((yellow[0] - red[0]) * D) + red[0];
        var G = ((yellow[1] - red[1]) * D) + red[1];
        var B = ((yellow[2] - red[2]) * D) + red[2];
        return rgbHex(R, G, B);
    } else {
        // return black
        return "000000";
    }

}
/**
*** Pushpin:
*** Calculate and return a color based on the event speed.
*** This algorithm performs the following:
***  - If the speed is greater than 70 mph, the returned color is green.
***  - If the speed is between 20 and 70 mph, the color will be a mix between yellow and green.
***  - If the speed is between  0 and 20 mph, the color will be a mix between red and yellow.
*** @param e  The 'MapEventRecord' object
**/
Calculate and return a color based on the event speed.
This algorithm performs the following:
If the speed is greater than 70 mph, the returned color is green.
If the speed is between 20 and 70 mph, the color will be a mix between yellow and green.
If the speed is between  0 and 20 mph, the color will be a mix between red and yellow.
Calculate and return a color based on the event speed . This algorithm performs the following : If the speed is greater than 70 mph the returned color is green . If the speed is between 20 and 70 mph the color will be a mix between yellow and green . If the speed is between 0 and 20 mph the color will be a mix between red and yellow .
function evSpeedColor(e)
{
    var mph = e.speedMPH;
    var green  = [   0, 210, 0 ];
    var yellow = [ 240, 240, 0 ];
    var red    = [ 255,   0, 0 ];
    if (mph > 70.0) {
        return rgbHex(green[0], green[1], green[2]);
    } else
    if (mph >= 20.0) {
        var D = (mph - 20.0) / (70.0 - 20.0);
        var R = ((green[0] - yellow[0]) * D) + yellow[0];
        var G = ((green[1] - yellow[1]) * D) + yellow[1];
        var B = ((green[2] - yellow[2]) * D) + yellow[2];
        return rgbHex(R, G, B);
    } else
    if (mph >= 0.0) {
        var D = (mph - 0.0) / (20.0 - 0.0);
        var R = ((yellow[0] - red[0]) * D) + red[0];
        var G = ((yellow[1] - red[1]) * D) + red[1];
        var B = ((yellow[2] - red[2]) * D) + red[2];
        return rgbHex(R, G, B);
    } else {
        return "000000";
    }
}
function evSpeedColor ( e ) { var mph = e . speedMPH ; var green = [ 0 , 210 , 0 ] ; var yellow = [ 240 , 240 , 0 ] ; var red = [ 255 , 0 , 0 ] ; if ( mph > 70.0 ) { return rgbHex ( green [ 0 ] , green [ 1 ] , green [ 2 ] ) ; } else if ( mph >= 20.0 ) { var D = ( mph - 20.0 ) / ( 70.0 - 20.0 ) ; var R = ( ( green [ 0 ] - yellow [ 0 ] ) * D ) + yellow [ 0 ] ; var G = ( ( green [ 1 ] - yellow [ 1 ] ) * D ) + yellow [ 1 ] ; var B = ( ( green [ 2 ] - yellow [ 2 ] ) * D ) + yellow [ 2 ] ; return rgbHex ( R , G , B ) ; } else if ( mph >= 0.0 ) { var D = ( mph - 0.0 ) / ( 20.0 - 0.0 ) ; var R = ( ( yellow [ 0 ] - red [ 0 ] ) * D ) + red [ 0 ] ; var G = ( ( yellow [ 1 ] - red [ 1 ] ) * D ) + red [ 1 ] ; var B = ( ( yellow [ 2 ] - red [ 2 ] ) * D ) + red [ 2 ] ; return rgbHex ( R , G , B ) ; } else { return "000000" ; } }
Pushpin:
Calculate and return a color based on the event speed.
Pushpin : Calculate and return a color based on the event speed .
// return green // fade from yellow to green // fade from red to yellow // return black