0

我需要在网页上显示地图 - 我有用户的地址信息,但为了安全起见,我需要地图以他们的邮政编码或城市的质心点为中心,而不是他们的具体地址。

是否可以仅向 Google maps V3 API 提交邮政编码并让它返回邮政编码/邮政编码的地图?

还是我必须先对邮政编码进行地理编码并提交纬度/经度?

这就是我使用雅虎的方式......

//assign the zipcode from the database to the zipcode variable
zipCode = oUser("zipCode")

<script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=x">
</script>

// create the container 
<div id="map" class="map">

<script type="text/javascript"> 
// Create a map object 
var map = new YMap(document.getElementById('map')); 
// Display the map centered on the zipcode 
map.drawZoomAndCenter("<%=zipCode%>", 5); 
</script>

如果您访问 google.com/maps 并输入 5 位数的美国邮政编码,该网站将返回以该邮政编码中心点为中心的地图。上面的脚本在我的网站上做了同样的事情(直到雅虎停止了它的地图服务)。

我想使用 Google API 做同样的事情——但到目前为止我所看到的一切都表明我必须将邮政编码质心点的长/纬度字符串发送到 API——这很好(我们有数据库中的邮政编码/长/纬度表)——它只需要在我们端进行更多的服务器工作——或者如果我动态地对邮政编码进行地理编码,则在谷歌上)。我想尽可能保持高效,并尽可能只发送 postal_code。

可以这样做吗?

谢谢,

  • 迈克尔
4

0 回答 0