bell
bell

Reputation: 11

How can i use the features of travel_mode: transit and transit_mode: rail for my android application?

I am developing an application that will show the duration, transit and fares for railway journey but i cant find any way to use the features provided in google directions api for android. how to retrieve the data from the json file? and the mode: transit is not included when i search for normal route.

for example https://maps.googleapis.com/maps/api/directions/json?origin=kl%20sentral%20&destination=%20nu%20sentral%20&key=AIzaSyDnwLF2-WfK8cVZt9OoDYJ9Y8kspXhEHfI shows the details of the route but only DRIVING available at the travel_mode.

meanwhile to gain info on transit mode i have to use this link https://maps.googleapis.com/maps/api/directions/json?origin=ktm%20padang%20jawa&destination=berjaya%20times%20squarel&mode=transit&key=AIzaSyBOMaygM5BVPpsoLhHVA3N80Fki61yT7j4 which consists the travel_mode: transit included in the url.

can anyone help me with this?

Upvotes: 1

Views: 168

Answers (1)

Nader
Nader

Reputation: 29

You can use it like this:

https://maps.googleapis.com/maps/api/directions/json?origin="+cityStart+"&destination="+cityEnd+"&transit_mode="+transitMode+"&key=YOUR_KEY

for transit_mode u can use any rail of train or of this here : https://developers.google.com/maps/documentation/directions/get-directions#transit_mode

and for less walking u can set transit_routing_preference to less_walking or fewer_transfers. here you can find more details: https://developers.google.com/maps/documentation/directions/get-directions#transit_routing_preference

Upvotes: 0

Related Questions