Google Maps v3 fitBounds() Zoom too close for single marker

前端 未结 17 2126
别那么骄傲
别那么骄傲 2020-12-12 23:28

Is there a way to set a max zoom level for fitBounds()? My problem is that when the map is only fed one location, it zooms in as far as it can go, which really

17条回答
  •  无人及你
    2020-12-13 00:00

    You can setup your map with maxZoom in the MapOptions (api-reference) like this:

    var map = new google.maps.Map(document.getElementById("map"), { maxZoom: 10 });
    

    This would keep the map from zooming any deeper when using fitBounds() and even removes the zoom levels from the zoom control.

提交回复
热议问题