我的地图上有 4 个不同的点。但它对所有人来说都是response一样的。我认为不要用流量来估计。例如,在谷歌地图中,我检查两点持续时间。那有时显示1小时8分钟,有时显示1小时7分钟。但在我的项目中它总是 58 分钟。如何解决这个问题并正确显示持续时间?durationlegs
function calculateAndDisplayRoute(directionsService,directionsRenderer, map, myCompany, companies) {
var waypts = [];
for (var i = 0; i < companies.length; i++) {
waypts.push({
location: companies[i].Address,
stopover: true
});
}
directionsService.route(
{
origin: document.getElementById("start").title,
destination: document.getElementById("start").title,
waypoints: waypts,
optimizeWaypoints: true,
travelMode: "DRIVING",
drivingOptions: {
departureTime: new Date(Date.now()),
trafficModel: 'optimistic'
}
},
function (response, status) {
if (status === "OK") {
console.log("response = ", response)
directionsRenderer.setDirections(response);
var route = response.routes[0];
console.log("route = ", route);
renderDirectionsPolylines(response, map, myCompany, companies);
当年话下
相关分类