Google MAPS waypoints

限于喜欢 提交于 2019-12-24 22:45:56

问题


I have a problem using waypoints in Google Maps: https://developers.google.com/maps/documentation/javascript/directions#DirectionsResults

I want to add waypoints and get driving directions in the order I provide them, but google automatically optimize them...

I send request with this code:

var request = {
  origin: start,
  destination: end,
  waypoints: waypts,
  optimizeWaypoints: true,
  travelMode: google.maps.TravelMode.DRIVING
};

and in my array (waypts) waypoints are ordered as they should be ...

Example:

I want to go from NY via Chicago via NY to Philadelphia.. But the response I get is like this: NY via NY (1 meter) to Chicago to Philadelphia. Google somehow optimize route but I don't want this ...

Any idea?

Thanks!


回答1:


LOL ... I missed that in documentation... The solution is:

In var request put the line:

optimizeWaypoints: false



回答2:


Or just simply removing this line:

optimizeWaypoints: true


来源:https://stackoverflow.com/questions/11295480/google-maps-waypoints

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!