I\'ve got an existing app that tracks vehicles and renders their polyline on a map, and I want to be able to import these polylines into another app using the routing servic
waypoints.push(new google.maps.LatLng(coordinates[index].lat(), coordinates[index].lng()));
the 'waypoints' property of the DirectionsRequest object definition should be an Array of google.maps.DirectionsWaypoint object definitions https://developers.google.com/maps/documentation/javascript/3.exp/reference#DirectionsWaypoint
So, try:
waypoints.push(
{
location: new google.maps.LatLng(coordinates[index].lat(), coordinates[index].lng())
}
);