在Google Map API中制作邮政编码边界 [英] Make Zip code boundaries in Google Map API

查看:142
本文介绍了在Google Map API中制作邮政编码边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了对类似问题的所有答复,但是,他们都是老的,或者没有人回答他们。



我已经完成了任务获取邮政编码并在Google地图上向用户显示其相应的边界,如本示例中所示。



我正在使用Javascript编写此代码并使用Google Maps API。我希望用户输入一个邮政编码,并在他们的目的地用一个代表该邮政编码区域的边框下拉标记。我发现Google地图目前在他们的地图代码中有一些东西,如果有人在maps.google.com上放置了一个邮政编码,就可以看到这些边界。我已经使用了多边形,但是这无助于围绕特定的邮政编码创建边框。



有关如何获得此信息的任何建议?



在此先感谢!

解决方案

我知道这并不是一个简单的答案。但是这里有一个关于如何做到的高层次的设计。



邮政编码的所有形状文件都可以在人口普查站点找到,可以从这个ftp服务器。但是,这是大量的数据,所以你需要一个地方来存储它。我建议使用带有PostGIS附加功能的PostgreSQL数据库。它是免费的,开源的,一般很棒。它具有将.shp文件(人口普查形状文件中的类型)转换为PostGIS几何形式的实用程序。 PostGIS让您以KML形式返回形状。

您可以a)在需要时从数据库中检索形状作为KML,并将其显示在地图上或b)为每个zip预先生成kml文件代码提前并根据需要检索文件(这将占用相当大的空间)。


I have seen all the responses to a similar question, however, they are all either old, or no one has answered them.

I have been given the task to obtain zip codes and display their corresponding boundaries to the user on a Google map, like in this example.

I am writing this code in Javascript and using the Google Maps API. I want the user to input a zip code and a marker drops down on their destination with a border representing that zip code area. I see that Google Maps currently has something in their map code that allows one to see the boundaries if someone puts a zip code on maps.google.com. I have used polygons but this wouldn't help make a border around a certain zip code.

Any suggestions on how to obtain this?

Thanks in advance!

解决方案

There is not an easy answer to this that I know of. But here is a high level design of how to do it.

All of the shape files for zip codes can be found at the census site and can be downloaded from this ftp server. However, that's a ton of data, so you need a place to store it. I recommend using the PostgreSQL database with the PostGIS add on. It is free and open source and generally awesome. It has a utility for converting .shp files (the type in the census shape files) into PostGIS geometry form. PostGIS let's you retrieve the shapes back out as KML.

You can either a) retrieve a shape from the database as KML when it is needed and display it on the map or b) pre-generate a kml file for every zip code ahead of time and retrieve a file as it is needed (this would take up quite a bit of space).

这篇关于在Google Map API中制作邮政编码边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆