0
votes

This is the call that I make:

https://maps.googleapis.com/maps/api/directions/json?alternatives=true&key=my_key&origin=52.370060,4.925040&destination=52.37913,4.90027&departure_time=1518168706&mode=transit

I This route, which should have atleast 3 metro's and some buses in between them, should find me results.

This is what I send as the departure_time to get that value: (System.currentTimeMillis() / 1000

And sometimes it works, sometimes no. I tried using the same + 30 (adding 30 seconds to current time) but, again, sometimes I get results, sometimes just ZERO_RESULTS. Why?

I noticed that if I set the time to 5 minutes in the past, it works. but I need it to start at this moment. This makes no sense, why would the call return me results for the past, but not future, for planning

1
I am getting results when i add 30 seconds, if i understood correctly you are getting results with departure_time=1518168706 but no results with departure_time=1518168736 ?betofarina
So If I try System.currentTimeMillis() / 1000 (so it's Seconds). I almost always get ZERO_RESULTS. BUT If I try to add some time, I get results. But not always.rosu alin
What I did for now, is make a retry logic, where if get ZERO_RESULTS, I retry with adding 300 seconds (5 minutes) to my time. I retry up to 4 times, and this gets me a response. Sometimes from the first call, sometimes from the second or third. But I consider this more an hack than a fix. In order to fix this, I need to understand WHY I get ZERO_RESULTS for variations of time, if the origin and destination are the same. and I should have a metro going in that direction every 3 minutesrosu alin

1 Answers

1
votes

I am afraid your questions is a bit broad since the understanding of how google works internally is a mistery for most mortals, but there is a few cases where you can have zero_results.

The first one is that you use times that are already in the pasts. so always make sure the epoch time you use has not already passed.

Another could be that in the moment you requested the directions, there are no posible routes for your desire destinations, since google collects data from other sources like Live Traffic(for driving), etc.

What I found is that if this issue persist (that you keep getting zero_results) for a specific directions could be actually a Bug of the API, and you can report it in the issue tracker https://issuetracker.google.com/ since I found reported/accepted Bugs (like https://issuetracker.google.com/issues/63884989) related with your issue.

If I found more info I will update this answer.