i use directionFinder in Google Apps Script application and I want do add some waypoints. Everything works well when i add this like this:
var directions = Maps.newDirectionFinder().setOrigin(start).setDestination(end)
.addWaypoint('Berlin')
.addWaypoint('Hamburg')
.getDirections();
but when I want do add some waypoints dynamicaly in loop like this:
var directions = Maps.newDirectionFinder().setOrigin(start).setDestination(end)
while (results.hasNext()) {
directions.addWaypoint('Berlin')
directions.addWaypoint('Hamm')
}
directions.getDirections();
finally the object directions hasn’t any waypoints. What I’m doing wrong? There isn’t possible to add waypoints in a loop?
I created a simple script (see bellow). It works correctly – the
rescontains 4 legs.I assume that the
results.hasNext()returns false. If not then, could you create a minimum compilable example/function which is possible to copy-and-paste to the editor and which reproduces the problem.Update 00: Additionally I wrote a deployed web app demonstrating that the
addWaypointfunction works. Here is the app source code.