Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

map city/zipcode polygons using google maps

I am looking for a javascript library that supports the ability to pass a zipcode or city as a parameter, and get a list of x,y coordinates to draw a polygon using google maps?

Does this exist? Does the google maps API support such queries? I am looking for an array of coordinates similar to those that google uses to draw maps on a google query:

enter image description here

like image 982
JZ. Avatar asked May 09 '12 22:05

JZ.


People also ask

Can you map zip codes in Google Maps?

This ZIP Codes on Google Maps tool will show all ZIP Code boundaries, in the U.S. anyway. To see ZIP Codes for a specific city, address, etc, just type the city or address in the "Search places" box just above the map.

Can you add polygons to Google Maps?

Draw a path or polygonTo make a path or polygon into a 3D object, click Altitude. A "New Path" or "New Polygon" dialog will pop up. You may need to move it out of the way before moving on to the next step. To draw the line or shape you want, click a start point on the map and drag.


2 Answers

Google Maps API doesn't support that kind of solution. There are a couple other places from which you can get the coordinates, though:

Flickr API

There is a Flickr API based on photos that people tag, but it's only as accurate as the people who tag photos: so it's good enough for bootstrapping but probably not for production: http://karya-blog.blogspot.com/2012/12/fetching-city-polygons-with-flickr-api.html

Natural Earth Data

An accurate alternative is www.naturalearthdata.com. To get that data from there you just need to make two requests: one with the city name and one with their ID to get the parameters:

unlock.edina.ac.uk/ws/search?name=berlin&gazetteer=naturalearth&format=json

and then

unlock.edina.ac.uk/ws/footprintLookup?format=json&identifier=14126951

and you're set :)

Mapzen

If it's possible for you to pre-fetch the data, go for Mapzen, they have a full and pretty accurate database: https://mapzen.com/data/borders/

like image 165
Wojtek Szkutnik Avatar answered Oct 10 '22 08:10

Wojtek Szkutnik


Short answer: I do not think there is any magical getZipCodeBoundaries method in the Google Maps API. However, what you want to do can and has been done. Please see the implementation, and this thread on Google groups concerning the process. Is the first link similar to what you're hoping to accomplish? Also, there is a neighborhood API offered from Zillow under the CC license. You might want to look into that and see if it breaks neighborhoods down by zipcode.

like image 21
Eli Hooten Avatar answered Oct 10 '22 08:10

Eli Hooten