Using the Google Transit API in android

I want to use the Google Transit API in an Android application. But I get data from the service. I used the following options:

http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1343605500&mode=transit

I always get this answer:

{ "routes" : [], "status" : "ZERO_RESULTS" } 

I think I'm passing something wrong in any parameters used in the above URL, maybe departure_time is wrong?

Can anyone say what needs to be passed to the parameters? Can someone help me find out the URL with parameters that return a value?

+4
source share
1 answer

You just need to set the departure_time parameter in the future (for example, a few days). From here :

When requesting transit routes, be sure to include either departure_time or arrival_time. Please note that in this example, Departure time is indicated as July 30, 2012 at 09:45. Update the parameter to a point in the future before sending the request.

Try http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1350472557&mode=transit , it works.

+3
source

Source: https://habr.com/ru/post/1439354/


All Articles