2
votes

How can I code something which'll calculate the driving distance between 2 zip codes within the USA in PHP. An API or web service that has SOAP or REST will also do.

But I understand GoogleMaps API can't be used because it violates the TOS.. So I need a way without using Google Maps, because I have no intention of using their maps, just calculate the distance.

2
a quick google search shows many sites violating that TOS... - Lawrence Cherone
Indeed, but my company will not be doing that! :) - Indranil

2 Answers

2
votes

There isn't a whole lot out there that's free, other than Google Maps. The MapQuest API may give you what you need. Here's their guide to the service - it addresses getting driving distances/times between a set of points. Their terms of service don't appear to require that you display a map, but take a look and see if that meets your needs.

1
votes

Google Maps Distance API has this exact Functionality. You can get a return as either xml or json.

Here is the documentation

https://developers.google.com/maps/documentation/distancematrix/

Here is a sample of the request url : http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&sensor=false

One nice thing is you dont have to calculate the long/lat first