答案 0 :(得分:45)
google.maps.Circle
有一个getBounds()
方法,可以返回圆圈的LatLngBounds
。您可以将此边界用作google.maps.Map.fitBounds()
如果使用圆圈,您可以这样做:
map.fitBounds(circle.getBounds());
...在init-function的末尾。
答案 1 :(得分:17)
对于多个圈子,请使用联盟而不是扩展:
var bounds = new google.maps.LatLngBounds();
$.each(circles, function(index, circle){
bounds.union(circle.getBounds());
});
map.fitBounds(bounds);