1

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()

kalifa17
  • 137
  • 7

1 Answers1

1

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

kalifa17
  • 137
  • 7
Alexandre Dubé
  • 2,769
  • 1
  • 18
  • 30
  • Thanks Alexandre, your solution works perfect, however im struggling now to integrate this with the tombatossals/angular-openlayers-directive, the map disappears after doing this..I might post a separte question with a jsfiddle showing the error in case I dont find the better way to integrate that. – kalifa17 Apr 26 '16 at 14:58
  • here is my new question in case you have used this library in the past. Thanks again! [question](http://stackoverflow.com/questions/36869725/change-maxzoom-option-in-runtime-to-ol-view-in-angular-openlayers-directive) – kalifa17 Apr 26 '16 at 15:49