I can not build more than 10 route in Google Maps, but I think this restriction is not found in the documentation limit on the number of the route, there is a restriction on the intermediate points (8). Then what could be the problem?
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++;
}
}
}
}
The directions service is subject to a quota and a rate limit as wall.
Check the status returned by the directions request:
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);
}
});
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다