When you create the DirectionsRenderer api-doc , you can pass the DirectionsRendererOptions api-doc for the constructor function, or you can call the DirectionsRenderer.setOptions method if you want to change the settings for some time after creation.
You can use the preserveViewport property of the DirectionsRendererOptions object to control how the renderer interacts with the map. Setting preserveViewport to true will leave the map display unchanged:
directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setOptions({ preserveViewport: true }); directionsDisplay.setDirections(response); } }
source share