[SGVLUG] Distance between two locations

Jeremy Leader jleader at alumni.caltech.edu
Fri Aug 3 17:47:02 PDT 2007


on 08/03/2007 05:28 PM Jeremy Leader  wrote:
> Determining the latitude/longitude of a location from its address is 
> often referred to as "geocoding"; a web search for that term should help.
> 
> For small numbers of requests, I believe both Yahoo and Google provide 
> APIs to use their maps databases to do geocoding; they might even do the 
> distance calculation for you too.  I believe Yahoo's is documented in 
> developer.yahoo.com, I don't know about Google's API docs.

I found the Yahoo geocoding API, 
http://developer.yahoo.com/maps/rest/V1/geocode.html, which you can invoke via 
an http request, in any language that can make such requests.  You give it an 
address in the request, it returns the latitude and longitude (and various other 
attributes) as xml.  I think you're rate limited to 5,000 queries per IP address 
per day.

If you're working in JavaScript or Flash, you could also use the Yahoo Maps API. 
  It looks like YGeoPoint objects provide a distance method which give you the 
distance between two points in statute miles, nautical miles, or kilometers (or 
pixels on the currently displayed map):

http://developer.yahoo.com/maps/ajax/V3.7/reference.html#YGeoPoint

and the YMap object provides a drawZoomAndCenter method which can take a text 
address and attempts to geocode it and display it centered on the map, and a 
getCenterLatLon method which returns the YGeoPoint the map is centered on:

http://developer.yahoo.com/maps/ajax/V3.7/reference.html#YMap

Note that I've never used these, this is just what I found w/ a little digging.

-- 
Jeremy Leader
jleader at alumni.caltech.edu
leaderj at yahoo-inc.com (work)


More information about the SGVLUG mailing list