Google maps api 3 谷歌地图API';不能正确设置缩放

Google maps api 3 谷歌地图API';不能正确设置缩放,google-maps-api-3,fitbounds,Google Maps Api 3,Fitbounds,我有一个问题,我认为fitBounds调用没有正确设置缩放级别。我已经在这里复制了我的测试用例——基本上,四个外部点是我正在设置的边界,如果你加载页面,然后放大一个级别,它们仍然可见。那么,谷歌地图为什么不将缩放级别设置为这一级别呢 谢谢,Tom,我通过以下方法解决了这个问题: var minlatminlong = new google.maps.LatLng({{ min_latitude }}, {{ min_longitude }}); var minlatmaxlong = n

我有一个问题,我认为fitBounds调用没有正确设置缩放级别。我已经在这里复制了我的测试用例——基本上,四个外部点是我正在设置的边界,如果你加载页面,然后放大一个级别,它们仍然可见。那么,谷歌地图为什么不将缩放级别设置为这一级别呢


谢谢,Tom,我通过以下方法解决了这个问题:

  var minlatminlong = new google.maps.LatLng({{ min_latitude }}, {{ min_longitude }});
  var minlatmaxlong = new google.maps.LatLng({{ min_latitude }}, {{ max_longitude }});
  var maxlatminlong = new google.maps.LatLng({{ max_latitude }}, {{ min_longitude }});
  var maxlatmaxlong = new google.maps.LatLng({{ max_latitude }}, {{ max_longitude }});

  zoomChangeBoundsListener = google.maps.event.addListener(map, 'bounds_changed', function(){
      var bounds = this.getBounds();
      if ((bounds.getSouthWest().lng() > {{ min_longitude }}) || (bounds.getNorthEast().lng() < {{ max_longitude }}) || (bounds.getSouthWest().lat() > {{ min_latitude }}) || (bounds.getNorthEast().lat() < {{ max_latitude }})) {
          this.setZoom(this.getZoom() - 1);
      } else {
          google.maps.event.removeListener(zoomChangeBoundsListener);
      }
  });
var minlatminlong=new google.maps.LatLng({{min_lation},{{min_lation});
var minlatmaxlong=new google.maps.LatLng({{min_lation},{{max_lation}});
var maxlatminlong=new google.maps.LatLng({{max_lation},{{min_lation}});
var maxlatmaxlong=new google.maps.LatLng({{max_lation},{{{max_lation}});
zoomChangeBoundsListener=google.maps.event.addListener(映射,'bounds_changed',函数(){
var bounds=this.getBounds();
如果((bounds.getSouthWest().lng()>{{min_latitude}}}){124;}(bounds.GetNorthwest().lng(){{{{max_latitude}})}(bounds.getSouthWest().lat()>{min u latitude}}){124;(bounds.GetNorthwest().lat(){{{max_latitude}){
this.setZoom(this.getZoom()-1);
}否则{
google.maps.event.removeListener(zoomChangeBoundsListener);
}
});
请注意,{{和}}中包含的任何内容都是我传递到html模板中的变量。

顶部有边距,因此“默认”标记显示的可能是