openlayers禁止手指缩放地图、禁止拖拽…
openlayers阻止默认行为
dragPan: false, // 禁止拖拽
doubleClickZoom: false, // 禁用双击缩放
pinchZoom: false, // 禁止手指缩放地图
mouseWheelZoom: false, // 取消滚动鼠标中间的滑轮交互
shiftDragZoom: false, // 取消shift+wheel左键拖动交互
const map = new Map({
target: this.mapId,
layers: [],
view,
doubleClickZoom: false, // 禁用双击缩放
controls: [],
interactions: defaultInteractions({
dragPan: false, // 禁止拖拽
doubleClickZoom: false, // 禁用双击缩放
pinchZoom: false, // 禁止手指缩放地图
mouseWheelZoom: false, // 取消滚动鼠标中间的滑轮交互
shiftDragZoom: false, // 取消shift+wheel左键拖动交互
})
.extend([
new DragPan({
condition: function(event) {
return event.originalEvent.button === 1;
}
}),
new PinchZoom({ // 禁止地图缩放
constrainResolution: true
})
]),
});