在运行时将maxZoom选项更改为ol.View在Openlayers 3中 [英] Change maxZoom option in runtime to ol.View in Openlayers 3

查看:368
本文介绍了在运行时将maxZoom选项更改为ol.View在Openlayers 3中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

激活地图的功能后,我试图更改maxZoom选项.因此,必须在运行时将其回滚到原始的maxZoom.

Im trying to change the maxZoom option once a functionality of the map is activated. So it has to be during runtime so it can be rolled back to the original maxZoom.

创建ol.View时,您可以像下面这样配置此参数:

Creating the ol.View you configure this parameters like this:

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

但是,该API仅允许使用 setZoom( )

however, the api only allows to change zoom with setZoom()

推荐答案

您可以通过完全更改地图的视图来实现此目的:

You can accomplish this by changing the view of the map completely:

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

一个 jsfiddle 来测试解决方案

这篇关于在运行时将maxZoom选项更改为ol.View在Openlayers 3中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆