I'm using this bit of code that I retrieved on these forums before (I
believe from Larry)

var directionsService = new google.maps.DirectionsService();
                                var request = {
                                        origin: new 
g.LatLng(49.266054,-123.256227),
                                        destination: new 
g.LatLng(49.261796,-122.572415),
                                        waypoints: [
                                                {
                                                        location: new 
g.LatLng(49.26319, -123.11271),
                                                        stopover: false
                                                },
                                                {
                                                        location: new 
g.LatLng(49.26193, -123.03379),
                                                        stopover: false
                                                },
                                                {
                                                        location: new 
g.LatLng(49.22978, -122.77764),
                                                        stopover: false
                                                },
                                                {
                                                        location: new 
g.LatLng(49.22019, -122.63567),
                                                        stopover: false
                                                }

                                                        ],
                                        travelMode: 
google.maps.DirectionsTravelMode.DRIVING
                                };

                                var polyline = new google.maps.Polyline({
                                        path: [],
                                        strokeColor: '#FF0000',
                                        strokeWeight: 3
                                });

                                directionsService.route(request, 
function(result, status) {
                                        if (status == 
google.maps.DirectionsStatus.OK) {
                                                var bounds = new
google.maps.LatLngBounds();
                                                var path = 
result.routes[0].overview_path;
                                                var legs = 
result.routes[0].legs;
                                                for
(i=0;i<legs.length;i++) {
                                                   var steps =
legs[i].steps;
                                                   for
(j=0;j<steps.length;j++) {
                                                     var nextSegment =
steps[j].path;
                                                     for
(k=0;k<nextSegment.length;k++) {
 
polyline.getPath().push(nextSegment[k]);
 
bounds.extend(nextSegment[k]);
                                                     }
                                                   }
                                                }

                        polyline.setMap(map);
                        map.fitBounds(bounds);

                                        }

                                });


The polyline is created, but I can't figure out how to create a
clickable marker at the start of the polyline that automatically
contains the directions of this polyline.  Any ideas?  Of course I
could just create a marker at this position and fill in the directions
myself, but I would like to use the automatic directions (much like
regular google maps direction service gives turn by turn instructions)

Thanks

-- 
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