Reputation: 7597
I am using the google direction api to solve the travelling salesman problem.
Apparently the api takes a param called optimize:true
and then return a "waypoint_order": [ 1, 0, 2, 3 ]
telling you the best order of waypoints that optimizes the route.
Thing is, when you try to optimize the route, the API just does not work and you get NO_RESULTS.
For instance use this url to see how the API fails when the optimize:true|
bit gets added.
NOT working (NO_RESULTS error):
WORKING (but not optimizing):
Does anyone know if they stopped supporting routes optimization?
Thanks
Upvotes: 0
Views: 2447
Reputation: 161354
Looks to me like that is a bug in the DirectionsService when you pass in PlaceIds. I replicated it with the Javascript API. Using addresses works:
waypts = [];
waypts.push({
location: "Plymouth, UK", // {placeId:"ChIJPeqVDlONbEgRk4X1zrUsKDs"},
stopover: true
});
waypts.push({
location: "Bournemouth, UK", // {placeId:"ChIJ_WegsaCYc0gRlCypaxXgLjs"},
stopover: true
});
var request = {
origin: "London, UK", //{placeId:"ChIJdd4hrwug2EcRmSrV3Vo6llI"},
destination: "Newquay, UK", //{placeId: "ChIJh1a5WhEMa0gRY1JU4PEam8Q"},
waypoints: waypts,
optimizeWaypoints: true,
travelMode: 'DRIVING'
};
fiddle using addresses (returns waypoint order=1,0)
But the same locations (I used these placeIds to get the addresses above) doesn't work using placeIds:
waypts = [];
waypts.push({
location: {placeId:"ChIJPeqVDlONbEgRk4X1zrUsKDs"},
stopover: true
});
waypts.push({
location: {placeId:"ChIJ_WegsaCYc0gRlCypaxXgLjs"},
stopover: true
});
var request = {
origin: {placeId:"ChIJdd4hrwug2EcRmSrV3Vo6llI"},
destination: {placeId: "ChIJh1a5WhEMa0gRY1JU4PEam8Q"},
waypoints: waypts,
optimizeWaypoints: true,
travelMode: 'DRIVING'
};
fiddle using placeId (returns ZERO_RESULTS)
might be related to this issue in the issue tracker: Issue 8979: Bug: Can't use combination of placeId and String for origin/destination
Upvotes: 1