Google航点地图。没有'A'点

时间:2012-06-28 15:06:18

标签: google-maps traveling-salesman jquery-waypoints

我正在建立一个航点谷歌地图。我有起点和终点,它们位于同一个位置。它似乎用我的航点绘制地图,但起点和终点位置不在我的地图上。没有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 />";
    }
  }
});
}

此外,航点似乎不遵循旅行推销员算法。我的路线到处都是。路线是否应该优化?

由于

1 个答案:

答案 0 :(得分:0)

那么开始/结束坐标和一些航路点怎么样?

更新: Here是您可行方向的路线。请注意,“A”标记位于“I”标记下(将“I”标记拖离“A”标记以验证)。