Sorry that this topic is not really rails-specific, but I happen to be
implementing it in rails. I’m trying to implement a common scenario,
where you get a comprehensive list of states/provinces, cities, and
zip/postal codes, and you find nearby cities based on a specified
location, like on some of the dating sites. I have no clue where to
start, I’m not even sure what keywords I should use to search. If
anyone can point out to me how this is usually done, I would really
appreciate it.
Sorry that this topic is not really rails-specific, but I happen to be
implementing it in rails. I’m trying to implement a common scenario,
where you get a comprehensive list of states/provinces, cities, and
zip/postal codes, and you find nearby cities based on a specified
location, like on some of the dating sites. I have no clue where to
start, I’m not even sure what keywords I should use to search. If
anyone can point out to me how this is usually done, I would really
appreciate it.
Start here:
Get one of the packages that includes lat/long coordinates. Then just
do
earth-distance calculations and you’re done.
Thanks for the recommendation. I was wondering if there are any free
ones available that don’t do as much. I just need to let the user
select a city or zip/postal, and return a list of cities within say
50/100/200 miles. There’s no need to be too specific. I am just a
student writing this app from my bedroom, so I try not to spend too
much.
start, I’m not even sure what keywords I should use to search. If
Thanks!
Bob
Purely out of curiosity, I decided to investigate this myself, and I found http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm . It’s free, and
has
lat/long coordinates and cities. It appears to be from 2001, but it may
be
accurate enough for your needs.
I haven’t looked into this at all, but does the Google Maps API have any
calls that would return the exact same information? If so, then just
make a
call out to their service.
I haven’t looked into this at all, but does the Google Maps API have any
calls that would return the exact same information? If so, then just make a
call out to their service.
Yes and no. You can get the lat/long for a given address/city/zip, but
you can’t do things like figure out the state given the zip, etc which
is
what this guy wants to do…
Also, they have a limit on the number of queries/day, but if you can
cache
it on insert that might work too.
Check out YM4R/GM . I am using it for a website I just started
coding(experimenting yet) www.catbrowse.com
Enter in the text field something like: Arendsweg, netherlands
I list possible results if google maps API returns multiple locations
(thanks to google and YM4R/GM)
If it returns only one address than I show it on google map. Something
like Arendsweg, Alkmaar, Netherlands (and then drag map to a little
South West)
All I use is (query is user’s input)
def find_locations(query)
Geocoding.get(query, { :host => “catbrowse.com” })
end
You should really check out the YM4R/GM, great plugin.
I haven’t looked into this at all, but does the Google Maps API have any
calls that would return the exact same information? If so, then just make a
call out to their service.
Yes and no. You can get the lat/long for a given address/city/zip, but
you can’t do things like figure out the state given the zip, etc which
is
what this guy wants to do…
Also, they have a limit on the number of queries/day, but if you can
cache
it on insert that might work too.
Oh well, give it a few more years and cheaper connectivity and storage
and
Google will provide an API for retrieving any information at all.
I guess if you want, you can already do a generic google search for
“85260.” The first thing retrieved is the name of the city. So, you
could
probably screen scrape that. I wonder if google watches for bots doing
stuff like that, or if they cap searches.
start, I’m not even sure what keywords I should use to search. If
earth-distance calculations and you’re done.
much.
may be accurate enough for your needs.
Just gave a talk on this at our local ruby users group last night.
(ncl.rb).
Useful plugin is GeoKit ( http://geokit.rubyforge.org/ ) which allows
you to geocode addresses using a variety of sources (Google, Yahoo
etc) works great if you are in the US or Canada. For UK Codes it
becomes a problem due to copyright of the postcode database. I have
hacked together an extra geocoder ( http://magpieuk.blogspot.com )
which plugs in to GeoKit which utilises a server I found which offers
this for free ( Geocoding Tool for Virtual Earth & Google Maps – Emad Fanous ).
GeoKit gives you the acts_as_mappable which once you add lat and lng
fields to it allows you to do nice things such as: