我正在建立一个航点谷歌地图。我有起点和终点,它们位于同一位置。它似乎用我的航点绘制了一张地图,但起点和终点位置不在我的地图上。没有A点。必须有其他人必须处理这个问题。
有什么帮助吗?这是我的代码。来自 Google 示例的标准代码:
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 />";
}
}
});
}
此外,航点似乎不遵循旅行推销员算法。它让我的路线走遍了。路线应该优化吗?
谢谢