Reputation: 199
I get the value of ONLY ONE WAYPOINT from a text box and I try to draw a route from start to end through this waypoint but it doesn't work.
function calcRoute() {
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
var waypts = document.getElementById('way').value;
var request = {
origin: start,
destination: end,
waypoints: waypts
};
Upvotes: 0
Views: 259
Reputation: 161404
Please read the documentation on waypoints
waypts needs to be an array of DirectionsWaypoint objects
function calcRoute() {
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
var waypts = document.getElementById('way').value;
var request = {
origin: start,
destination: end,
waypoints: [{location:waypts, stopover: true}]
};
Upvotes: 1