Basically I want to turn off the feature that centers the map on each turn when you click on Directions Panel step.

Is there a way to disable that feature?

PS: i tried:

suppressMarkers: true,
suppressInfoWindows: true,

but those only take out the markers and infowindows - it still centers the map on the turn point when its clicked.

有帮助吗?

解决方案 2

So this is what I ended up doing:

function getDirections()
{   
    var request = 
    {
        origin: start,
        destination: end,
        travelMode: google.maps.TravelMode.DRIVING
    };

    var summaryPanel = document.getElementById('directions_steps');

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

            directionsDisplay.setMap(map);
            directionsDisplay.setDirections(response);      

            var legs = response.routes[0].legs; 

            for (var leg = 0; leg < legs.length; leg++) {
                for (var step = 0; step < legs[leg].steps.length;
                step++) {
                    if (legs[leg].steps[step].lat_lngs) {                       
                        summaryPanel.innerHTML += legs[leg].steps[step].instructions+"<br/><br/>";                                                      
                    }
                }
            }

        }
    });
}

其他提示

You can render the DirectionsPanel yourself (rather than using the DirectionsRenderer). That gives you complete control.

Example

Completely late, but for future references what worked for me was commenting these lines:

var directionsRenderer = new google.maps.DirectionsRenderer({
            draggable: true,
            map: map//,
            //panel: document.getElementById('right-panel') step directions instructions here
        });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top