简体   繁体   English

在运行时将 maxZoom 选项更改为 Openlayers 3 中的 ol.View

[英]Change maxZoom option in runtime to ol.View in Openlayers 3

Im trying to change the maxZoom option once a functionality of the map is activated.一旦激活地图的功能,我就会尝试更改 maxZoom 选项。 So it has to be during runtime so it can be rolled back to the original maxZoom.所以它必须在运行时才能回滚到原始的 maxZoom。

Creating the ol.View you configure this parameters like this:创建 ol.View 您可以像这样配置此参数:

new ol.View({
            ...
            zoom: 10,
            maxZoom: 17,
            minZoom: 10,
});

however, the api only allows to change zoom with setZoom()但是,api 只允许使用setZoom()更改缩放

You can accomplish this by changing the view of the map completely:您可以通过完全更改地图视图来完成此操作:

map.setView(new ol.View({
  zoom: 10,
  maxZoom: 17,
  minZoom: 10,
}));

Edit:编辑:

A jsfiddle to test the solution用于测试解决方案的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM