0
votes

I want send my origin point and destination point to Google for direction. When I use name for origin and destination it's true and returns true JSON information, but when I send latitude and longitude for origin and destination it doesn't work.

It's ok whit this URL: https://maps.googleapis.com/maps/api/directions/json?origin=tehran&destination=shiraz&key=AIzaSyBvR07aFM-1ddGVgt392lRnUge3weT6nUY

But it doesn't work with this: https://maps.googleapis.com/maps/api/directions/json?origin=32,52&destination=34,54&key=AIzaSyBvR07aFM-1ddGVgt392lRnUge3weT6nUY

1

1 Answers

0
votes

I think the problem is the coordinates you're using - they look like they're not accessible via roads. Make sure that you're not casting the latitude or longitude to ints, you need the decimal-point precision.

Converting Tehran and Shiraz to latlngs, I get the following URL which works correctly:

https://maps.googleapis.com/maps/api/directions/json?origin=35.6887931,51.3891646&destination=29.5916593,52.583701&key=<api key here>