Hi, thanks for the replies, I need do it in the loop because I need know the polylines between two points(in the load listener I call var gp=directions.getPolyline();). If I do this out of the loop I will get the polylines between the first and last point. Therfore, if I create the GDirections object in the loop is possible that the listener work in the loop?
Thanks. On 30 nov, 01:06, Andrew Leach <[email protected]> wrote: > On Nov 29, 11:26 pm, molistok <[email protected]> wrote: > > > > > But I can see that when I call loadFromWaypoints into the loop then > > don't go to the listener method. If I call loadFromWaypoints out of > > the loop then works. > > Yes: see the > documentation:http://code.google.com/apis/maps/documentation/reference.html#GDirect... > "If a previous load() request has not completed when a new call to load > () is invoked, the previous request is cancelled. Thus, you can use a > single GDirections object to issue directions requests serially, but > to generate multiple requests in parallel, you must use multiple > GDirections objects." > > Every time round your loop you cancel the request you just issued. > > > How I can use listeners in a loop? > > You need to issue the next directions request from within the load > listener function (that is, you don't do it in a "for" loop). > > However, I'm not sure what you are hoping to achieve with your > existing code, even if you could do directions in parallel like that. > What is your intended result? There may be a better way of getting > there. > > Andrew -- 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.
