The route create only if I use LatLng or String params but I need create it by PlaceId but it doesn't work
example:
directionsService.route({
origin: {'placeId': 'ChIJc1lGdwfP20YR3lGOMZD-GTM'},
destination: {'placeId': 'ChIJdTGhqsbP20YR6DZ2QMPnJk0'},
waypoints: [{stopover: true, location: new google.maps.Place('ChIJRVj1dgPP20YRBWB4A_sUx_Q')}],
optimizeWaypoints: true,
travelMode: google.maps.TravelMode.DRIVING
}
Just need to pass the google.maps.Place
object as the waypoint location.
For example:
directionsService.route({
origin: { placeId: "ChIJc1lGdwfP20YR3lGOMZD-GTM" },
destination: { placeId: "ChIJdTGhqsbP20YR6DZ2QMPnJk0" },
waypoints: [{ stopover: true, location: { placeId: "ChIJRVj1dgPP20YRBWB4A_sUx_Q" } }],
optimizeWaypoints: true,
travelMode: google.maps.TravelMode.DRIVING
}
location specifies the location of the waypoint, as a LatLng, as a google.maps.Place object or as a String which will be geocoded.
Google Maps - Direction Services Documentation
Here's the JsFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With