开发者

Calculating driving distance using zip codes

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开发者_Go百科 a way without using Google Maps, because I have no intention of using their maps, just calculate the distance.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜