问题
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.
回答1:
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.
回答2:
It's because of wrong lat-long for the destination. Also path is not available for the requested Travel mode.
回答3:
Try with this google API:
https://maps.google.com/maps?saddr=%@,%@&daddr=%@,%@
Pass latitude, longitudes to above API. You will get the result.
来源:https://stackoverflow.com/questions/37786919/google-map-direction-api-return-zero-results-swift