Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 911
John W. Nesk Avatar asked Mar 09 '13 20:03

John W. Nesk


1 Answers

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

like image 199
geocodezip Avatar answered Sep 29 '22 10:09

geocodezip