There is a task to build two routes from the starting point to the final, through the intermediate ones. Since I’m a complete zero in JS, I started looking for ready-made solutions ... it turned out to build routes from the initial to the end point, but I’m not able to specify intermediate ones, if I try to indicate that the route is not built at all, the problem occurs in the waypoints line, if you remove it then .
function initialize() { var mapOptions = { zoom: 10, center: new google.maps.LatLng(55.904779, 37.541202), mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); directionsService = new google.maps.DirectionsService(); directionsService.route({ origin: "55.904779, 37.54120", destination: "55.908560,37.597723", waypoints: "55.905731, 37.591735", optimizeWaypoints: true, travelMode: google.maps.DirectionsTravelMode.DRIVING }, function(result) { renderDirections(result, { strokeColor:'#ff0000' }); }); setTimeout(function() { map.setZoom(12); }, 2000); }