0

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

此外,航点似乎不遵循旅行推销员算法。它让我的路线走遍了。路线应该优化吗?

谢谢

4

1 回答 1

0

那么开始/结束坐标和一些航点呢?

更新: 是带有可拖动方向的路线。请注意,“A”标记位于“I”标记下方(将“I”标记拖离“A”标记以验证这一点)。

于 2012-06-28T19:12:38.087 回答