Google Map API v3 different setTrackColour for each different xml file?
<p>I would like to know what wrong with my coding?
I'm trying to make different color for each different XML file.
In the coding that I attached, as you can see if canal is 002 and their route will change their color to <strong>RED</strong>.</p>



<pre class="lang-js prettyprint-override"><code>parser.setTrackColour("#ff0000");     // Set the track line colour
</code></pre>

<p>For the other if canal is 003 their route will change their color to <strong>BLACK</strong>.</p>

<pre class="lang-js prettyprint-override"><code>parser.setTrackColour("#000000");     // Set the track line colour
</code></pre>

<p>This is my example full coding for your reference. </p>

<pre class="lang-js prettyprint-override"><code>if(canal == "002"){
    function loadGPXFileIntoGoogleMap(map, filename) {
        $.ajax({url: filename,
            dataType: "xml",
            success: function(data) {
                var parser = new GPXParser(data, map);
                parser.setTrackColour("#ff0000");     // Set the track line colour
                parser.setTrackWidth(5);          // Set the track line width
                parser.setMinTrackPointDelta(0.001);      // Set the minimum distance between track points
                parser.centerAndZoom(data);
                parser.addTrackpointsToMap();         // Add the trackpoints
                parser.addWaypointsToMap();           // Add the waypoints

            }
        });
    }

    $(document).ready(function() {
        var mapOptions = {
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map"), mapOptions);
        loadGPXFileIntoGoogleMap(map, "routeXML/a.xml");
    });
}else
if(canal == "003"){
    function loadGPXFileIntoGoogleMap(map, filename) {
        $.ajax({url: filename,
            dataType: "xml",
            success: function(data) {
                var parser = new GPXParser(data, map);
                parser.setTrackColour("#000000");     // Set the track line colour
                parser.setTrackWidth(5);          // Set the track line width
                parser.setMinTrackPointDelta(0.001);      // Set the minimum distance between track points
                parser.centerAndZoom(data);
                parser.addTrackpointsToMap();         // Add the trackpoints
                parser.addWaypointsToMap();           // Add the waypoints
            }
        });
    }

    $(document).ready(function() {
        var mapOptions = {
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map"), mapOptions);
        loadGPXFileIntoGoogleMap(map, "routeXML/b.xml");
    });
}   
</code></pre>

<p>Can someone please explain why I can't get what it should be?</p>