Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

Google Maps API to get bus route

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 little experience with Gmaps before, but only using the web-service to get directions between points.

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.

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

Thanks.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...