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

Golang Directions SDK does not optimize waypoints #138

Closed
silverspace opened this issue Mar 23, 2018 · 2 comments · Fixed by #149
Closed

Golang Directions SDK does not optimize waypoints #138

silverspace opened this issue Mar 23, 2018 · 2 comments · Fixed by #149
Labels

Comments

@silverspace
Copy link

The Directions API does not optimize waypoints when the request specifies Optimize: true.

The issue is that the golang SDK adds optimize=true as its own query parameter, when it should be part of the waypoints query parameter as optimize:true|....

Example of working URL from https://developers.google.com/maps/documentation/directions/intro#Waypoints:

https://maps.googleapis.com/maps/api/directions/json?origin=Adelaide,SA&destination=Adelaide,SA&waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA&key=YOUR_API_KEY

The issue here is that https://github.com/googlemaps/google-maps-services-go/blob/master/directions.go#L91 adds optimize as a separate query parameter, rather than appending the waypoint string "optimize:true".

The result is a broken URL:

https://maps.googleapis.com/maps/api/directions/json?optimize=true&origin=Adelaide,SA&destination=Adelaide,SA&waypoints=Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA&key=YOUR_API_KEY
@febytanzil
Copy link

febytanzil commented Jun 4, 2018

maybe found the same issue,

routes, _, err := c.Directions(context.Background(), &maps.DirectionsRequest{
		Origin:      origin.String(),
		Destination: origin.String(),
		Waypoints:   wpArr,
		Optimize:    true,
	})
log.Println(routes[0].WaypointOrder)

was trying like this with different permutations of waypoints, but always return ordered integer 0, 1, etc. even optimize is set to true

@googlemaps-bot
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants