Module: ol/interaction/defaults

ol/interaction/defaults


函数s

import {defaults} from 'ol/interaction/defaults';

默认包含在地图中的交互集合。可以通过在构造函数选项中将相应选项设置为 false 来排除特定交互,但交互的顺序是固定的。如果要为交互指定不同的顺序,需要创建自己的 Interaction 实例,并在创建 Map 实例之前按所需顺序插入到 Collection 中。如果需要在某个点停止事件传播,更改顺序可能会很有用。默认的交互集合,按顺序为: DragRotate DoubleClickZoom DragPan PinchRotate PinchZoom KeyboardPan KeyboardZoom MouseWheelZoom DragZoom

Name Type Description
altShiftDragRotate boolean (defaults to true)

是否需要 Alt-Shift-拖动旋转。

onFocusOnly boolean (defaults to false)

仅在地图获得焦点时交互。这影响 MouseWheelZoom 和 DragPan 交互,当没有获得浏览器焦点的地图需要页面滚动时很有用。

doubleClickZoom boolean (defaults to true)

是否需要双击缩放。

keyboard boolean (defaults to true)

是否需要键盘交互。

mouseWheelZoom boolean (defaults to true)

是否需要鼠标滚轮缩放。

shiftDragZoom boolean (defaults to true)

是否需要 Shift-拖动缩放。

dragPan boolean (defaults to true)

是否需要拖动平移。

pinchRotate boolean (defaults to true)

是否需要捏合旋转。

pinchZoom boolean (defaults to true)

是否需要捏合缩放。

zoomDelta number | undefined

使用键盘或双击缩放时的缩放级别增量。

zoomDuration number | undefined

缩放动画持续时间(毫秒)。

返回值:
用于 Map 构造函数 interactions 选项的交互集合。

Type Definitions

DefaultsOptions{Object}

属性:
Name Type Description
altShiftDragRotate boolean
(defaults to true)

是否需要 Alt-Shift-拖动旋转。

onFocusOnly boolean
(defaults to false)

仅在地图获得焦点时交互。这影响 MouseWheelZoom 和 DragPan 交互,当没有获得浏览器焦点的地图需要页面滚动时很有用。

doubleClickZoom boolean
(defaults to true)

是否需要双击缩放。

keyboard boolean
(defaults to true)

是否需要键盘交互。

mouseWheelZoom boolean
(defaults to true)

是否需要鼠标滚轮缩放。

shiftDragZoom boolean
(defaults to true)

是否需要 Shift-拖动缩放。

dragPan boolean
(defaults to true)

是否需要拖动平移。

pinchRotate boolean
(defaults to true)

是否需要捏合旋转。

pinchZoom boolean
(defaults to true)

是否需要捏合缩放。

zoomDelta number | undefined

使用键盘或双击缩放时的缩放级别增量。

zoomDuration number | undefined

缩放动画持续时间(毫秒)。