map city/zipcode polygons using google maps

前端 未结 4 1097
日久生厌
日久生厌 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: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/

提交回复
热议问题