问题
I need to code a finder of cities in a radius of X km. of a given one using a ZIP code or a city. Something like this:
Enter ZIP code or city: [ ] Choose Radius in Km. (10) (20) (30) ------------------------------------------- [ Submit ]
So I need a database relating zip codes, coordinates and city names. (not for USA, Germany) Anyone know of any? Or a ready to use web service or whatever that allow me go to the beach earlier?
THX.-
回答1:
I just found this:
http://api.geonames.org/findNearbyPostalCodes?postalcode=8775&country=CH&radius=10&username=demo
http://www.geonames.org/export/client-libraries.html (several client libraries to request geonames service)
Exactly what I want for Christmas. THX.-
回答2:
If you can get hold of the coordinates of each location (zipcode - longitude - latitude) you can calculate the distance
You could use http://developer.yahoo.com/geo/geoplanet/guide/index.html to get the longitude and latitude for a place then use the calculation to create the distance.
Calculating distance between zip codes in PHP
来源:https://stackoverflow.com/questions/5123338/find-locations-using-zip-codes-cities-or-coordinates