Hi Ronny,

Thanks for response,

As you are showing directions for two different routes as A to B And
then an other A to B but i want to show as A to B Then B to C and so
on.
your code helped me to write the code but still same its showing
Direction for last two points only.

Code is here,

                                var directionsService = [];
                                var directionsDisplay = [];
                                for (var i = 0; i < markers.length - 1; i++) {
                                        directionsService[i] = new 
google.maps.DirectionsService();
                                        directionsDisplay[i] = new 
google.maps.DirectionsRenderer({ map:
map, preserveViewport: true });
                                }
                                for (var i = 1; i < markers.length - 1; i++) {
                                        if (markers[i].geoCodeAddr) {
                                                var route = {
                                                        origin: markers[i - 
1].geoCodeAddr,
                                                        destination: 
markers[i].geoCodeAddr,
                                                        travelMode: 
google.maps.DirectionsTravelMode.DRIVING
                                                };
                                                directionsService[i - 
1].route(route, function(response, status)
{
                                                        if (status == 
google.maps.DirectionsStatus.OK) {
                                                                var 
objDirDisplay = directionsDisplay[i - 1];
                                                                if 
(objDirDisplay) {
                                                                        
objDirDisplay.setDirections(response);
                                                                } else {
                                                                        
alert('problem');
                                                                }
                                                        }
                                                        else {
                                                                alert("the 
googlemaps direction calculation returned status
\"" + status + "\" which is not ok");
                                                        }
                                                });
                                        }
                                }

 Firstly i use directionsService and directionsDisplay  in Loop but it
was overwriting so just for check i created array for them,
 Please let me know if you or anyone have a solution for it.

On Jan 9, 10:18 pm, Ronny Aerts <[email protected]> wrote:
> Can you take a look 
> athttp://www.grasoft.be/mtb/gmap/route-v3.htm<http://www.grasoft.biz/mtb/gmap/route-v3.htm>
> where
> I load 2 directions. Is this what your are looking for?
>
> The point is that you need to have a service and display for each call you
> do.
>
> kind regards,
> Ronny Aerts - Belgium
-- 
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