问题
Now I know using Geocomplete I can get city,state postal codes and lot other info.How can I get all postal codes / zipcodes within a city.Like this one I found here.Can I get it from geocomplete or should I query it from a geoip database like Maxmind?
回答1:
i work here boundaries-io.com I think this is what you need it uses US Census as repository: US Zipcode Boundaries API: https://www.mashape.com/vanitysoft/boundaries-io
Above API shows US Boundaries(GeoJson) by zipcode,city, and state. you should use the API programatically to handle large results.
for example:
回答2:
concept name Reverse Geocoding :-
here you can get the total address along with postal code also:-
places.getDetails( request_details, function(results_details, status){
// Check if the Service is OK
if (status == google.maps.places.PlacesServiceStatus.OK) {
places_postal = results_details.address_components
places_phone = results_details.formatted_phone_number
places_phone_int = results_details.international_phone_number
places_format_address = results_details.formatted_address
places_google_url = results_details.url
places_website = results_details.website
places_rating = results_details.rating
for (var i = 0; i < places_postal.length; i++ ) {
if (places_postal[i].types == "postal_code" && ){
console.log(places_postal[i].long_name)
}
}
}
});
Example directly from Google
and for retrieving Zip-code
var address = results[0].address_components;
var zipcode = address[address.length - 1].long_name;
回答3:
There are a variety of sources. The US Postal Service is the authority on this. Unfortunately you have to buy the database. You can get FREE list of zips in a city from USPS through an online interactive form, one city at a time!
http://mobile.usps.com/iphone/iphoneFindZip.aspx
There are other FREE services. These are based on the US Census 2010 ZCTAs. These approximate zip code boundaries for census purposes, but are not a 100% match. Maxmind does not provide a free database anymore. Geonames does. You would have to read up on how complete and accurate it is.
http://download.geonames.org/export/zip/
I've worked in the past with these things.
[ADDED] To anybody interested, I made a (FREE) CSV file of approxiamately all USPS postal codes with their corresponding cities and lat/lng. As many would understand, the USPS dataset is copyrighted and the free ZCTA data from the US Census is an approximation.
I decided to use the following method to reverse build nearly the entire set. I got the US Department of Educations NCES dataset on all schools in the United States (103K schools), and figure that 99% of postal codes would have at least on school. I used the address information to build a unique set of postal codes to cities. Statistics wise, there are approxiametely 41.5K unique postal codes. My list has 43K - assuming some postal codes have multiple entries due to being in more than one city. Also note, the lat/lng is NOT an area centroid. It is simply the lat/lng of some school within the postal code. Have fun with my free dataset!
Format: State, City, ZipCode, Latitude, Longitude http://www.opengeocode.org/download/cityzip.zip
来源:https://stackoverflow.com/questions/20258435/what-are-good-ways-to-get-all-zipcodes-postal-codes-within-a-city