预测 this.map.fitBounds 之前的缩放级别

Predicting zoomlevel before this.map.fitBounds

我在我们的应用程序中使用 mapbox。执行 this.map.fitBounds(bound value) 将缩小或放大映射到指定值。在调用 this.map.fitBounds 之前,我需要找出缩放级别(即适合边界后的地图渲染)。 mapbox有什么方法可用吗?

使用L.MapgetBoundsZoom方法:

Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety.

http://leafletjs.com/reference.html#map-getboundszoom