Google Maps API - “road” distance between 2 points

2019-06-10 19:32发布

问题:

I have a website where "near locations" are shown for each item, based on the latitude and longitude coordinates stored in a database.

Problem is that this calculated distance is the air-line distance, which differs a lot ferom the actual driving distance.

Google Maps does only have a JavaScript API for driving directions by now, I need it as a web service API to make calls directly from the server.

Is there any possibility to do this?

回答1:

The Google Maps API has a HTTP service for geocoding, but not for directions. You can only access that functionality through the Javascript API. You could hack it, but it would break Google's ToS.

More discussion here.