I'm looking to geoencode an address and convert it to GPS Coordinates. Basically,
var address;
// Google/Yahoo/whatever program to convert address to GPS coordinates
var output=xx.xxxxxxx,xx.xxxxxxx
I've researched Google and Yahoo APIs, but can't seem to get their codes to work in my Google Gadget. Any suggestions?
Thanks in advance!
I did this and worked perfect:
Here's what I did for my address-to-gps-coords needs:
Then you call it like
get_coords('1600 Pennsylvania Avenue NW Washington, DC 20500')
and it'll return the latitude and longitude.You'll need to supply your own Google Maps API key to make it work, of course.
Hope this helps!
I help to maintain one API called LiveAddress which does this. Much easier to use than Google/Yahoo's APIs, and without the restrictive Terms of Service which prohibit requests en masse, storing the results, or using the data without showing a map or by automation.
Here's a complete example, using this sample wrapper function:
Individual coordinates are found in
geo.lat
andgeo.lon
, with the combined string "lat, lon" format ingeo.coords
. You can also obtain the precision of the data withgeo.precision
.