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

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

问题描述

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

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,
...

我想获取这些数据并在 Google 地图中创建可视化路线.我之前对 Gmaps 有一些经验,但只使用网络服务来获取点之间的方向.

I want to get this data and create a visual route in Google Maps. I had a little experience with Gmaps before, but only using the web-service to get directions between points.

在这种情况下,使用这种方式的网络服务是无用的,因为如果我问方向,考虑到每个点(A、B、C)都是一条街道,GMaps 会创建一条从W 49th St"到中间的路线10th Ave"然后到W 65th St"的中间,等等

In this case the web-service 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.

我可以从 Google 地图中获得此类信息吗?或者更容易做到这一点?

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

谢谢.

推荐答案

从 Google Maps API v3 获取公交路线信息的唯一真正选择是使用 路线服务,模式设置为TRANSIT一>.是否返回数据取决于您在哪个城市查找该信息.

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.

过境路线示例

手动"选项是使用路线服务获取路线上实际停靠点之间的路线[使用模式驾驶],您当前的列表不够详细,无法做到这一点,但如果您有路线的坐标停止,它可以完成(或者您可以尝试使用可拖动的方向来捕获路线).

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).

示例使用多个路线请求

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

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