I want to show directions for multiple markers on map but i am unable
to do such.

i have a array of markers and with the help of loop on it i am getting
the response from DirectionsService

                        var directionsService = new
google.maps.DirectionsService();

                        directionsDisplay = new 
google.maps.DirectionsRenderer();
                        directionsDisplay.setMap(map);
                        directionsDisplay.setPanel
(document.getElementById("gmapdirections"));
                            for (var i = 1; i < markers.length - 1; i+
+) {
                                if (markers[i].geoCodeAddr && centerIndex !== 
i) {
                                        var request = {
                                                origin: markers[i - 
1].geoCodeAddr,
                                                destination: 
markers[i].geoCodeAddr,
                                                travelMode: 
google.maps.DirectionsTravelMode.DRIVING
                                        };
                                        directionsService.route(request, 
function(response, status) {
                                                if (status == 
google.maps.DirectionsStatus.OK) {
                                                        
directionsDisplay.setDirections(response);


                                                }
                                        });
                                }
                        }

Its obvious it will show last two marks direction as it over write
previous all.
Please let me know if any body have a solution.
-- 
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 [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