score:1

function calculateAndDisplayRoute(directionsService, directionsRenderer)
{
  var selectedMode = document.getElementById("mode").value;
  directionsService.route(
    {
      origin: Your Origin Values,
      destination: Your Destination Values,
      travelMode: google.maps.TravelMode[selectedMode]
    },
    (response, status) => {
      if (status == "OK") {
        directionsRenderer.setDirections(response);
      }
      else {
        window.alert("Directions request failed due to " + status);
      }
    }
  );
}

Related Query

More Query from same tag