我无法在Google地图中构建超过10条路线,但我认为在路线编号的文档限制中找不到此限制,对中间点有限制(8)。那可能是什么问题?
function requestDirections(start, end, polylineOpts, ways, image) {
if (ways.length > 0) {
var waypts = [];
for (var i = 0; i < ways.length; i++) {
waypts.push({
location: ways[i][0] + ", " + ways[i][1],
stopover: true
});
}
directionsService.route({
origin: start,
destination: end,
waypoints: waypts,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}, function (result) {
renderDirections(result, polylineOpts, image);
});
} else {
directionsService.route({
origin: start,
destination: end,
//waypoints: waypts,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}, function (result) {
renderDirections(result, polylineOpts, image);
});
}
}
function beretCoordinate() {
var routesId = document.getElementsByName('routesId');
var k = 0;
for (var i = 0; i < routesId.length; i++) {
var routesId2 = routesId[i].value.replace('~', '').split(',');
var startMassiv = 0;
var index = 0;
var mapPoints = document.getElementsByName(routesId2[0]);
var start;
var end;
for (var j = 0; j < mapPoints.length; j++) {
routes[j] = mapPoints[j].value.replace(',', '.').replace(',', '.').replace('+', ',').replace('+', ',').replace('+', ',').split(',');
if (i >= routesId.length) {
pointsMap[k]=[routes[j][0], routes[j][1], routes[j][2]];
k++;
//marshrutCount++;
} else {
if (startMassiv == 0) {
var startRoute = routes[j];
end = startRoute[0] + ", " + startRoute[1];
} else {
if (startMassiv == 9 || startMassiv == mapPoints.length - 1) {
var endRoute = routes[j];
start = endRoute[0] + ", " + endRoute[1];
var icons2 = {
link: new google.maps.MarkerImage(
// URL
routes[j][2],
// (width,height)
new google.maps.Size(50, 50),
// The origin point (x,y)
new google.maps.Point(0, 0),
// The anchor point (x,y)
new google.maps.Point(25, 46)
)
};
//calcRoute(start, end, findRoutes);
requestDirections(start, end, { strokeColor: routesId2[1] }, findRoutes, { icon: icons2.link });
//DrawRoute(findeRoutes, "red");
startMassiv = -1;
index = 0;
findRoutes = [];
//marshrutCount++;
} else {
findRoutes[index] = routes[j];
index++;
}
}
startMassiv++;
}
}
}
}
答案 0 :(得分:0)
路线服务受限于配额和费率限制。
检查路线请求返回的状态:
function requestDirections(start, end, polylineOpts, ways, image) {
if (ways.length > 0) {
var waypts = [];
for (var i = 0; i < ways.length; i++) {
waypts.push({
location: ways[i][0] + ", " + ways[i][1],
stopover: true
});
}
directionsService.route({
origin: start,
destination: end,
waypoints: waypts,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}, function (result, status) {
if (status == google.maps.DirectionsStatus.OK) {
renderDirections(result, polylineOpts, image);
} else {
alert("Directions request failed:"+status);
}
});
} else {
directionsService.route({
origin: start,
destination: end,
//waypoints: waypts,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}, function (result,status) {
if (status == google.maps.DirectionsStatus.OK) {
renderDirections(result, polylineOpts, image);
} else {
alert("Directions request failed:"+status);
}
});
}
}