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,753
  • 72
  • 57
  • 129
Novak
  • 2,760
  • 9
  • 42
  • 63

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.
  • 147,927
  • 63
  • 340
  • 553