map city/zipcode polygons using google maps

google-maps, google-maps-api-3, javascript, overlay, polygon

Solution

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/

Problem

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:

Original source