谷歌地图:如何缩小到地图上的所有位置
Google Maps: How to zoom out to all locations on map
我正在开发使用谷歌地图显示不同地点列表的应用程序,我一切正常,并与当前位置和最近的位置一起工作,它会缩放以显示这一点,但我试图更改它以设置它,以便它缩小以显示所有建筑物,而不仅仅是最近的建筑物
编辑:这是工作代码
// Sets the bounds of the map to include at lease one visable marker
function setBounds(){
if ( markerCluster.getMarkers().length > 0 && homeMarker != null){
map.setZoom(17);
var visableMarkers = markerCluster.getMarkers();
// want to set the starting position at the homeMarker
//Make an array of the LatLng's of the markers you want to show
var LatLngList = new Array ();
LatLngList.push(homeMarker.position);
$.each(visableMarkers, function() {
LatLngList.push(this.position);
});
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds ();
// Go through each...
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) {
// And increase the bounds to take this point
bounds.extend (LatLngList[i]);
}
// Fit these bounds to the map
map.fitBounds (bounds);
}
}
数组LatLngList
的代码不正确,我认为应该说
var LatLngList = new Array (new google.maps.LatLng (52.537,-2.061), new google.maps.LatLng (52.564,-2.017));
相关文章:
- PHP谷歌地图-位置红色气球没有显示
- Bing地图图钉宽度设置会将图钉从地图位置移开
- 谷歌地图位置自动完成被jQuery Mobile弹出窗口阻止
- 地图位置带有照片和其他详细信息的详细信息
- 将显示为 XML 格式的 Google 地图位置转换为输出 (ASP.Net、C#)
- 具有常规位置类型的谷歌地图位置构造函数
- 如何使用自己的地址/坐标生成指向 Google 地图位置的准确链接?有没有这方面的API
- 谷歌地图API:将标记放在当前地图位置
- 返回我之前指定的谷歌地图位置列表
- 将地图位置信息从PHP传递到javascript,以便与Google地图v3api一起使用
- 谷歌地图V3保存用户使用拖放后的地图位置;滴
- Jquery谷歌地图位置-获取选择选项
- 更新基于gps坐标的谷歌地图位置
- ArcGIS初始地图位置
- 谷歌地图位置搜索框:如何重新计算pac-container的位置
- 使用jquery移动显示地图位置,使用经度和纬度
- 谷歌地图位置API地址自动完成和显示选择的结果
- 点击按钮时更新地图位置
- 触发谷歌地图位置信息窗口
- MapsApi -谷歌地图位置服务给出一个奇怪的错误