One problem is that DirectionRenderer
for route is created
directionsDisplay = new google.maps.DirectionsRenderer();
but map is not specified on which directions will be rendered:
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
In createRoute()
start and end points are created:
var start = document.getElementById('start').value;
var waypts = [];
var end = document.getElementById('end').value;
and then used as array and filled up as waypoints in a loop:
for (var i = 0; i < ListBox2.length; i++) {
start.push({
location: ListBox2[0].value,
stopover: true
});
waypts.push({
location: ListBox2[i].value,
stopover: true
});
end.push({
location: ListBox2[ListBox2.length-1].value,
stopover: true
});
}
If ListBox2 has 10 elements, start
and end
will have 10 elements at the end. So, it is not clear what is the source for those two points.
See example at jsbin. start
and end
are hardcoded, waypoints are filled up from faked ListBox2 (0 and last index are skipped).