aspose file tools*
The moose likes Java in General and the fly likes Zip Code Search API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Zip Code Search API" Watch "Zip Code Search API" New topic
Author

Zip Code Search API

joe black
Ranch Hand

Joined: Dec 03, 2003
Posts: 103
I want to implement a zip code search.

The idea is that you enter a zip code to search, and the results contain records where the zipcode is within a certain number of miles from the zip code you entered. I also want to display how many miles the resulting zipcode is from the one you entered.

Is there an api I can use for this?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

I haven't found an easy one that does it all.

The basic steps are to:

  • Convert zip code to geocode (place on earth)

  • Since you are talking about Zip codes, I'll assume you are in the US.
  • get the lattitude/longitude of the location.
  • have previously stored all the lat/long values in fields in your records.
  • for each record, calculate distance from record's lat/long to your point



  • The calculation of distance is almost trivial if you use nautical miles, then you can convert it to kilometers, statute miles, etc.

    The US Postal Service has an API you can call to convert addresses to zip codes. They also sell services to convert addresses to zip codes.

    GoogleMaps has some nice APIs that you can use.

    Some databases, I know MySql specifically, have geocoding support, which lets you send a select string and get all records within a radius of a point.

    Once you have it connected, you can have your JSP generate a page using the GoogleMap API to map the points, with zoom, etc. Very cool.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Zip Code Search API