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

map = new ol.Map({
target: 'container',
layers: [
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() ?


Yes, it's setZoom() .

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

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


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

  • It's not setZoom() what i need. Please read carefully. I want to somehow set zoom factor. So that the scroll in will not zoom map with factor 2 but e.g. with factor 1.5. We can set the zoomFactor creating map but can we do that on the fly? – Standy Jun 7 '17 at 13:25

I think the only way to do it is by replacing the existing view of your map. Something like that should do the job:

function setNewZoomFactor(){
var newView = new ol.View({
    center: [0, 0],
    zoom: 2,
    zoomFactor:5//just replace with your desired zoom factor value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.