本文介绍了谷歌地图V3,如何获得多个目的地的最佳驾车路线列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Gmap API来计算许多目的地的最佳驾车路线。
我已阅读此网页:





这几乎与我想要的一样。然而,我只想得到一个返回目的地列表,这是排序,并告诉哪个目的地先去。



例如:我发送三个目的地的位置A ,B,C到Gmap。我需要接受一个像$ bestroute [] = {B,C,A}的数组。



我将使用PHP和javascript进行编码。如果你可以帮助我或知道任何教程,请帮助。



非常感谢。

解决方案

您引用的链接解释了如何做到这一点:诚然,您还可以找回您不关心的一些路线信息,但您可以忽略它。



要清楚的是,除了您的出发地和目的地(A和E)之外,您只需提供带有一些路标(例如B,C和D)的路线请求。



如果使用,请确保在列出航点之前设置优化:true检查waypoint_order数组(接近此url结果的底部)以获取所需信息:

  http:// 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& sensor = false 

如果使用JS API,请在请求中设置optimizeWaypoints:true。

与往常一样,请确保遵守服务条款(例如,您的网络服务请求的结果必须显示在Google地图上)


i would like to use Gmap API to calculate the best driving route for many destinations. I have read this page:

http://googlegeodevelopers.blogspot.de/2010/03/good-day-for-salesmen-that-travel-on.html

That is nearly the same thing i want. However, i only want to get a list of destinations back, that is sorted and tell which destination to go first.

For ex.: I send location of three Destinations A, B , C to Gmap. I need to receive an array like $bestroute[] = {B,C,A}.

I will code with PHP and javascript. If you can help me or know any tutorial, please help.

Thank you very much.

解决方案

The link you refer to explains how to do this: admittedly you also get back some directions information you don't care about, but you can simply ignore it.

To be clear, you just make a directions request with some waypoints (say B,C and D) in addition to your origin and destination (A and E).

If using the web service, ensure you set optimize:true before listing your waypoints, and check the waypoint_order array (near the bottom of the result for this url) to get the info you want:

http://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&sensor=false

If use the JS API, set optimizeWaypoints:true in your request.

As always, be sure you're abiding by the terms of service (e.g. results from your web service request must be displayed on a Google Map)

这篇关于谷歌地图V3,如何获得多个目的地的最佳驾车路线列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 08:16