Find zipcodes inside polygon shape using google maps api

I am working on a google graphical application. I draw a polygon on the GMap and get the area covered by it. I need to find out how many zipcodes are inside a closed area. How can I use the Google Maps API? Any suggestion?

+1
jquery asp.net-mvc-4 google-maps-api-3
source share
3 answers

You will need, as David Strahan said, the geometry for each ZIP code, here is such a database: https://www.google.com/fusiontables/DataSource?docid=1AxB511DayCdtmyBuYOIPHIe_WM9iG87Q3jKh6EQ#rows:id=1

use a database that supports geospatial queries and queries the database using ST_CONTAINS and st_ INTERSECTS

Note. The linked database is FusionTable, it will provide you with the geometry, but you must save this data in another database, since FusionTables does not support polygons for spatial conditions.

+1
source share

Apparently it's too late :) But I would provide a serious answer, and it may take some time when you also have a day life. Note. Alloy Dr. Molles covers only about 65% of all US zip codes. As I note, it is very shortened and therefore may not be so good for finding zipcodes for local distributors.

promised answer:

See this working demo that extracts all zip codes from any polygon on a US map → http://bit.ly/1cW1am6

I found this zipcode database → http://www.boutell.com/zipcodes/ , which contains all the American zipcodes by their centered latlngs - the previously mentioned http://federalgovernmentzipcodes.us/ lacked 1000 zip codes and a lot of latlng were missing -info.

Zoom in, create a polygon by clicking and clicking search: enter image description here

The code works as follows:

  • pass the polygon as pairs [lat, lng] to the server using ajax
  • create a preliminary square describing the borders
  • search all zipcodes inside a square
  • use Point in Polygon algorithm to refine your search
  • return zipcodes inside the polygon

Below the google map there is a link to the zip file containing the full demo, that is, the full source code and databasedumps (as well as the original CSV files). I planned to describe the code in detail, but the question already has an accepted answer - and I have already spent a lot of time on this demonstration. Note. The demonstration will be deleted from the server one day.

+17
source share

I think this is what you need: US Zipcode Boundaries API: https://www.mashape.com/vanitysoft/boundaries-io

Above the API shows the borders of the USA (GeoJson) by zipcode, city and state. you must use the API programmatically to handle large results.

eg: Washington, DC with all Zipcodes in boundaries

query by county: Washington County, in Maryland (MD)

0
source share

All Articles