Take the 2-minute tour ×

I have seen all the responses to a similar question, however, they are all either old, or no one has answered them.

I have been given the task to obtain zip codes and display their corresponding boundaries to the user on a Google map, like in this example.

I am writing this code in Javascript and using the Google Maps API. I want the user to input a zip code and a marker drops down on their destination with a border representing that zip code area. I see that Google Maps currently has something in their map code that allows one to see the boundaries if someone puts a zip code on maps.google.com. I have used polygons but this wouldn't help make a border around a certain zip code.

Any suggestions on how to obtain this?

Thanks in advance!

share|improve this question
Have you tried looking at how Google have done this with their own page and their own API? –  Lee Taylor Jul 13 '12 at 13:39
Yes, a lot of the things I find are articles and what not. Another post said that they use Twitter API but I couldn't find that particular one. –  njavia66 Jul 13 '12 at 13:47
I just spoke with sales at Digital Map Products inquiring about doing this via their ParcelStream service, and they advised me Google is among their clients. (service is around 10k/month). –  johntrepreneur May 16 '13 at 23:08

1 Answer 1

up vote 7 down vote accepted

There is not an easy answer to this that I know of. But here is a high level design of how to do it.

All of the shape files for zip codes can be found at the census site and can be downloaded from this ftp server. However, that's a ton of data, so you need a place to store it. I recommend using the PostgreSQL database with the PostGIS add on. It is free and open source and generally awesome. It has a utility for converting .shp files (the type in the census shape files) into PostGIS geometry form. PostGIS let's you retrieve the shapes back out as KML.

You can either a) retrieve a shape from the database as KML when it is needed and display it on the map or b) pre-generate a kml file for every zip code ahead of time and retrieve a file as it is needed (this would take up quite a bit of space).

share|improve this answer
O gosh sounds like a long process! :-/ I actually have an excel file full of zipcodes and what not and I can ask the user to input the zip code and a marker will drop in the middle of zip code. Is there not a way to avoid KML? –  njavia66 Jul 13 '12 at 13:59
@njavia66 You can avoid KML, (I don't use it), but you still need a database full of polygons. You can hardly hold that information in an Excel file. I use PostgreSQL/PostGIS as Mark suggested. And yes, it's a long process, involving many different skills, for which serious clients pay thousands of dollars, so I wouldn't expect to get a freebie. :-) –  Marcelo Jul 13 '12 at 14:13
@njavia66 It's hard to avoid KML (or GeoJSON or some other gis format) if you want the boundaries of the zip code to be displayed. AFAIK, google doesn't provide the zip code shapes to you. If you are okay just dropping the marker, you can put your spreadsheet in Google Fusion Tables, and pull that data out using the Maps API (developers.google.com/maps/documentation/javascript/…). –  Mark Jul 13 '12 at 14:16
@Mark: note that what you get from the Census Bureau are not zip codes as defined by the USPS. Instead they are ZCTA's or 'Zip code tabulation areas'. census.gov/geo/ZCTA/zcta.html –  Marcelo Jul 13 '12 at 14:20
Awesome! @Marcelo I wasn't looking for a freebie just a simple way to integrate it. :) Seems like a simple idea but hard to implement which is fine. I like challenges. Thanks for telling me the database of polygons! That is a lifesaver. I was "drawing" them and if you had many markers within a zipcode... it gets ugly! –  njavia66 Jul 13 '12 at 14:20

Your Answer


