Sorry if I confused you by talking about the directions changed event.
I was trying to say the event is useless because the routeindex is not set 
until  setDirections(response) has completed.

You just need to call setShortestRoute After setDirections

   directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
         directionsDisplay.setDirections(response);
         idx = directionsDisplay.getRouteIndex();
         console.log('idx 2: ', idx);
         setShortestRoute(directionsDisplay.getDirections());
         idx = directionsDisplay.getRouteIndex();
         console.log('idx 3: ', idx);
      }

set idx: 1
test_map.html:103 <http://localhost:51356/Gmap/test_map.html>idx 2: 0
test_map.html:88 <http://localhost:51356/Gmap/test_map.html>set idx: 1
test_map.html:106 <http://localhost:51356/Gmap/test_map.html>idx 3: 1


-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-maps-js-api-v3/-/DVlLXzldqzcJ.
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-js-api-v3?hl=en.

Reply via email to