Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Non-Stopover Waypoints #93

Closed
pcoughran opened this issue Jul 3, 2015 · 7 comments · Fixed by #468
Closed

Allow Non-Stopover Waypoints #93

pcoughran opened this issue Jul 3, 2015 · 7 comments · Fixed by #468

Comments

@pcoughran
Copy link

From https://developers.google.com/maps/documentation/directions/ -->

You can use waypoints to influence your route without adding a stopover by prefixing the waypoint with via:. Waypoints prefixed with via: will not add an additional leg to the route.

Sample Request:

https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|via:Lexington,MA&key=API_KEY
@markmcd
Copy link
Contributor

markmcd commented Jul 5, 2015

Thanks for the FR. I'm not going to be able to get to this in the next couple of weeks but if anyone else wants to send a pull request through I'd be happy to take a look at it.

@domesticmouse
Copy link
Contributor

@pcoughran could you propose an API interface that would make sense for this use case? I have done a bit thinking of how best to expose this in the API, but would love your thoughts. Thank you!

@gardster
Copy link

Javascript API has stopover property to set up a waypoint type. Maybe implement this feature with the same way?

@raulastu
Copy link

how do I set up stopover=false in the sample request? I would like duration_in_traffic to be returned in every leg, and via: prefix does not add a leg entry.

@apjanke
Copy link
Contributor

apjanke commented Jul 5, 2018

How about this: We currently have String and LatLng waypoint variants in DirectionsApiRequest.

public DirectionsApiRequest waypoints(LatLng... waypoints)
public DirectionsApiRequest waypoints(String... waypoints)

We could add a Waypoint class, and a public DirectionsApiRequest waypoints(Waypoint... waypoints) method. The Waypoint class could have a boolean isStopover flag that defaults to false, and constructors:

Waypoint(String str)
Waypoint(String str, boolean isStopover)
Waypoint(LatLng point)
Waypoint(LatLng point, boolean isStopover)

The DirectionsApiRequest's internal waypoints field could either be converted to Waypoint[], or it could remain String[], and the Waypoint objects converted to String in the waypoints(Waypoint...) method. (I like the former.)

@domesticmouse
Copy link
Contributor

I like your proposal @apjanke. Feel free to put together a PR for your preferred approach if you have time, otherwise I'll loop back and implement when I get a spare moment. Thanks!

@apjanke
Copy link
Contributor

apjanke commented Jul 7, 2018

Here's a PR: #468. I made Waypoint a nested class in DirectionsApiRequest, since that seems consistent with the existing design.

NOTE: In my design, the isStopover flag defaults to true, instead of false like I said previously. I misspoke: it should default to true, I think, since that's the current default behavior for String and LatLng waypoint arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants