Change the maxZoom parameter at runtime to ol.View in the angular-openlayers directive

I posted this question to change maxZoom at runtime using openlayers3 and this works fine:

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

However, I am trying to integrate this solution using angular-openlayers-directive and the map disappears. Here's a demonstration of the plunger . I tried to create a new directive and also did not work.

olData.getMap().then(function(map){
  map.setView(new ol.View({
    zoom: 11,
    maxZoom: 11,
    minZoom: 0,
  }));
});

Any suggestions on how to integrate this, and if you could make it work in a Plunker demo, would be great.

+4
source share
2 answers

ol.View

http://openlayers.org/en/v3.2.1/apidoc/ol.View.html

ol.View, undefined. undefined, . $scope.changeZoom() undefined, . - .

Fix

olData.getMap().then(function(map){
   map.setView(new ol.View({
      center: ol.proj.transform([37.41, 8.82], 'EPSG:4326', 'EPSG:3857'),
      zoom: 11,
      maxZoom: 11,
      minZoom: 0,
   }));
});

. .

+1

, ( ol3, ), ol-debug.js, , , view .

:

$scope.changeZoom = function () {
    olData.getMap().then(function (map) {
        newView = new ol.View({
            zoom: 5,
            maxZoom: 20,
            minZoom: 0,
        });
        newView.setCenter(map.getView().getCenter());
        map.setView(newView);
    });
};

*.

* plunker , , , , !

0

All Articles