>Well you could create them when you create the gdir[j] object itself.
That's exactly what I was trying to do, but I couldn't figure out how
to do it dynamically.
I tried something like this:
for (var j = 0; j < locations.length -1; j++) {
leg[0]=points[j];
leg[1]=points[j+1];
if(transport_type[j]=="A"){
gdir[j-count]=new GDirections("map");
gdir[j-count].loadFromWaypoints(leg);
GEvent.addListener(gdir[j-count], "load", function(){
if (poly[j-count]) map.removeOverlay(poly[j-
count]);
poly[j-count] = gdir[j-count].getPolyline();
map.addOverlay(poly[j-count]);
});
}else{
var polyline = new GPolyline(leg, "#555555", 5);
map.addOverlay(polyline);
count+=1;
}
}
But I couldn't get the addListener function to work with variables
used in the indexes. Any idea why that doesn't work?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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
-~----------~----~----~----~------~----~------~--~---