簡體   English   中英

如何在 OpenLayers 7 中禁用 mouseWheelZoom?

[英]How can I disable mouseWheelZoom in OpenLayers 7?

我剛剛從 OpenLayers 6 更新到版本 7。我現在收到有關交互的錯誤。 我想禁用縮放,以便可以滾動頁面。 只有在使用“platformModifierKeyOnly”時才可以通過滾動進行縮放。 這是曾經工作的代碼:

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,
        }),
    ]),
});

但是現在我在控制台中收到以下錯誤: ol.interaction.defaults is not a function

不幸的是,OpenLayers 文檔對於找出需要更改的內容以使其再次工作並沒有太大幫助。

在 OpenLayers 7 中,語法是ol.interaction.defaults.defaults

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM