map city/zipcode polygons using google maps

前端 未结 4 1084
日久生厌
日久生厌 2020-12-30 13:41

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 ma

相关标签:
4条回答
  • 2020-12-30 14:20

    Look on this site Twitter geo api You have few modes of search, and it gives You boundary box for cities. I am using it now on My site. Try f.e. this link and U will see the results.

    0 讨论(0)
  • 2020-12-30 14:22

    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.

    0 讨论(0)
  • 2020-12-30 14:32

    You can get polygon coordenates in json for using with googlemaps using openstreetmap. Go to http://nominatim.openstreetmap.org/ search a place like "Partido de Ituzaingó"

    Steps:

    • Click on "details"
    • Look for the OSM ID and copy it (control+c), example: 2018776
    • Go to http://polygons.openstreetmap.fr/index.py
    • Paste the ID in
    • Download the polygon
    0 讨论(0)
  • 2020-12-30 14:43

    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/

    0 讨论(0)
提交回复
热议问题