Okay I've isolated the problem to this function:
function processPolyLines(colour) {
var xmlDoc = GXml.parse(request.responseText);
for ( var j = 0; j < 12; j++) {
inc += 1;
if (j < 9) {
checkpoint = ("lineTFT00" + inc);
} else {
checkpoint = ("lineTFT0" + inc);
}
var lines =
xmlDoc.documentElement.getElementsByTagName(checkpoint);
// There are 12 lines, however the problem here is that only 1
line
is being detected.
alert("The length of lines is " + lines.length);
for
( var a = 0; a < lines.length; a++) {
alert(a); // This loop only goes up to 0 and no higher,
hence
colours more than the
// index of 0 cannot be plotted.
var width = parseFloat(lines[a].getAttribute("width"));
var points = lines[a].getElementsByTagName("point");
// alert(a);
var pts = [];
for (var i = 0; i < points.length; i++) {
pts[i] = new GLatLng(parseFloat(points[i]
.getAttribute("latPoly")),
parseFloat(points[i]
.getAttribute("longPoly")));
}
p[a] = new GPolyline(pts,colour,width)
map.addOverlay(p[a]);
}
}
Now my XML file has a structure like this:
<datapoints>
<lineTFT001> latitude=" " longitude=" " In here are the
latitiude and longitude points for this segment of the road </
lineTFT001>
.
.
<lineTFT012> latitude=" " longitude= " " In here are the
latitiude and longitude points for this segment of the road </
lineTFT012>
</datapoints>
Near the 1st "for loop" if I place:
alert(checkpoint);
right beneath:
var lines = xmlDoc.documentElement.getElementsByTagName(checkpoint);
Then when the map loads it shows me the message boxes => lineTFT001,
lineTFT002, lineTFT003....lineTFT012. So clearly what I have here is
12 lines.
However if I place:
alert("The length of lines is " + lines.length);
beneath the same statement mentioned just above the message boxes I
get are only: 1, 1, 1, 1 etc... but total 12 times before the map is
painted on the canvas,
Now the 2nd "for loop" works by plotting each TAG seperately. However
since the length of "line" I am getting is only 1 this loop is not
going any higher up to 12 times that it should to plot all the coords
in the 12 TAGs. So ( var a = 0; a < lines.length; a++) is not looping
for 12 times that it should, instead it's only looping once, so my "a"
variable is not getting any higher than 0.
This is the reason why if I pass any index value (corresponding to a
particular line) in the changeColors(lineIndex, color) function, only
an index of 0 is being painted with a colour, anything higher is not.
So any ideas on how I can modify my code such that regardless of
whatever "lineIndex" value I pass (from 0 to 11) that the
corresponding TAG will be called and paint the colour I want? I'm sure
I did somethign wrong here but I can't see it.
Thanks
PS: no free web hosts support jsp (im using tomcat FYI)
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.