문제

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