I'm on ASP.NET MVC and I'm using Google Maps API with Javascript. I send a Model to the View with one or more waypoints to add to the route.
function calcRoute() {
initialize();
var start = "<%= Model.StartAddress %>";
var end = "<%= Model.ClientAddress %>";
var waypts = [];
waypts.push({
location: "<%= Model.PickupAddress[0] %>",
stopover:true
});
var request = {
origin: start,
destination: end,
waypoints: waypts,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
Is it possible to add waypoints this way with the addresses in Model.PickupAddress array? I have seen examples code by using JSON (for markers), but if I can do it directly in this Javascript code, that's fine for me.