1

Had a hard time coming up with a subject description that would fit my question, but I will elaborate:

I'm calculating and plotting a route from A to C with 1 waypoint along the way, lets call it B

So my route looks like this : A -> B (waypoint) -> C

If the route has this format (passing over waypoint B) I would like to FORCE the route between point A and B to use travelmode "walking" I would love to go about this in the most clean way possible , but I was not able to use "waypoints" as such in this way.

I came up with a very hacky alternative of cutting the route from A to C up in 2 separate routes (so needing two separate DirectionsRenderer objects (1 for each route)) which enabled me to force a travelmode into those objects separately. Eventually this does exactly what I want it to do ... but it still does not feel right.

Anyone any experience in doing this ? I feel like I just looked over some part in the docs which explains how to set separate travel modes for each route between waypoint.

Short snippet of my hacky alternative:

... code omitted ...

var directionsDisplayDrive  = new google.maps.DirectionsRenderer({suppressMarkers: false, polylineOptions: polylineOptionsDrive});
var directionsDisplayWalk = new google.maps.DirectionsRenderer({suppressMarkers: false, polylineOptions: polylineOptionsWalk});

directionsDisplayWalk.setMap(map);
directionsDisplayDrive.setMap(map);

calcRoute("WALKING", fromCoded, waypoint1); // force WALK from A to B
calcRoute("DRIVING", waypoint1, toCoded);   // force DRIVE from B to C

... rest of code omitted...

Thanks

Wayfarer
  • 620
  • 6
  • 16

0 Answers0