I want to have a large map of berlin from which you see multiple routes. Unfortunately a DirectionsRenderer zooms to the route so you have to manually zoom out again.
In my case, this worked for me:
let directionsService = new google.maps.DirectionsService();
// always pass the `preserveViewport` to maintain the zoom ratio when using directionsRenderer
let directionsRenderer = new google.maps.DirectionsRenderer({map:this.map,preserveViewport: true});
//store the request state in an object ` use 'google.maps.TravelMode.DRIVING' instead of 'DRIVING'`
var request = {
origin: {query:start},
destination: {query:end},
travelMode: google.maps.TravelMode.DRIVING,
};
directionsService.route(request, function (response, status) {
directionsRenderer.setDirections(response);
// const route = request.routes;
})
i didn't have to pass the setMap method.