0

I'm building a web based application to determine a value, which consists the calculation of the distance between X city to Y city (US).

Is there a data resource to pull that information?

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Novak
  • 2,690
  • 9
  • 39
  • 62

1 Answers1

1

You can get the latitude and longitude of your cities from a map API. I use Yahoo's because their terms of service fit better with my needs, but the Google API is certainly a good choice as well.

The Yahoo API is described here

http://developer.yahoo.com/geo/placefinder/

Once you have the latitude and longitude, you can find the distance either using a fairly straightforward formula

Calculate distance between two latitude-longitude points? (Haversine formula)

or with another API:

http://developer.yahoo.com/flash/maps/classreference/com/yahoo/maps/api/utils/Distance.html

Community
  • 1
  • 1
Eric J.
  • 143,945
  • 62
  • 324
  • 540