有几个点,然后显示一张地图,要求边界是刚刚好将这几个点包含。

2 views
Skip to first unread message

焰 熊

unread,
Nov 26, 2009, 10:44:53 PM11/26/09
to 谷歌地图 API 论坛
常规是setcenter 和zoom。在显示多个点时,有相应的设置地图的函数吗,还是要自己算中心或四个角坐标?
应该是个基础问题,但不知道,请指教。

Fei Chen

unread,
Nov 30, 2009, 2:50:24 AM11/30/09
to google-map...@googlegroups.com
使用GLatLngBounds.extend()方法:
var bounds = new GLatLngBounds();
for(point in points){
  bounds.extend(point);
}
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));


2009/11/27 焰 熊 <woyour...@gmail.com>
Reply all
Reply to author
Forward
0 new messages