[GIS] OpenLayers 3 zoom factor

openlayers

I know we can create map with a zoom factor like:

map = new ol.Map({
target: 'container',
layers: [
    layer
],
view: new ol.View({
    maxResolution: res,
    extent: ext,
    zoomFactor: factor
}),
controls: [
   new ol.control.Zoom()
]

});

But is there any way to change this zoom factor on the fly? I want to make custom control to set that. Any function like map.getView().setZoomFactor() ?

Best Answer

Yes, it's setZoom() .

In your case: map.getView().setZoom(x)

Always a good idea to check the API for such simple things first :) .

EDIT:

My bad, misunderstood. No, you cannot alter the zoomfactor after initialization right now, just as you can't change a lot of view constraints programmatically. The established workflow is to recreate the view with the new setting and then set that on the map. However, it is being worked on and might come sooner or later ( latest updates of OL gave us setMaxZoom/setMinZoom, at least!)

Related Question