4
votes

I have a latitude and longitude of two places. I can get the direction to reach the destination by below api with mode=transit.

https://maps.googleapis.com/maps/api/directions/json?origin=place_id:ChIJVwkdVbQTrjsRGUkefteUeFk&destination=place_id:ChIJIZo0S_EUrjsR_yPLFVLgvHw&mode=transit&key=YOUR_API_KEY

But it don't return the "Bus Service No" as it is shown in google map. Google map with bus service no

Can we get all the buses between the specified location using google api or any api

1
hi did you got the solution to the above problem. - Adarsh

1 Answers

2
votes

If you check the documentation of Google Maps Directions API using the parameter mode=transit or transit_mode=bus, they did not specify the service number of vehicles that will be used in the transit mode.

If you check the Transit Details of the documentation, it contains the following field line that contains information about the transit line used in this step, and may include the following properties:

  • name contains the full name of this transit line. eg. "7 Avenue Express".

  • color contains the color commonly used in signage for this transit line. The color will be specified as a hex string such as: #FF0033.

  • agencies contains an array of TransitAgency objects that each provide information about the operator of the line.

  • short_name contains the short name of this transit line. This will normally be a line number, such as "M7" or "355".

  • vehicle contains the type of vehicle used on this line. This may include the following properties:

    • name contains the name of the vehicle on this line. eg. "Subway".

    • type contains the type of vehicle that runs on this line. See the Vehicle Type documentation for a complete list of supported values.

    • icon contains the URL for an icon associated with this vehicle type.

    • local_icon contains the URL for the icon associated with this vehicle type, based on the local transport signage.

Note: I think this short_name can give you the service number, if you check in your sample request, it will give you a "short_name" : "500D", which it is available in your sample screenshot.