Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Zip Codes within a range in a given Longitude-Latitude

Im working with the google-mapquest mapping API. I need to add some Points of Interest near a certain area from a given latitude-longitude location. I search the google and mapquest documentation to figure out if there is a method to get all zip-codes in that area but i didnt find anything that does that.

I tried the harvesine implementation to calculate the nearest point given in that radiuos/latitude-longitude and it works fine. The problem with this approach is that i need to update constatntly the database, so i dont like it much.

The question is: Is there a service (google-mapquest or another) that gives you this information?.

like image 288
Charles Avatar asked Feb 04 '26 07:02

Charles


2 Answers

No, there is no API for either service that I am aware of. Your best bet is to just get a ZIP Code database and use that. Some really good inexpensive ones are out there. I prefer http://www.zip-codes.com/zip-code-database.asp. Their $40 package is very accurate, updated monthly, and licensed by the USPS (so you know it's quality data).

like image 77
James Harris Avatar answered Feb 05 '26 21:02

James Harris


UPDATE:

I found a WebService that does exactly what i need. You could provide only a simple ZipCode and a country or perhaps a full address and in the response you get the longitude/latitude. Then i send the Latitude and Longitude returned to get a list of all the ZipCodes near the provided coordinates and a given Radius that also can be customized. You can filter the total rows you want the service to return, or even if you are gonna use miles or kilometers as the measure unit.

So, basically with the returned information, i feed those coordinates for each of the nearest ZipCodes obtained to the google API and render those points of interest into the map that you need to show.

The services are provided by GeoNames. Its an organization dedicated to Geolocalization services. They offer also premium data, but in particular these services are free of use, obviously the information is not as accurate as the premium one, but actually in my tests i found that that is trustful and the response also is very fast. Another good advantage is that the process to get a Key for use Geonames services it's quite simple.

I left you the link of the services that i'm talking about.

List of available services: http://www.geonames.org/export/web-services.html

Hope it helps many people. Regards!

like image 24
Charles Avatar answered Feb 05 '26 22:02

Charles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!