I am building a waypoints Google map. I have the start and end points, which are in the same location. It seems to draw a map with my waypoints, but the start and end locations are not on my map. There is no A point. Someone else must have had to deal with this.
Any help? Here is my code. Standard code from Google samples:
function calcRoute() {
depotNumber = document.getElementById("depot").value;
var start = fullDepotAddress;
var end = fullDepotAddress;
var waypts = [];
var checkboxArray = document.getElementById("stores");
for (var i = 0; i < checkboxArray.length; i++) {
if (checkboxArray.options[i].selected == true) {
waypts.push({
location:storeAddress[ checkboxArray[i].value],
stopover:true});
}
}
var request = {
origin: start,
destination: end,
waypoints: waypts,
optimizeWaypoints: true,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
var route = response.routes[0];
var summaryPanel = document.getElementById("directions_panel");
summaryPanel.innerHTML = "";
// For each route, display summary information.
for (var i = 0; i < route.legs.length; i++) {
var routeSegment = i + 1;
summaryPanel.innerHTML += "<b>Route Segment: " + routeSegment + "</b><br />";
summaryPanel.innerHTML += route.legs[i].start_address + " to ";
summaryPanel.innerHTML += route.legs[i].end_address + "<br />";
summaryPanel.innerHTML += route.legs[i].distance.text + "<br /><br />";
}
}
});
}
Also, the waypoints don't seem to follow a traveling salesman algorithm. It has my route going all over. Are the routes supposed to come out optimized?
Thanks