Search code examples
javascriptgoogle-maps-api-3directions

Access to google maps api directions markers


I need to add listeners for directions markers, but haven't any access. How can I get access to direction markers like simple markers? Sorry for my terrible English, I hope you can understand me.

UPD: I create a new route:

var request = {
    origin: someorigin,
    destination: somedestination,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
};

directionsService.route(request, function(response, status){
    if (status == google.maps.DirectionsStatus.OK){
        directionsDisplay.setDirections(response);
    }
});

And now I want to get access to the origin and destination markers.


Solution

  • You can't access markers added to the map via the google.maps.DirectionsRenderer class. You can however use the suppressMarkers option, render the polyline route and then add your own start and destination markers with your own events.

    Hope this helps.