I managed to add two points to Google Directions route - start and end point, but I'm interested to adding more end points like on this site: http://www.bikeroutetoaster.com/Course.aspx
When user adds third point, the route is continuing, but waypoint on second point stays. This is my code:
function addRoute(event) {
if(markers.length < 2){
var marker = new google.maps.Marker({
position: event.latLng,
map: map,
draggable: true
});
markers.push(marker);
}
if(markers.length == 2){
var start = markers[0].getPosition();
var end = markers[1].getPosition();
putDirections(start, end);
$(markers).each(function(i, marker){
google.maps.event.addListener(marker, 'dragend', function(){
clearDirections();
var start = markers[0].getPosition();
var end = markers[1].getPosition();
putDirections(start, end);
});
});
}
}