OK, so i'm trying to generate multiple GDirection Polylines on a
single google map and am having the problem that due to the way I have
coded it each poly replaces the previous resulting in a map with just
the last poly. My list of routes is generated via php so what I now
have is a list of varibles like...
var route1 = ["1,1","2,1"];
var route2 = ["2,2","3,2"];
So within my JS I need to take these and turn them into GDirection
GPolylines to display on my map. The problem I'm having is that I
don't know previously how many routes there will be and don't know of
a way to dynamically create variables in the JS. So, in my init() I've
got...
directions = new GDirections();
directions.loadFromWaypoints(route1, {getPolyline: true});
GEvent.addListener(directions, "load", onGDirectionsLoad);
And the onGDirectionsLoad function looks like this...
function onGDirectionsLoad(){
var poly = directions.getPolyline();
poly.color = "#FF00FF";
map.addOverlay(directions.getPolyline());
}
Any ideas on how I can loop this so each time the onGDirectionsLoad
function is called it can give the direction a new name and similar in
the init . Something like...
var i = 1; //global variable!
directions = new GDirections();
directions.loadFromWaypoints(route[i], {getPolyline: true});
GEvent.addListener(directions, "load", onGDirectionsLoad);
function onGDirectionsLoad(){
rte[i] = directions;
var poly[i] = rte[i].getPolyline();
poly[i].color = "#FF00FF";
map.addOverlay(rte[i].getPolyline());
i++;
}
Please bare in mind I have no previous experience in Javascript or PHP
prior to about 2 weeks ago!
Thanks in advance for any help!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---