对于多个圆圈使用 联盟 而不是 延伸:
var bounds = new google.maps.LatLngBounds();
$.each(circles, function(index, circle){
bounds.union(circle.getBounds());
});
map.fitBounds(bounds);
A google.maps.Circle
拥有 getBounds()
方法,该方法返回 LatLngBounds
的圆。你可以用这个边界作为 google.maps.Map.fitBounds()
如果使用一个圆,你可以这样做。
map.fitBounds(circle.getBounds());
...在init -function的结尾。