No, I am using the DirectionsRenderer to display the routes on the map, but I am handling the display of instuctions with my own function. The basic problem seems to be that calling setRouteIndex(1) or setRouteIndex(2) on the DirectionsRenderer object before calling setDirections(result) has no effect -- the DirectionsRenderer still renders route 0 on the map, even though calling getRouteIndex shows that the route index has been set to 1 or 2 rather than 0. I am able to display the instructions for the alternate paths by accessing the alternate routes in the result object, but I can't get DirectionsRenderer to render the alternate paths on the map.
Your answer will be helpful if I have to resort to rendering the paths on the map myself. On Sep 21, 3:33 am, stu <s...@hybridweb.co.nz> wrote: > Hi > I'd guess that if you are rendering the results to the map yourself, > that you can't then use DirectionsRenderer to get to routes. > > I presume you are getting the results object and either using the > overview_path or going through the legs, steps etc to build the > polyline, > In that case you *can* use the result object which has an array of the > routes (as long as the DirectionsRequest has provideRouteAlternatives > set to true) > if your DirectionsRequest result is called directionsResult, then you > just ask for the routes like > directionsResult.routes[n] where n is the index for one of the > routes. > > To get your basic polyline path for route number 2: > directionsResult.routes[1].overview_path > > Does that help? > ...stu > > On Sep 21, 2:52 pm, bmcf <brian.mcf...@gmail.com> wrote: > > > > > I should have made it clear that I am not using the .setPanel method > > on the DirectionsRenderer, I am trying to handle the display of > > directions with my own function. > > > On Sep 20, 2:31 am, bmcf <brian.mcf...@gmail.com> wrote: > > > > I would like to have the map show alternate routes on demand. It > > > initially shows the first route in the "result" by default (there are > > > three routes). I tried calling .setRouteIndex(1) and > > > then .setDirections(result) on the DirectionsRenderer object but the > > > second route was not rendered on the map. Is this not the way to do > > > it? > > > > Thanks.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to google-maps-js-api...@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.