Merge pull request #13967 from tschaub/uncircular
Remove circular dependency
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
<div class="card h-100 bg-light">
|
<div class="card h-100 bg-light">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">Controls</h4>
|
<h4 class="card-title">Controls</h4>
|
||||||
<a href="module-ol_control.html#.defaults">Map default controls</a><br>
|
<a href="module-ol_control_defaults#.defaults">Map default controls</a><br>
|
||||||
<a href="module-ol_control_Control-Control.html">All controls</a>
|
<a href="module-ol_control_Control-Control.html">All controls</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
<div class="card h-100 bg-light">
|
<div class="card h-100 bg-light">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">Interactions</h4>
|
<h4 class="card-title">Interactions</h4>
|
||||||
<a href="module-ol_interaction.html#~defaults">Map default interactions</a><br>
|
<a href="module-ol_interaction_defaults#.defaults">Map default interactions</a><br>
|
||||||
Interactions for <a href="module-ol_Feature-Feature.html">vector features</a>
|
Interactions for <a href="module-ol_Feature-Feature.html">vector features</a>
|
||||||
<ul><li><a href="module-ol_interaction_Select-Select.html">ol/interaction/Select</a></li>
|
<ul><li><a href="module-ol_interaction_Select-Select.html">ol/interaction/Select</a></li>
|
||||||
<li><a href="module-ol_interaction_Draw-Draw.html">ol/interaction/Draw</a></li>
|
<li><a href="module-ol_interaction_Draw-Draw.html">ol/interaction/Draw</a></li>
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ if (/-dev$/.test(version)) {
|
|||||||
</dt>
|
</dt>
|
||||||
<dd class="<?js= (data.stability && data.stability !== 'stable') ? 'unstable' : '' ?>">
|
<dd class="<?js= (data.stability && data.stability !== 'stable') ? 'unstable' : '' ?>">
|
||||||
|
|
||||||
<?js if (data.parent && data.parent.kind == 'module' && data.parent.name.split('ol/').length < 3) { ?>
|
<?js if (data.parent && data.parent.kind == 'module') { ?>
|
||||||
<pre class="prettyprint source"><code>import {<?js= data.name ?>} from '<?js= data.parent.name ?>';</code></pre>
|
<?js const importName = data.isDefaultExport ? data.name : `{${data.name}}`; ?>
|
||||||
|
<pre class="prettyprint source"><code>import <?js= importName ?> from '<?js= data.parent.name ?>';</code></pre>
|
||||||
<?js } ?>
|
<?js } ?>
|
||||||
|
|
||||||
<?js if (data.description) { ?>
|
<?js if (data.description) { ?>
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import {
|
|||||||
getForViewAndSize,
|
getForViewAndSize,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
} from './extent.js';
|
} from './extent.js';
|
||||||
import {defaults as defaultControls} from './control.js';
|
import {defaults as defaultControls} from './control/defaults.js';
|
||||||
import {defaults as defaultInteractions} from './interaction.js';
|
import {defaults as defaultInteractions} from './interaction/defaults.js';
|
||||||
import {fromUserCoordinate, toUserCoordinate} from './proj.js';
|
import {fromUserCoordinate, toUserCoordinate} from './proj.js';
|
||||||
import {getUid} from './util.js';
|
import {getUid} from './util.js';
|
||||||
import {hasArea} from './size.js';
|
import {hasArea} from './size.js';
|
||||||
@@ -115,12 +115,12 @@ import {removeNode} from './dom.js';
|
|||||||
* @typedef {Object} MapOptions
|
* @typedef {Object} MapOptions
|
||||||
* @property {Collection<import("./control/Control.js").default>|Array<import("./control/Control.js").default>} [controls]
|
* @property {Collection<import("./control/Control.js").default>|Array<import("./control/Control.js").default>} [controls]
|
||||||
* Controls initially added to the map. If not specified,
|
* Controls initially added to the map. If not specified,
|
||||||
* {@link module:ol/control.defaults} is used.
|
* {@link module:ol/control/defaults.defaults} is used.
|
||||||
* @property {number} [pixelRatio=window.devicePixelRatio] The ratio between
|
* @property {number} [pixelRatio=window.devicePixelRatio] The ratio between
|
||||||
* physical pixels and device-independent pixels (dips) on the device.
|
* physical pixels and device-independent pixels (dips) on the device.
|
||||||
* @property {Collection<import("./interaction/Interaction.js").default>|Array<import("./interaction/Interaction.js").default>} [interactions]
|
* @property {Collection<import("./interaction/Interaction.js").default>|Array<import("./interaction/Interaction.js").default>} [interactions]
|
||||||
* Interactions that are initially added to the map. If not specified,
|
* Interactions that are initially added to the map. If not specified,
|
||||||
* {@link module:ol/interaction.defaults} is used.
|
* {@link module:ol/interaction/defaults.defaults} is used.
|
||||||
* @property {HTMLElement|Document|string} [keyboardEventTarget] The element to
|
* @property {HTMLElement|Document|string} [keyboardEventTarget] The element to
|
||||||
* listen to keyboard events on. This determines when the `KeyboardPan` and
|
* listen to keyboard events on. This determines when the `KeyboardPan` and
|
||||||
* `KeyboardZoom` interactions trigger. For example, if this option is set to
|
* `KeyboardZoom` interactions trigger. For example, if this option is set to
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/control
|
* @module ol/control
|
||||||
*/
|
*/
|
||||||
import Attribution from './control/Attribution.js';
|
|
||||||
import Collection from './Collection.js';
|
|
||||||
import Rotate from './control/Rotate.js';
|
|
||||||
import Zoom from './control/Zoom.js';
|
|
||||||
|
|
||||||
export {default as Attribution} from './control/Attribution.js';
|
export {default as Attribution} from './control/Attribution.js';
|
||||||
export {default as Control} from './control/Control.js';
|
export {default as Control} from './control/Control.js';
|
||||||
export {default as FullScreen} from './control/FullScreen.js';
|
export {default as FullScreen} from './control/FullScreen.js';
|
||||||
@@ -16,58 +11,4 @@ export {default as ScaleLine} from './control/ScaleLine.js';
|
|||||||
export {default as Zoom} from './control/Zoom.js';
|
export {default as Zoom} from './control/Zoom.js';
|
||||||
export {default as ZoomSlider} from './control/ZoomSlider.js';
|
export {default as ZoomSlider} from './control/ZoomSlider.js';
|
||||||
export {default as ZoomToExtent} from './control/ZoomToExtent.js';
|
export {default as ZoomToExtent} from './control/ZoomToExtent.js';
|
||||||
|
export {defaults} from './control/defaults.js';
|
||||||
/**
|
|
||||||
* @typedef {Object} DefaultsOptions
|
|
||||||
* @property {boolean} [attribution=true] Include
|
|
||||||
* {@link module:ol/control/Attribution~Attribution}.
|
|
||||||
* @property {import("./control/Attribution.js").Options} [attributionOptions]
|
|
||||||
* Options for {@link module:ol/control/Attribution~Attribution}.
|
|
||||||
* @property {boolean} [rotate=true] Include
|
|
||||||
* {@link module:ol/control/Rotate~Rotate}.
|
|
||||||
* @property {import("./control/Rotate.js").Options} [rotateOptions] Options
|
|
||||||
* for {@link module:ol/control/Rotate~Rotate}.
|
|
||||||
* @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}.
|
|
||||||
* @property {import("./control/Zoom.js").Options} [zoomOptions] Options for
|
|
||||||
* {@link module:ol/control/Zoom~Zoom}.
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set of controls included in maps by default. Unless configured otherwise,
|
|
||||||
* this returns a collection containing an instance of each of the following
|
|
||||||
* controls:
|
|
||||||
* * {@link module:ol/control/Zoom~Zoom}
|
|
||||||
* * {@link module:ol/control/Rotate~Rotate}
|
|
||||||
* * {@link module:ol/control/Attribution~Attribution}
|
|
||||||
*
|
|
||||||
* @param {DefaultsOptions} [opt_options]
|
|
||||||
* Defaults options.
|
|
||||||
* @return {Collection<import("./control/Control.js").default>}
|
|
||||||
* Controls.
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
export function defaults(opt_options) {
|
|
||||||
const options = opt_options ? opt_options : {};
|
|
||||||
|
|
||||||
/** @type {Collection<import("./control/Control.js").default>} */
|
|
||||||
const controls = new Collection();
|
|
||||||
|
|
||||||
const zoomControl = options.zoom !== undefined ? options.zoom : true;
|
|
||||||
if (zoomControl) {
|
|
||||||
controls.push(new Zoom(options.zoomOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
const rotateControl = options.rotate !== undefined ? options.rotate : true;
|
|
||||||
if (rotateControl) {
|
|
||||||
controls.push(new Rotate(options.rotateOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
const attributionControl =
|
|
||||||
options.attribution !== undefined ? options.attribution : true;
|
|
||||||
if (attributionControl) {
|
|
||||||
controls.push(new Attribution(options.attributionOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
return controls;
|
|
||||||
}
|
|
||||||
|
|||||||
60
src/ol/control/defaults.js
Normal file
60
src/ol/control/defaults.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* @module ol/control/defaults
|
||||||
|
*/
|
||||||
|
import Attribution from './Attribution.js';
|
||||||
|
import Collection from '../Collection.js';
|
||||||
|
import Rotate from './Rotate.js';
|
||||||
|
import Zoom from './Zoom.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} DefaultsOptions
|
||||||
|
* @property {boolean} [attribution=true] Include
|
||||||
|
* {@link module:ol/control/Attribution~Attribution}.
|
||||||
|
* @property {import("./Attribution.js").Options} [attributionOptions]
|
||||||
|
* Options for {@link module:ol/control/Attribution~Attribution}.
|
||||||
|
* @property {boolean} [rotate=true] Include
|
||||||
|
* {@link module:ol/control/Rotate~Rotate}.
|
||||||
|
* @property {import("./Rotate.js").Options} [rotateOptions] Options
|
||||||
|
* for {@link module:ol/control/Rotate~Rotate}.
|
||||||
|
* @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}.
|
||||||
|
* @property {import("./Zoom.js").Options} [zoomOptions] Options for
|
||||||
|
* {@link module:ol/control/Zoom~Zoom}.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of controls included in maps by default. Unless configured otherwise,
|
||||||
|
* this returns a collection containing an instance of each of the following
|
||||||
|
* controls:
|
||||||
|
* * {@link module:ol/control/Zoom~Zoom}
|
||||||
|
* * {@link module:ol/control/Rotate~Rotate}
|
||||||
|
* * {@link module:ol/control/Attribution~Attribution}
|
||||||
|
*
|
||||||
|
* @param {DefaultsOptions} [opt_options] Options for the default controls.
|
||||||
|
* @return {Collection<import("./Control.js").default>} A collection of controls
|
||||||
|
* to be used with the {@link module:ol/Map~Map} constructor's `controls` option.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
export function defaults(opt_options) {
|
||||||
|
const options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
|
/** @type {Collection<import("./Control.js").default>} */
|
||||||
|
const controls = new Collection();
|
||||||
|
|
||||||
|
const zoomControl = options.zoom !== undefined ? options.zoom : true;
|
||||||
|
if (zoomControl) {
|
||||||
|
controls.push(new Zoom(options.zoomOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
const rotateControl = options.rotate !== undefined ? options.rotate : true;
|
||||||
|
if (rotateControl) {
|
||||||
|
controls.push(new Rotate(options.rotateOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
const attributionControl =
|
||||||
|
options.attribution !== undefined ? options.attribution : true;
|
||||||
|
if (attributionControl) {
|
||||||
|
controls.push(new Attribution(options.attributionOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
return controls;
|
||||||
|
}
|
||||||
@@ -1,18 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/interaction
|
* @module ol/interaction
|
||||||
*/
|
*/
|
||||||
import Collection from './Collection.js';
|
|
||||||
import DoubleClickZoom from './interaction/DoubleClickZoom.js';
|
|
||||||
import DragPan from './interaction/DragPan.js';
|
|
||||||
import DragRotate from './interaction/DragRotate.js';
|
|
||||||
import DragZoom from './interaction/DragZoom.js';
|
|
||||||
import KeyboardPan from './interaction/KeyboardPan.js';
|
|
||||||
import KeyboardZoom from './interaction/KeyboardZoom.js';
|
|
||||||
import Kinetic from './Kinetic.js';
|
|
||||||
import MouseWheelZoom from './interaction/MouseWheelZoom.js';
|
|
||||||
import PinchRotate from './interaction/PinchRotate.js';
|
|
||||||
import PinchZoom from './interaction/PinchZoom.js';
|
|
||||||
|
|
||||||
export {default as DoubleClickZoom} from './interaction/DoubleClickZoom.js';
|
export {default as DoubleClickZoom} from './interaction/DoubleClickZoom.js';
|
||||||
export {default as DragAndDrop} from './interaction/DragAndDrop.js';
|
export {default as DragAndDrop} from './interaction/DragAndDrop.js';
|
||||||
export {default as DragBox} from './interaction/DragBox.js';
|
export {default as DragBox} from './interaction/DragBox.js';
|
||||||
@@ -34,137 +22,4 @@ export {default as Pointer} from './interaction/Pointer.js';
|
|||||||
export {default as Select} from './interaction/Select.js';
|
export {default as Select} from './interaction/Select.js';
|
||||||
export {default as Snap} from './interaction/Snap.js';
|
export {default as Snap} from './interaction/Snap.js';
|
||||||
export {default as Translate} from './interaction/Translate.js';
|
export {default as Translate} from './interaction/Translate.js';
|
||||||
|
export {defaults} from './interaction/defaults.js';
|
||||||
/**
|
|
||||||
* @typedef {Object} DefaultsOptions
|
|
||||||
* @property {boolean} [altShiftDragRotate=true] Whether Alt-Shift-drag rotate is
|
|
||||||
* desired.
|
|
||||||
* @property {boolean} [onFocusOnly=false] Interact only when the map has the
|
|
||||||
* focus. This affects the `MouseWheelZoom` and `DragPan` interactions and is
|
|
||||||
* useful when page scroll is desired for maps that do not have the browser's
|
|
||||||
* focus.
|
|
||||||
* @property {boolean} [doubleClickZoom=true] Whether double click zoom is
|
|
||||||
* desired.
|
|
||||||
* @property {boolean} [keyboard=true] Whether keyboard interaction is desired.
|
|
||||||
* @property {boolean} [mouseWheelZoom=true] Whether mousewheel zoom is desired.
|
|
||||||
* @property {boolean} [shiftDragZoom=true] Whether Shift-drag zoom is desired.
|
|
||||||
* @property {boolean} [dragPan=true] Whether drag pan is desired.
|
|
||||||
* @property {boolean} [pinchRotate=true] Whether pinch rotate is desired.
|
|
||||||
* @property {boolean} [pinchZoom=true] Whether pinch zoom is desired.
|
|
||||||
* @property {number} [zoomDelta] Zoom level delta when using keyboard or double click zoom.
|
|
||||||
* @property {number} [zoomDuration] Duration of the zoom animation in
|
|
||||||
* milliseconds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set of interactions included in maps by default. Specific interactions can be
|
|
||||||
* excluded by setting the appropriate option to false in the constructor
|
|
||||||
* options, but the order of the interactions is fixed. If you want to specify
|
|
||||||
* a different order for interactions, you will need to create your own
|
|
||||||
* {@link module:ol/interaction/Interaction~Interaction} instances and insert
|
|
||||||
* them into a {@link module:ol/Collection~Collection} in the order you want
|
|
||||||
* before creating your {@link module:ol/Map~Map} instance. Changing the order can
|
|
||||||
* be of interest if the event propagation needs to be stopped at a point.
|
|
||||||
* The default set of interactions, in sequence, is:
|
|
||||||
* * {@link module:ol/interaction/DragRotate~DragRotate}
|
|
||||||
* * {@link module:ol/interaction/DoubleClickZoom~DoubleClickZoom}
|
|
||||||
* * {@link module:ol/interaction/DragPan~DragPan}
|
|
||||||
* * {@link module:ol/interaction/PinchRotate~PinchRotate}
|
|
||||||
* * {@link module:ol/interaction/PinchZoom~PinchZoom}
|
|
||||||
* * {@link module:ol/interaction/KeyboardPan~KeyboardPan}
|
|
||||||
* * {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}
|
|
||||||
* * {@link module:ol/interaction/MouseWheelZoom~MouseWheelZoom}
|
|
||||||
* * {@link module:ol/interaction/DragZoom~DragZoom}
|
|
||||||
*
|
|
||||||
* @param {DefaultsOptions} [opt_options] Defaults options.
|
|
||||||
* @return {import("./Collection.js").default<import("./interaction/Interaction.js").default>}
|
|
||||||
* A collection of interactions to be used with the {@link module:ol/Map~Map}
|
|
||||||
* constructor's `interactions` option.
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
export function defaults(opt_options) {
|
|
||||||
const options = opt_options ? opt_options : {};
|
|
||||||
|
|
||||||
/** @type {Collection<import("./interaction/Interaction.js").default>} */
|
|
||||||
const interactions = new Collection();
|
|
||||||
|
|
||||||
const kinetic = new Kinetic(-0.005, 0.05, 100);
|
|
||||||
|
|
||||||
const altShiftDragRotate =
|
|
||||||
options.altShiftDragRotate !== undefined
|
|
||||||
? options.altShiftDragRotate
|
|
||||||
: true;
|
|
||||||
if (altShiftDragRotate) {
|
|
||||||
interactions.push(new DragRotate());
|
|
||||||
}
|
|
||||||
|
|
||||||
const doubleClickZoom =
|
|
||||||
options.doubleClickZoom !== undefined ? options.doubleClickZoom : true;
|
|
||||||
if (doubleClickZoom) {
|
|
||||||
interactions.push(
|
|
||||||
new DoubleClickZoom({
|
|
||||||
delta: options.zoomDelta,
|
|
||||||
duration: options.zoomDuration,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const dragPan = options.dragPan !== undefined ? options.dragPan : true;
|
|
||||||
if (dragPan) {
|
|
||||||
interactions.push(
|
|
||||||
new DragPan({
|
|
||||||
onFocusOnly: options.onFocusOnly,
|
|
||||||
kinetic: kinetic,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pinchRotate =
|
|
||||||
options.pinchRotate !== undefined ? options.pinchRotate : true;
|
|
||||||
if (pinchRotate) {
|
|
||||||
interactions.push(new PinchRotate());
|
|
||||||
}
|
|
||||||
|
|
||||||
const pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
|
|
||||||
if (pinchZoom) {
|
|
||||||
interactions.push(
|
|
||||||
new PinchZoom({
|
|
||||||
duration: options.zoomDuration,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const keyboard = options.keyboard !== undefined ? options.keyboard : true;
|
|
||||||
if (keyboard) {
|
|
||||||
interactions.push(new KeyboardPan());
|
|
||||||
interactions.push(
|
|
||||||
new KeyboardZoom({
|
|
||||||
delta: options.zoomDelta,
|
|
||||||
duration: options.zoomDuration,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const mouseWheelZoom =
|
|
||||||
options.mouseWheelZoom !== undefined ? options.mouseWheelZoom : true;
|
|
||||||
if (mouseWheelZoom) {
|
|
||||||
interactions.push(
|
|
||||||
new MouseWheelZoom({
|
|
||||||
onFocusOnly: options.onFocusOnly,
|
|
||||||
duration: options.zoomDuration,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const shiftDragZoom =
|
|
||||||
options.shiftDragZoom !== undefined ? options.shiftDragZoom : true;
|
|
||||||
if (shiftDragZoom) {
|
|
||||||
interactions.push(
|
|
||||||
new DragZoom({
|
|
||||||
duration: options.zoomDuration,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return interactions;
|
|
||||||
}
|
|
||||||
|
|||||||
148
src/ol/interaction/defaults.js
Normal file
148
src/ol/interaction/defaults.js
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/**
|
||||||
|
* @module ol/interaction/defaults
|
||||||
|
*/
|
||||||
|
import Collection from '../Collection.js';
|
||||||
|
import DoubleClickZoom from './DoubleClickZoom.js';
|
||||||
|
import DragPan from './DragPan.js';
|
||||||
|
import DragRotate from './DragRotate.js';
|
||||||
|
import DragZoom from './DragZoom.js';
|
||||||
|
import KeyboardPan from './KeyboardPan.js';
|
||||||
|
import KeyboardZoom from './KeyboardZoom.js';
|
||||||
|
import Kinetic from '../Kinetic.js';
|
||||||
|
import MouseWheelZoom from './MouseWheelZoom.js';
|
||||||
|
import PinchRotate from './PinchRotate.js';
|
||||||
|
import PinchZoom from './PinchZoom.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} DefaultsOptions
|
||||||
|
* @property {boolean} [altShiftDragRotate=true] Whether Alt-Shift-drag rotate is
|
||||||
|
* desired.
|
||||||
|
* @property {boolean} [onFocusOnly=false] Interact only when the map has the
|
||||||
|
* focus. This affects the `MouseWheelZoom` and `DragPan` interactions and is
|
||||||
|
* useful when page scroll is desired for maps that do not have the browser's
|
||||||
|
* focus.
|
||||||
|
* @property {boolean} [doubleClickZoom=true] Whether double click zoom is
|
||||||
|
* desired.
|
||||||
|
* @property {boolean} [keyboard=true] Whether keyboard interaction is desired.
|
||||||
|
* @property {boolean} [mouseWheelZoom=true] Whether mousewheel zoom is desired.
|
||||||
|
* @property {boolean} [shiftDragZoom=true] Whether Shift-drag zoom is desired.
|
||||||
|
* @property {boolean} [dragPan=true] Whether drag pan is desired.
|
||||||
|
* @property {boolean} [pinchRotate=true] Whether pinch rotate is desired.
|
||||||
|
* @property {boolean} [pinchZoom=true] Whether pinch zoom is desired.
|
||||||
|
* @property {number} [zoomDelta] Zoom level delta when using keyboard or double click zoom.
|
||||||
|
* @property {number} [zoomDuration] Duration of the zoom animation in
|
||||||
|
* milliseconds.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of interactions included in maps by default. Specific interactions can be
|
||||||
|
* excluded by setting the appropriate option to false in the constructor
|
||||||
|
* options, but the order of the interactions is fixed. If you want to specify
|
||||||
|
* a different order for interactions, you will need to create your own
|
||||||
|
* {@link module:ol/interaction/Interaction~Interaction} instances and insert
|
||||||
|
* them into a {@link module:ol/Collection~Collection} in the order you want
|
||||||
|
* before creating your {@link module:ol/Map~Map} instance. Changing the order can
|
||||||
|
* be of interest if the event propagation needs to be stopped at a point.
|
||||||
|
* The default set of interactions, in sequence, is:
|
||||||
|
* * {@link module:ol/interaction/DragRotate~DragRotate}
|
||||||
|
* * {@link module:ol/interaction/DoubleClickZoom~DoubleClickZoom}
|
||||||
|
* * {@link module:ol/interaction/DragPan~DragPan}
|
||||||
|
* * {@link module:ol/interaction/PinchRotate~PinchRotate}
|
||||||
|
* * {@link module:ol/interaction/PinchZoom~PinchZoom}
|
||||||
|
* * {@link module:ol/interaction/KeyboardPan~KeyboardPan}
|
||||||
|
* * {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}
|
||||||
|
* * {@link module:ol/interaction/MouseWheelZoom~MouseWheelZoom}
|
||||||
|
* * {@link module:ol/interaction/DragZoom~DragZoom}
|
||||||
|
*
|
||||||
|
* @param {DefaultsOptions} [opt_options] Defaults options.
|
||||||
|
* @return {Collection<import("./Interaction.js").default>}
|
||||||
|
* A collection of interactions to be used with the {@link module:ol/Map~Map}
|
||||||
|
* constructor's `interactions` option.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
export function defaults(opt_options) {
|
||||||
|
const options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
|
/** @type {Collection<import("./Interaction.js").default>} */
|
||||||
|
const interactions = new Collection();
|
||||||
|
|
||||||
|
const kinetic = new Kinetic(-0.005, 0.05, 100);
|
||||||
|
|
||||||
|
const altShiftDragRotate =
|
||||||
|
options.altShiftDragRotate !== undefined
|
||||||
|
? options.altShiftDragRotate
|
||||||
|
: true;
|
||||||
|
if (altShiftDragRotate) {
|
||||||
|
interactions.push(new DragRotate());
|
||||||
|
}
|
||||||
|
|
||||||
|
const doubleClickZoom =
|
||||||
|
options.doubleClickZoom !== undefined ? options.doubleClickZoom : true;
|
||||||
|
if (doubleClickZoom) {
|
||||||
|
interactions.push(
|
||||||
|
new DoubleClickZoom({
|
||||||
|
delta: options.zoomDelta,
|
||||||
|
duration: options.zoomDuration,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const dragPan = options.dragPan !== undefined ? options.dragPan : true;
|
||||||
|
if (dragPan) {
|
||||||
|
interactions.push(
|
||||||
|
new DragPan({
|
||||||
|
onFocusOnly: options.onFocusOnly,
|
||||||
|
kinetic: kinetic,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const pinchRotate =
|
||||||
|
options.pinchRotate !== undefined ? options.pinchRotate : true;
|
||||||
|
if (pinchRotate) {
|
||||||
|
interactions.push(new PinchRotate());
|
||||||
|
}
|
||||||
|
|
||||||
|
const pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
|
||||||
|
if (pinchZoom) {
|
||||||
|
interactions.push(
|
||||||
|
new PinchZoom({
|
||||||
|
duration: options.zoomDuration,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyboard = options.keyboard !== undefined ? options.keyboard : true;
|
||||||
|
if (keyboard) {
|
||||||
|
interactions.push(new KeyboardPan());
|
||||||
|
interactions.push(
|
||||||
|
new KeyboardZoom({
|
||||||
|
delta: options.zoomDelta,
|
||||||
|
duration: options.zoomDuration,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mouseWheelZoom =
|
||||||
|
options.mouseWheelZoom !== undefined ? options.mouseWheelZoom : true;
|
||||||
|
if (mouseWheelZoom) {
|
||||||
|
interactions.push(
|
||||||
|
new MouseWheelZoom({
|
||||||
|
onFocusOnly: options.onFocusOnly,
|
||||||
|
duration: options.zoomDuration,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const shiftDragZoom =
|
||||||
|
options.shiftDragZoom !== undefined ? options.shiftDragZoom : true;
|
||||||
|
if (shiftDragZoom) {
|
||||||
|
interactions.push(
|
||||||
|
new DragZoom({
|
||||||
|
duration: options.zoomDuration,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return interactions;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user