如何避免放大this.map.fitBounds()?执行this.map.fitBounds将放大或缩小地图以拟合定界值。我想避免放大fitBounds的功能。我怎么能那样做?
尝试过的Following.This将在执行fitBounds()之后执行。需要在执行fitBounds()之前执行
var lineBounds = this._trail.getLineBounds()
, current_zoom = this.map.getZoom()
, center = this.map.getCenter();
this.map.fitBounds(lineBounds, {
padding: [29, 29],
});
this.map.once('zoomend', function() {
if (current_zoom > this.map.getZoom()) {
this.map.setView(center, current_zoom);
}
}.bind(this));发布于 2015-10-19 11:14:01
您必须设置映射实例的minZoom选项。问题是您需要手动编辑映射实例的options对象。setMinZoom和setMaxZoom方法已经在传单v1.0.0-beta.2中引入,Mapbox还没有使用该版本。否则,您可以简单地执行map.setMinZoom(number),现在您将不得不求助于map.options.minZoom = number。因此,在拟合好您的边界后,使用map.getZoom方法获取映射的当前缩放因子,并将该因子值设置为您的minZoom选项。
https://stackoverflow.com/questions/33209900
复制相似问题