Jerry
Jerry

Reputation: 191

google directions api returns no results

So I am trying to figure out why my api called to maps.googleapis is returning no results. I inputted my exact same queries into google maps (using their interface though, same numbers) and I get directions.

here is my example https://maps.googleapis.com/maps/api/directions/json?origin=43.4833815,-80.539168&destination=43.47242353,-80.54613339&sensor=true&arrival_time=1417650300000&mode=transit

Here is the result from google maps https://www.google.ca/maps/dir/'43.4833815,-80.539168'/'43.47242353,-80.54613339'/@43.4780799,-80.5413407,15z/am=t/data=!4m16!4m15!1m3!2m2!1d-80.539168!2d43.4833815!1m5!1m1!1s0x0:0x0!2m2!1d-80.5461334!2d43.4724235!2m3!6e5!7e2!8j1417632300!3e3

Any ideas why? I am pretty sure my syntax is correct

answer: you need to give departure time in seconds, not milliseconds!

Upvotes: 0

Views: 3946

Answers (1)

MrUpsidown
MrUpsidown

Reputation: 22490

https://maps.googleapis.com/maps/api/directions/json?origin=43.4833815,-80.539168&destination=43.47242353,-80.54613339&sensor=false&arrival_time=1417650300&mode=transit

Your timestamp needs to be a UNIX Timestamp in seconds. You provided a UNIX timestamp in milliseconds.

From the documentation:

arrival_time - Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC. You can specify either departure_time or arrival_time, but not both. Note that arrival_time must be specified as an integer.

Upvotes: 1

Related Questions