Google Maps API获取公交路线 [英] Google Maps API to get bus route

查看:137
本文介绍了Google Maps API获取公交路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的情况,也许有人可能会提出解决方案的提示,或者指出它不可能:



我有刚刚定义的公交路线巴士通行证如下:

  W 49th St,
10th Ave,
W 65th St ,
79街Street Transverse Rd,
5th Ave,
...

我想要获取这些数据并在Google地图中创建一条可视路线。我对Gmaps b4有一个小小的体验,但只使用web服务来获取点之间的方向。在这种情况下,用这种方式使用的web服务是无用的,因为如果我问方向考虑每个点(A,B,C)是一条街道,GMaps会创建一条路线从第49街到第10街的中间,再到第65街等等。

我认为如果有是一种获取地图数据和自己创建路线的方式,通过导航地图和寻找最短路径给予一组街道。



我可以有这种来自谷歌地图的信息或者可能更容易做到这一点?



谢谢。

从Google Maps API v3获取公交路线信息的唯一方法是使用路线服务,并将模式设置为 TRANSIT 。无论是否返回数据,都取决于您要查找哪些城市信息。



转乘路线示例

手动选项是使用directions service在路线的实际停靠点之间获取方向[使用模式DRIVING],您当前的列表不够详细,但如果您有停靠点的坐标,则可以完成(或者您可以尝试捕捉路线使用可拖动的方向)。



使用多个路线请求


Here is my situation, maybe someone could give a hint towards the solution or maybe point out that its not possible:

I have bus routes just defined by the streets that the buses pass, like this:

W 49th St,
10th Ave,
W 65th St,
79th Street Transverse Rd,
5th Ave,
...

I want to get this data and create a visual route in Google Maps. I had a litte experience with Gmaps b4, but only using the webservice to get directions between points.

In this case the webservice utilized that way is useless because if I ask directions considering every point (A, B, C) is a street, GMaps create a route that goes from "W 49th St" to the middle of "10th Ave" then to the middle of "W 65th St", etc.

I think I could accomplish this if there is a way to get the map data and create the route myself by navigating the map and looking for the shortest paths given a set of streets.

Can I have this kind of information from Google Maps or maybe someway easier to do this?

Thanks.

解决方案

The only real option for getting bus route information from the Google Maps API v3 is to use the directions service with the mode set to TRANSIT. Whether it returns data or not will depend on what city you are looking for that information in.

Example transit route

The "manual" option is to use the directions service to get directions [with mode DRIVING] between the actual stops on the route, your current list isn't detailed enough to do that, but if you have the coordinates of the stops, it can be done (or you can attempt to capture a route using draggable directions).

Example using multiple directions requests

这篇关于Google Maps API获取公交路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆