限制 Mapbox 缩放
Restrict Mapbox Zooming
我是 mapbox 的新手,想在我的网站上放一个。我们如何确保它不会缩小到小于包含地图本身的 div。目前,它缩小到级别 1,在所有边上留下空白。
我用过下面的代码
<style>
#map {
position: relative;
padding-bottom: 50%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
</style>
<section id="content">
<div id="map"></div>
</section>
我还附上一张快照来说明问题...
根据the documentation for Mapbox.js你可以设置minZoom
(地图状态选项):
minZoom: Minimum zoom level of the map. Overrides any minZoom set on map layers.
如果您使用的是 Mapbox GL JS,则可以使用 options.minZoom
参数:
options.minZoom (default 0) The minimum zoom level of the map (1-20).
我是 mapbox 的新手,想在我的网站上放一个。我们如何确保它不会缩小到小于包含地图本身的 div。目前,它缩小到级别 1,在所有边上留下空白。
我用过下面的代码
<style>
#map {
position: relative;
padding-bottom: 50%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
</style>
<section id="content">
<div id="map"></div>
</section>
我还附上一张快照来说明问题...
根据the documentation for Mapbox.js你可以设置minZoom
(地图状态选项):
minZoom: Minimum zoom level of the map. Overrides any minZoom set on map layers.
如果您使用的是 Mapbox GL JS,则可以使用 options.minZoom
参数:
options.minZoom (default 0) The minimum zoom level of the map (1-20).