Change maxZoom option in runtime to ol.View in Ope

2019-07-25 10:01发布

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.

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

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

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

1条回答
我想做一个坏孩纸
2楼-- · 2019-07-25 10:20

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

查看更多
登录 后发表回答