I had this example :
https://google-developers.appspot.com/maps/documentation/javascript/examples/directions-panel
and I was wondering how to set routes by 2 or more waypoint? As you know on that application you can get the waypoint: first, set the origin / start point and then set the destination point and the maps will generating the routes. Script :
function calcRoute() {
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
see : origin : start, destination: end.
Now the Question is : Is that possible to me to set the waypoint by myself? Using LatLong from point-to-point or maybe I just say what the street name that will be the point?
Understand? Sorry I am not good at words but I always wait for the answers, thank you!
Yes it is possible to add waypoints to a directions request:
Here is the description of the waypoint object from the documentation:
https://developers.google.com/maps/documentation/javascript/reference#DirectionsWaypoint
Here is the request description in the documentation (see waypoints):
https://developers.google.com/maps/documentation/javascript/reference#DirectionsRequest
Example with an “address” waypoint
Example with a waypoint specified by coordinates