简体   繁体   中英

How can I disable mouseWheelZoom in OpenLayers 7?

I have just updated from OpenLayers 6 to version 7. I now get an error regarding the interactions. I want to disable the zoom so the page can be scrolled. Only when using "platformModifierKeyOnly" zooming via scroll should be possible. This is the code that used to work:

const map = new ol.Map({
    layers: [clusterHulls, clusters, clusterCircles],
    target: 'map',
    view: view,
    interactions: ol.interaction.defaults({
        dragPan: false,
        mouseWheelZoom: false
    }).extend([
        new ol.interaction.DragPan({
            condition: function (event) {
                return this.getPointerCount() === 2 || ol.events.condition.platformModifierKeyOnly(event);
            },
        }),
        new ol.interaction.MouseWheelZoom({
            condition: ol.events.condition.platformModifierKeyOnly,
        }),
    ]),
});

But now I get the following error in the console: ol.interaction.defaults is not a function .

Unfortunately the OpenLayers documentation doesn't help much to find out what needs to be changed to get this working again.

In OpenLayers 7 the syntax is is ol.interaction.defaults.defaults

See https://github.com/openlayers/openlayers/issues/14020

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM