Rawan Rawan - 5 months ago 175
Swift Question

Google Map Direction API Return Zero Results Swift

My App using Google Maps Direction API to draw route between any two positions (origin - direction positions)user pin it.

I used the API like this way:

https://maps.googleapis.com/maps/api/directions/json?origin=(fromLat),(fromLng)&destination=(toLat),(toLng)&mode=(travelMode)&departure_time=now&alternatives=true&language=(lang)

The problem is sometimes the response return Zero Results, like this :

{
"geocoded_waypoints": [
{},
{}
],

"routes": [],

"status": "ZERO_RESULTS"
}


I searched a lot but no useful results.

Anyone faced this problem?

Could this problem be because I used the free API?

I will be thankful for any help.

Thanks.

Answer

If there will be no path then it returns the same.

See this link : Path Information

Hope this helps!

UPDATE:

Try to covert Latitude Longitude into address and pass it over the URL and it will solve the issue. CLGeocoder might help you to do the same.