Merge pull request #7989 from ahocevar/interaction-type

Redistribute olx types for ol/interaction
This commit is contained in:
Andreas Hocevar
2018-03-18 16:12:32 +01:00
committed by GitHub
26 changed files with 741 additions and 1703 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,299 +1,4 @@
/**
* @typedef {Object} interaction_DoubleClickZoomOptions
* @property {number|undefined} duration Animation duration in milliseconds. Default is `250`.
* @property {number|undefined} delta The zoom delta applied on each double click, default is `1`.
*/
/**
* @typedef {Object} interaction_DragAndDropOptions
* @property {Array.<function(new: ol.format.Feature)>|undefined} formatConstructors Format constructors.
* @property {ol.source.Vector|undefined} source Optional vector source where features will be added. If a source is provided
* all existing features will be removed and new features will be added when
* they are dropped on the target. If you want to add features to a vector
* source without removing the existing features (append only), instead of
* providing the source option listen for the "addfeatures" event.
* @property {ol.ProjectionLike} projection Target projection. By default, the map's view's projection is used.
* @property {Element|undefined} target The element that is used as the drop target, default is the viewport element.
*/
/**
* @typedef {Object} interaction_DragBoxOptions
* @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragbox`.
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.always}.
* @property {number|undefined} minArea The minimum area of the box in pixel, this value is used by the default
* `boxEndCondition` function. Default is `64`.
* @property {ol.DragBoxEndConditionType|undefined} boxEndCondition A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
* {@link ol.Pixel}s to indicate whether a `boxend` event should be fired.
* Default is `true` if the area of the box is bigger than the `minArea` option.
*/
/**
* @typedef {Object} interaction_DragPanOptions
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.noModifierKeys}.
* @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the pan.
*/
/**
* @typedef {Object} interaction_DragRotateAndZoomOptions
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.shiftKeyOnly}.
* @property {number|undefined} duration Animation duration in milliseconds. Default is `400`.
*/
/**
* @typedef {Object} interaction_DragRotateOptions
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.altShiftKeysOnly}.
* @property {number|undefined} duration Animation duration in milliseconds. Default is `250`.
*/
/**
* @typedef {Object} interaction_DragZoomOptions
* @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragzoom`.
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.shiftKeyOnly}.
* @property {number|undefined} duration Animation duration in milliseconds. Default is `200`.
* @property {boolean|undefined} out Use interaction for zooming out. Default is `false`.
*/
/**
* @typedef {Object} interaction_DrawOptions
* @property {number|undefined} clickTolerance The maximum distance in pixels between "down" and "up" for a "up" event
* to be considered a "click" event and actually add a point/vertex to the
* geometry being drawn. Default is 6 pixels. That value was chosen for
* the draw interaction to behave correctly on mouse as well as on touch
* devices.
* @property {ol.Collection.<module:ol/Feature~Feature>|undefined} features Destination collection for the drawn features.
* @property {ol.source.Vector|undefined} source Destination source for the drawn features.
* @property {number|undefined} dragVertexDelay Delay in milliseconds after pointerdown before the current vertex can be
* dragged to its exact position. Default is 500 ms.
* @property {number|undefined} snapTolerance Pixel distance for snapping to the drawing finish. Default is `12`.
* @property {module:ol/geom/GeometryType~GeometryType|string} type Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint',
* 'MultiLineString', 'MultiPolygon' or 'Circle').
* @property {boolean|undefined} stopClick Stop click, singleclick, and doubleclick events from firing during drawing.
* Default is `false`.
* @property {number|undefined} maxPoints The number of points that can be drawn before a polygon ring or line string
* is finished. The default is no restriction.
* @property {number|undefined} minPoints The number of points that must be drawn before a polygon ring or line string
* can be finished. Default is `3` for polygon rings and `2` for line strings.
* @property {ol.EventsConditionType|undefined} finishCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether the drawing can be finished.
* @property {ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined} style Style for sketch features.
* @property {ol.DrawGeometryFunctionType|undefined} geometryFunction Function that is called when a geometry's coordinates are updated.
* @property {string|undefined} geometryName Geometry name to use for features created by the draw interaction.
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* By default {@link ol.events.condition.noModifierKeys}, i.e. a click, adds a
* vertex or deactivates freehand drawing.
* @property {boolean|undefined} freehand Operate in freehand mode for lines, polygons, and circles. This makes the
* interaction always operate in freehand mode and takes precedence over any
* `freehandCondition` option.
* @property {ol.EventsConditionType|undefined} freehandCondition Condition that activates freehand drawing for lines and polygons. This
* function takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean to
* indicate whether that event should be handled. The default is
* {@link ol.events.condition.shiftKeyOnly}, meaning that the Shift key
* activates freehand drawing.
* @property {boolean|undefined} wrapX Wrap the world horizontally on the sketch overlay. Default is `false`.
*/
/**
* @typedef {Object} interaction_ExtentOptions
* @property {ol.Extent|undefined} extent Initial extent. Defaults to no initial extent
* @property {ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined} boxStyle Style for the drawn extent box.
* Defaults to ol.style.Style.createDefaultEditing()[module:ol/geom/GeometryType~GeometryType.POLYGON]
* @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or
* vertex for editing. Default is `10`.
* @property {ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined} pointerStyle Style for the cursor used to draw the extent.
* Defaults to ol.style.Style.createDefaultEditing()[module:ol/geom/GeometryType~GeometryType.POINT]
* @property {boolean|undefined} wrapX Wrap the drawn extent across multiple maps in the X direction?
* Only affects visuals, not functionality. Defaults to false.
*/
/**
* @typedef {Object} interaction_TranslateOptions
* @property {ol.Collection.<module:ol/Feature~Feature>|undefined} features Only features contained in this collection will be able to be translated. If
* not specified, all features on the map will be able to be translated.
* @property {undefined|Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean} layers A list of layers from which features should be
* translated. Alternatively, a filter function can be provided. The
* function will be called for each layer in the map and should return
* `true` for layers that you want to be translatable. If the option is
* absent, all visible layers will be considered translatable.
* @property {number|undefined} hitTolerance Hit-detection tolerance. Pixels inside the radius around the given position
* will be checked for features. This only works for the canvas renderer and
* not for WebGL. Default is `0`.
*/
/**
* @typedef {Object} interaction_KeyboardPanOptions
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.noModifierKeys} and
* {@link ol.events.condition.targetNotEditable}.
* @property {number|undefined} duration Animation duration in milliseconds. Default is `100`.
* @property {number|undefined} pixelDelta Pixel The amount to pan on each key press. Default is `128` pixels.
*/
/**
* @typedef {Object} interaction_KeyboardZoomOptions
* @property {number|undefined} duration Animation duration in milliseconds. Default is `100`.
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol.events.condition.targetNotEditable}.
* @property {number|undefined} delta The amount to zoom on each key press. Default is `1`.
*/
/**
* @typedef {Object} interaction_ModifyOptions
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event will be considered to add or move a vertex
* to the sketch.
* Default is {@link ol.events.condition.primaryAction}.
* @property {ol.EventsConditionType|undefined} deleteCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* By default, {@link ol.events.condition.singleClick} with
* {@link ol.events.condition.altKeyOnly} results in a vertex deletion.
* @property {ol.EventsConditionType|undefined} insertVertexCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether a new vertex can be added to the sketch features.
* Default is {@link ol.events.condition.always}
* @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or
* vertex for editing. Default is `10`.
* @property {ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined} style Style used for the features being modified. By default the default edit
* style is used (see {@link ol.style}).
* @property {ol.source.Vector|undefined} source The vector source with features to modify. If a vector source is not
* provided, a feature collection must be provided with the features option.
* @property {ol.Collection.<module:ol/Feature~Feature>|undefined} features The features the interaction works on. If a feature collection is not
* provided, a vector source must be provided with the source option.
* @property {boolean|undefined} wrapX Wrap the world horizontally on the sketch overlay. Default is `false`.
*/
/**
* @typedef {Object} interaction_MouseWheelZoomOptions
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled. Default is {@link ol.events.condition.always}.
* @property {number|undefined} duration Animation duration in milliseconds. Default is `250`.
* @property {number|undefined} timeout Mouse wheel timeout duration in milliseconds. Default is `80`.
* @property {boolean|undefined} constrainResolution When using a trackpad or magic mouse, zoom to the closest integer zoom level
* after the scroll gesture ends.
* Default is `false`.
* @property {boolean|undefined} useAnchor Enable zooming using the mouse's location as the anchor. Default is `true`.
* When set to false, zooming in and out will zoom to the center of the screen
* instead of zooming on the mouse's location.
*/
/**
* @typedef {Object} interaction_PinchRotateOptions
* @property {number|undefined} duration The duration of the animation in milliseconds. Default is `250`.
* @property {number|undefined} threshold Minimal angle in radians to start a rotation. Default is `0.3`.
*/
/**
* @typedef {Object} interaction_PinchZoomOptions
* @property {number|undefined} duration Animation duration in milliseconds. Default is `400`.
* @property {boolean|undefined} constrainResolution Zoom to the closest integer zoom level after the pinch gesture ends. Default is `false`.
*/
/**
* @typedef {Object} interaction_PointerOptions
* @property {(function(ol.MapBrowserPointerEvent):boolean|undefined)} handleDownEvent Function handling "down" events. If the function returns `true` then a drag
* sequence is started.
* @property {(function(ol.MapBrowserPointerEvent)|undefined)} handleDragEvent Function handling "drag" events. This function is called on "move" events
* during a drag sequence.
* @property {(function(module:ol/MapBrowserEvent~MapBrowserEvent):boolean|undefined)} handleEvent Method called by the map to notify the interaction that a browser event was
* dispatched to the map. The function may return `false` to prevent the
* propagation of the event to other interactions in the map's interactions
* chain.
* @property {(function(ol.MapBrowserPointerEvent)|undefined)} handleMoveEvent Function handling "move" events. This function is called on "move" events,
* also during a drag sequence (so during a drag sequence both the
* `handleDragEvent` function and this function are called).
* @property {(function(ol.MapBrowserPointerEvent):boolean|undefined)} handleUpEvent Function handling "up" events. If the function returns `false` then the
* current drag sequence is stopped.
*/
/**
* @typedef {Object} interaction_SelectOptions
* @property {ol.EventsConditionType|undefined} addCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* By default, this is {@link ol.events.condition.never}. Use this if you want
* to use different events for add and remove instead of `toggle`.
* @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* This is the event for the selected features as a whole. By default, this is
* {@link ol.events.condition.singleClick}. Clicking on a feature selects that
* feature and removes any that were in the selection. Clicking outside any
* feature removes all from the selection.
* See `toggle`, `add`, `remove` options for adding/removing extra features to/
* from the selection.
* @property {undefined|Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean} layers A list of layers from which features should be
* selected. Alternatively, a filter function can be provided. The
* function will be called for each layer in the map and should return
* `true` for layers that you want to be selectable. If the option is
* absent, all visible layers will be considered selectable.
* @property {ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined} style Style for the selected features. By default the default edit style is used
* (see {@link ol.style}).
* @property {ol.EventsConditionType|undefined} removeCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* By default, this is {@link ol.events.condition.never}. Use this if you want
* to use different events for add and remove instead of `toggle`.
* @property {ol.EventsConditionType|undefined} toggleCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* This is in addition to the `condition` event. By default,
* {@link ol.events.condition.shiftKeyOnly}, i.e. pressing `shift` as well as
* the `condition` event, adds that feature to the current selection if it is
* not currently selected, and removes it if it is.
* See `add` and `remove` if you want to use different events instead of a
* toggle.
* @property {boolean|undefined} multi A boolean that determines if the default behaviour should select only
* single features or all (overlapping) features at the clicked map
* position. Default is false i.e single select
* @property {ol.Collection.<module:ol/Feature~Feature>|undefined} features Collection where the interaction will place selected features. Optional. If
* not set the interaction will create a collection. In any case the collection
* used by the interaction is returned by
* {@link ol.interaction.Select#getFeatures}.
* @property {ol.SelectFilterFunction|undefined} filter A function that takes an {@link module:ol/Feature~Feature} and an {@link ol.layer.Layer} and
* returns `true` if the feature may be selected or `false` otherwise.
* @property {boolean|undefined} wrapX Wrap the world horizontally on the selection overlay. Default is `true`.
* @property {number|undefined} hitTolerance Hit-detection tolerance. Pixels inside the radius around the given position
* will be checked for features. This only works for the canvas renderer and
* not for WebGL. Default is `0`.
*/
/**
* @typedef {Object} interaction_SnapOptions
* @property {ol.Collection.<module:ol/Feature~Feature>|undefined} features Snap to these features. Either this option or source should be provided.
* @property {boolean|undefined} edge Snap to edges. Default is `true`.
* @property {boolean|undefined} vertex Snap to vertices. Default is `true`.
* @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or
* vertex for snapping. Default is `10` pixels.
* @property {ol.source.Vector|undefined} source Snap to features from this source. Either this option or features should be provided
*/
/** /**
* @typedef {Object} layer_BaseOptions * @typedef {Object} layer_BaseOptions
* @property {number|undefined} opacity Opacity (0, 1). Default is `1`. * @property {number|undefined} opacity Opacity (0, 1). Default is `1`.
@@ -1467,4 +1172,3 @@
* `WEBGL_MAX_TEXTURE_SIZE` or 2048 if WebGL is not supported. * `WEBGL_MAX_TEXTURE_SIZE` or 2048 if WebGL is not supported.
* @property {number|undefined} space The space in pixels between images (default: 1). * @property {number|undefined} space The space in pixels between images (default: 1).
*/ */

View File

@@ -7,6 +7,14 @@ import {TRUE, FALSE} from '../functions.js';
import {WEBKIT, MAC} from '../has.js'; import {WEBKIT, MAC} from '../has.js';
/**
* A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* `{boolean}`. If the condition is met, true should be returned.
*
* @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent): boolean} Condition
*/
/** /**
* Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when * Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when
* additionally the shift-key is pressed). * additionally the shift-key is pressed).

View File

@@ -5,13 +5,21 @@ import {inherits} from '../index.js';
import MapBrowserEventType from '../MapBrowserEventType.js'; import MapBrowserEventType from '../MapBrowserEventType.js';
import Interaction, {zoomByDelta} from '../interaction/Interaction.js'; import Interaction, {zoomByDelta} from '../interaction/Interaction.js';
/**
* @typedef {Object} Options
* @property {number} [duration] Animation duration in milliseconds. Default is `250`.
* @property {number} [delta] The zoom delta applied on each double click, default is `1`.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to zoom by double-clicking on the map. * Allows the user to zoom by double-clicking on the map.
* *
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @param {olx.interaction.DoubleClickZoomOptions=} opt_options Options. * @param {module:ol/interaction/DoubleClickZoom~Options=} opt_options Options.
* @api * @api
*/ */
const DoubleClickZoom = function(opt_options) { const DoubleClickZoom = function(opt_options) {
@@ -44,7 +52,7 @@ inherits(DoubleClickZoom, Interaction);
* doubleclick) and eventually zooms the map. * doubleclick) and eventually zooms the map.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.DoubleClickZoom} * @this {module:ol/interaction/DoubleClickZoom~DoubleClickZoom}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
let stopEvent = false; let stopEvent = false;

View File

@@ -12,13 +12,26 @@ import Interaction from '../interaction/Interaction.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
/**
* @typedef {Object} Options
* @property {Array.<function(new: ol.format.Feature)>|undefined} formatConstructors Format constructors.
* @property {ol.source.Vector|undefined} source Optional vector source where features will be added. If a source is provided
* all existing features will be removed and new features will be added when
* they are dropped on the target. If you want to add features to a vector
* source without removing the existing features (append only), instead of
* providing the source option listen for the "addfeatures" event.
* @property {ol.ProjectionLike} projection Target projection. By default, the map's view's projection is used.
* @property {Element|undefined} target The element that is used as the drop target, default is the viewport element.
*/
/** /**
* @enum {string} * @enum {string}
*/ */
const DragAndDropEventType = { const DragAndDropEventType = {
/** /**
* Triggered when features are added * Triggered when features are added
* @event ol.interaction.DragAndDropEvent#addfeatures * @event module:ol/interaction/DragAndDrop~DragAndDropEvent#addfeatures
* @api * @api
*/ */
ADD_FEATURES: 'addfeatures' ADD_FEATURES: 'addfeatures'
@@ -27,13 +40,13 @@ const DragAndDropEventType = {
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.DragAndDrop} instances are instances * Events emitted by {@link module:ol/interaction/DragAndDrop~DragAndDrop} instances are instances
* of this type. * of this type.
* *
* @constructor * @constructor
* @extends {ol.events.Event} * @extends {ol.events.Event}
* @implements {oli.interaction.DragAndDropEvent} * @implements {oli.interaction.DragAndDropEvent}
* @param {ol.interaction.DragAndDropEventType} type Type. * @param {module:ol/interaction/DragAndDrop~DragAndDropEventType} type Type.
* @param {File} file File. * @param {File} file File.
* @param {Array.<module:ol/Feature~Feature>=} opt_features Features. * @param {Array.<module:ol/Feature~Feature>=} opt_features Features.
* @param {module:ol/proj/Projection~Projection=} opt_projection Projection. * @param {module:ol/proj/Projection~Projection=} opt_projection Projection.
@@ -72,9 +85,9 @@ inherits(DragAndDropEvent, Event);
* Handles input of vector data by drag and drop. * Handles input of vector data by drag and drop.
* *
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @fires ol.interaction.DragAndDropEvent * @fires module:ol/interaction/DragAndDrop~DragAndDropEvent
* @param {olx.interaction.DragAndDropOptions=} opt_options Options. * @param {module:ol/interaction/DragAndDrop~Options=} opt_options Options.
* @api * @api
*/ */
const DragAndDrop = function(opt_options) { const DragAndDrop = function(opt_options) {
@@ -124,7 +137,7 @@ inherits(DragAndDrop, Interaction);
/** /**
* @param {Event} event Event. * @param {Event} event Event.
* @this {ol.interaction.DragAndDrop} * @this {module:ol/interaction/DragAndDrop~DragAndDrop}
*/ */
function handleDrop(event) { function handleDrop(event) {
const files = event.dataTransfer.files; const files = event.dataTransfer.files;

View File

@@ -10,27 +10,49 @@ import PointerInteraction from '../interaction/Pointer.js';
import RenderBox from '../render/Box.js'; import RenderBox from '../render/Box.js';
/**
* A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
* {@link module:ol~Pixel}s and returns a `{boolean}`. If the condition is met,
* true should be returned.
* @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean} EndCondition
*/
/**
* @typedef {Object} Options
* @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragbox`.
* @property {module:ol/events/condition~Condition|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link ol/events/condition~always}.
* @property {number|undefined} minArea The minimum area of the box in pixel, this value is used by the default
* `boxEndCondition` function. Default is `64`.
* @property {module:ol/interaction/DragBox~EndCondition|undefined} boxEndCondition A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
* {@link module:ol~Pixel}s to indicate whether a `boxend` event should be fired.
* Default is `true` if the area of the box is bigger than the `minArea` option.
*/
/** /**
* @enum {string} * @enum {string}
*/ */
const DragBoxEventType = { const DragBoxEventType = {
/** /**
* Triggered upon drag box start. * Triggered upon drag box start.
* @event ol.interaction.DragBoxEvent#boxstart * @event module:ol/interaction/DragBox~DragBoxEvent#boxstart
* @api * @api
*/ */
BOXSTART: 'boxstart', BOXSTART: 'boxstart',
/** /**
* Triggered on drag when box is active. * Triggered on drag when box is active.
* @event ol.interaction.DragBoxEvent#boxdrag * @event module:ol/interaction/DragBox~DragBoxEvent#boxdrag
* @api * @api
*/ */
BOXDRAG: 'boxdrag', BOXDRAG: 'boxdrag',
/** /**
* Triggered upon drag box end. * Triggered upon drag box end.
* @event ol.interaction.DragBoxEvent#boxend * @event module:ol/interaction/DragBox~DragBoxEvent#boxend
* @api * @api
*/ */
BOXEND: 'boxend' BOXEND: 'boxend'
@@ -39,13 +61,13 @@ const DragBoxEventType = {
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.DragBox} instances are instances of * Events emitted by {@link module:ol/interaction/DragBox~DragBox} instances are instances of
* this type. * this type.
* *
* @param {string} type The event type. * @param {string} type The event type.
* @param {module:ol/coordinate~Coordinate} coordinate The event coordinate. * @param {module:ol/coordinate~Coordinate} coordinate The event coordinate.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Originating event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Originating event.
* @extends {ol.events.Event} * @extends {module:ol/events/Event~Event}
* @constructor * @constructor
* @implements {oli.DragBoxEvent} * @implements {oli.DragBoxEvent}
*/ */
@@ -75,18 +97,18 @@ inherits(DragBoxEvent, Event);
/** /**
* @classdesc * @classdesc
* Allows the user to draw a vector box by clicking and dragging on the map, * Allows the user to draw a vector box by clicking and dragging on the map,
* normally combined with an {@link ol.events.condition} that limits * normally combined with an {@link module:ol/events/condition} that limits
* it to when the shift or other key is held down. This is used, for example, * it to when the shift or other key is held down. This is used, for example,
* for zooming to a specific area of the map * for zooming to a specific area of the map
* (see {@link ol.interaction.DragZoom} and * (see {@link module:ol/interaction/DragZoom~DragZoom} and
* {@link ol.interaction.DragRotateAndZoom}). * {@link module:ol/interaction/DragRotateAndZoom}).
* *
* This interaction is only supported for mouse devices. * This interaction is only supported for mouse devices.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @fires ol.interaction.DragBoxEvent * @fires module:ol/interaction/DragBox~DragBoxEvent
* @param {olx.interaction.DragBoxOptions=} opt_options Options. * @param {module:ol/interaction/DragBox~Options=} opt_options Options.
* @api * @api
*/ */
const DragBox = function(opt_options) { const DragBox = function(opt_options) {
@@ -100,7 +122,7 @@ const DragBox = function(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
/** /**
* @type {ol.render.Box} * @type {module:ol/render/Box~Box}
* @private * @private
*/ */
this.box_ = new RenderBox(options.className || 'ol-dragbox'); this.box_ = new RenderBox(options.className || 'ol-dragbox');
@@ -119,13 +141,13 @@ const DragBox = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : always; this.condition_ = options.condition ? options.condition : always;
/** /**
* @private * @private
* @type {ol.DragBoxEndConditionType} * @type {module:ol/interaction/DragBox~EndCondition}
*/ */
this.boxEndCondition_ = options.boxEndCondition ? this.boxEndCondition_ = options.boxEndCondition ?
options.boxEndCondition : defaultBoxEndCondition; options.boxEndCondition : defaultBoxEndCondition;
@@ -142,7 +164,7 @@ inherits(DragBox, PointerInteraction);
* @param {module:ol~Pixel} startPixel The starting pixel of the box. * @param {module:ol~Pixel} startPixel The starting pixel of the box.
* @param {module:ol~Pixel} endPixel The end pixel of the box. * @param {module:ol~Pixel} endPixel The end pixel of the box.
* @return {boolean} Whether or not the boxend condition should be fired. * @return {boolean} Whether or not the boxend condition should be fired.
* @this {ol.interaction.DragBox} * @this {module:ol/interaction/DragBox~DragBox}
*/ */
function defaultBoxEndCondition(mapBrowserEvent, startPixel, endPixel) { function defaultBoxEndCondition(mapBrowserEvent, startPixel, endPixel) {
const width = endPixel[0] - startPixel[0]; const width = endPixel[0] - startPixel[0];
@@ -152,8 +174,8 @@ function defaultBoxEndCondition(mapBrowserEvent, startPixel, endPixel) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.DragBox} * @this {module:ol/interaction/DragBox~DragBox}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
@@ -187,9 +209,9 @@ DragBox.prototype.onBoxEnd = UNDEFINED;
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.DragBox} * @this {module:ol/interaction/DragBox~DragBox}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
@@ -209,9 +231,9 @@ function handleUpEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.DragBox} * @this {module:ol/interaction/DragBox~DragBox}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {

View File

@@ -9,13 +9,23 @@ import {noModifierKeys} from '../events/condition.js';
import {FALSE} from '../functions.js'; import {FALSE} from '../functions.js';
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js'; import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [condition] A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link module:ol/events/condition~noModifierKeys}.
* @property {module:ol/Kinetic~Kinetic} [kinetic] Kinetic inertia to apply to the pan.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to pan the map by dragging the map. * Allows the user to pan the map by dragging the map.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.DragPanOptions=} opt_options Options. * @param {module:ol/interaction/DragPan~Options=} opt_options Options.
* @api * @api
*/ */
const DragPan = function(opt_options) { const DragPan = function(opt_options) {
@@ -30,7 +40,7 @@ const DragPan = function(opt_options) {
/** /**
* @private * @private
* @type {ol.Kinetic|undefined} * @type {module:ol/Kinetic~Kinetic|undefined}
*/ */
this.kinetic_ = options.kinetic; this.kinetic_ = options.kinetic;
@@ -46,7 +56,7 @@ const DragPan = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : noModifierKeys; this.condition_ = options.condition ? options.condition : noModifierKeys;
@@ -62,8 +72,8 @@ inherits(DragPan, PointerInteraction);
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.DragPan} * @this {module:ol/interaction/DragPan~DragPan}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
const targetPointers = this.targetPointers; const targetPointers = this.targetPointers;
@@ -95,9 +105,9 @@ function handleDragEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.DragPan} * @this {module:ol/interaction/DragPan~DragPan}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
const map = mapBrowserEvent.map; const map = mapBrowserEvent.map;
@@ -133,9 +143,9 @@ function handleUpEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.DragPan} * @this {module:ol/interaction/DragPan~DragPan}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) { if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {

View File

@@ -9,17 +9,28 @@ import {FALSE} from '../functions.js';
import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js'; import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction from '../interaction/Pointer.js';
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [condition] A function that takes an
* {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link module:ol/events/condition~altShiftKeysOnly}.
* @property {number} [duration=250] Animation duration in milliseconds.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to rotate the map by clicking and dragging on the map, * Allows the user to rotate the map by clicking and dragging on the map,
* normally combined with an {@link ol.events.condition} that limits * normally combined with an {@link module:ol/events/condition} that limits
* it to when the alt and shift keys are held down. * it to when the alt and shift keys are held down.
* *
* This interaction is only supported for mouse devices. * This interaction is only supported for mouse devices.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.DragRotateOptions=} opt_options Options. * @param {module:ol/interaction/DragRotate~Options=} opt_options Options.
* @api * @api
*/ */
const DragRotate = function(opt_options) { const DragRotate = function(opt_options) {
@@ -34,7 +45,7 @@ const DragRotate = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : altShiftKeysOnly; this.condition_ = options.condition ? options.condition : altShiftKeysOnly;
@@ -55,8 +66,8 @@ inherits(DragRotate, PointerInteraction);
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.DragRotate} * @this {module:ol/interaction/DragRotate~DragRotate}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
@@ -82,9 +93,9 @@ function handleDragEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.DragRotate} * @this {module:ol/interaction/DragRotate~DragRotate}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
@@ -101,9 +112,9 @@ function handleUpEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.DragRotate} * @this {module:ol/interaction/DragRotate~DragRotate}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {

View File

@@ -8,6 +8,17 @@ import {shiftKeyOnly, mouseOnly} from '../events/condition.js';
import {rotate, rotateWithoutConstraints, zoom, zoomWithoutConstraints} from '../interaction/Interaction.js'; import {rotate, rotateWithoutConstraints, zoom, zoomWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction from '../interaction/Pointer.js';
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled.
* Default is {@link module:ol/events/condition~shiftKeyOnly}.
* @property {number} [duration=400] Animation duration in milliseconds.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to zoom and rotate the map by clicking and dragging * Allows the user to zoom and rotate the map by clicking and dragging
@@ -19,8 +30,8 @@ import PointerInteraction from '../interaction/Pointer.js';
* And this interaction is not included in the default interactions. * And this interaction is not included in the default interactions.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.DragRotateAndZoomOptions=} opt_options Options. * @param {module:ol/interaction/DragRotateAndZoom~Options=} opt_options Options.
* @api * @api
*/ */
const DragRotateAndZoom = function(opt_options) { const DragRotateAndZoom = function(opt_options) {
@@ -35,7 +46,7 @@ const DragRotateAndZoom = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : shiftKeyOnly; this.condition_ = options.condition ? options.condition : shiftKeyOnly;
@@ -69,8 +80,8 @@ inherits(DragRotateAndZoom, PointerInteraction);
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.DragRotateAndZoom} * @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
@@ -102,9 +113,9 @@ function handleDragEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.DragRotateAndZoom} * @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
@@ -123,9 +134,9 @@ function handleUpEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.DragRotateAndZoom} * @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
if (!mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {

View File

@@ -7,18 +7,32 @@ import {shiftKeyOnly} from '../events/condition.js';
import {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.js'; import {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.js';
import DragBox from '../interaction/DragBox.js'; import DragBox from '../interaction/DragBox.js';
/**
* @typedef {Object} Options
* @property {string} [className='ol-dragzoom'] CSS class name for styling the
* box.
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled.
* Default is {@link module:ol/events/condition~shiftKeyOnly}.
* @property {number} [duration=200] Animation duration in milliseconds.
* @property {boolean} [out=false] Use interaction for zooming out.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to zoom the map by clicking and dragging on the map, * Allows the user to zoom the map by clicking and dragging on the map,
* normally combined with an {@link ol.events.condition} that limits * normally combined with an {@link module:ol/events/condition} that limits
* it to when a key, shift by default, is held down. * it to when a key, shift by default, is held down.
* *
* To change the style of the box, use CSS and the `.ol-dragzoom` selector, or * To change the style of the box, use CSS and the `.ol-dragzoom` selector, or
* your custom one configured with `className`. * your custom one configured with `className`.
* *
* @constructor * @constructor
* @extends {ol.interaction.DragBox} * @extends {module:ol/interaction/DragBox~DragBox}
* @param {olx.interaction.DragZoomOptions=} opt_options Options. * @param {module:ol/interaction/DragZoom~Options=} opt_options Options.
* @api * @api
*/ */
const DragZoom = function(opt_options) { const DragZoom = function(opt_options) {
@@ -54,7 +68,7 @@ inherits(DragZoom, DragBox);
DragZoom.prototype.onBoxEnd = function() { DragZoom.prototype.onBoxEnd = function() {
const map = this.getMap(); const map = this.getMap();
const view = /** @type {!ol.View} */ (map.getView()); const view = /** @type {!module:ol/View~View} */ (map.getView());
const size = /** @type {!module:ol/size~Size} */ (map.getSize()); const size = /** @type {!module:ol/size~Size} */ (map.getSize());

View File

@@ -29,6 +29,69 @@ import VectorSource from '../source/Vector.js';
import {createEditingStyle} from '../style/Style.js'; import {createEditingStyle} from '../style/Style.js';
/**
* @typedef {Object} Options
* @property {module:ol/geom/GeometryType~GeometryType} type Geometry type of
* the geometries being drawn with this instance.
* @property {number} [clickTolerance=6] The maximum distance in pixels between
* "down" and "up" for a "up" event to be considered a "click" event and
* actually add a point/vertex to the geometry being drawn. The default of `6`
* was chosen for the draw interaction to behave correctly on mouse as well as
* on touch devices.
* @property {module:ol/Collection~Collection.<module:ol/Feature~Feature>} [features]
* Destination collection for the drawn features.
* @property {module:ol/source/Vector~Vector} [source] Destination source for
* the drawn features.
* @property {number} [dragVertexDelay=500] Delay in milliseconds after pointerdown
* before the current vertex can be dragged to its exact position.
* @property {number} [snapTolerance=12] Pixel distance for snapping to the
* drawing finish.
* @property {boolean} [stopClick=false] Stop click, singleclick, and
* doubleclick events from firing during drawing.
* @property {number} [maxPoints] The number of points that can be drawn before
* a polygon ring or line string is finished. By default there is no
* restriction.
* @property {number} [minPoints] The number of points that must be drawn
* before a polygon ring or line string can be finished. Default is `3` for
* polygon rings and `2` for line strings.
* @property {module:ol/events/condition~Condition} [finishCondition] A function
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether the drawing can be finished.
* @property {module:ol/style/Style~Style|Array.<module:ol/style/Style~Style>|module:ol/style~StyleFunction} [style]
* Style for sketch features.
* @property {module:ol/interaction/Draw~GeometryFunction} [geometryFunction]
* Function that is called when a geometry's coordinates are updated.
* @property {string} [geometryName] Geometry name to use for features created
* by the draw interaction.
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled.
* By default {@link module:ol/events/condition~noModifierKeys}, i.e. a click,
* adds a vertex or deactivates freehand drawing.
* @property {boolean} [freehand=false] Operate in freehand mode for lines,
* polygons, and circles. This makes the interaction always operate in freehand
* mode and takes precedence over any `freehandCondition` option.
* @property {module:ol/events/condition~Condition} [freehandCondition]
* Condition that activates freehand drawing for lines and polygons. This
* function takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and
* returns a boolean to indicate whether that event should be handled. The
* default is {@link module:ol/events/condition~shiftKeyOnly}, meaning that the
* Shift key activates freehand drawing.
* @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch
* overlay.
*/
/**
* Function that takes an array of coordinates and an optional existing geometry as
* arguments, and returns a geometry. The optional existing geometry is the
* geometry that is returned when the function is called without a second
* argument.
* @typedef {function(!Array.<module:ol/coordinate~Coordinate>, module:ol/geom/SimpleGeometry~SimpleGeometry=):
* module:ol/geom/SimpleGeometry~SimpleGeometry} GeometryFunction
*/
/** /**
* Draw mode. This collapses multi-part geometry types with their single-part * Draw mode. This collapses multi-part geometry types with their single-part
* cousins. * cousins.
@@ -48,13 +111,13 @@ const Mode = {
const DrawEventType = { const DrawEventType = {
/** /**
* Triggered upon feature draw start * Triggered upon feature draw start
* @event ol.interaction.Draw.Event#drawstart * @event module:ol/interaction/Draw~DrawEvent#drawstart
* @api * @api
*/ */
DRAWSTART: 'drawstart', DRAWSTART: 'drawstart',
/** /**
* Triggered upon feature draw end * Triggered upon feature draw end
* @event ol.interaction.Draw.Event#drawend * @event module:ol/interaction/Draw~DrawEvent#drawend
* @api * @api
*/ */
DRAWEND: 'drawend' DRAWEND: 'drawend'
@@ -63,13 +126,13 @@ const DrawEventType = {
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.Draw} instances are instances of * Events emitted by {@link module:ol/interaction/Draw~Draw} instances are
* this type. * instances of this type.
* *
* @constructor * @constructor
* @extends {ol.events.Event} * @extends {module:ol/events/Event~Event}
* @implements {oli.DrawEvent} * @implements {oli.DrawEvent}
* @param {ol.interaction.DrawEventType} type Type. * @param {module:ol/interaction/Draw~DrawEventType} type Type.
* @param {module:ol/Feature~Feature} feature The feature drawn. * @param {module:ol/Feature~Feature} feature The feature drawn.
*/ */
const DrawEvent = function(type, feature) { const DrawEvent = function(type, feature) {
@@ -93,9 +156,9 @@ inherits(DrawEvent, Event);
* Interaction for drawing feature geometries. * Interaction for drawing feature geometries.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @fires ol.interaction.DrawEvent * @fires module:ol/interaction/Draw~DrawEvent
* @param {olx.interaction.DrawOptions} options Options. * @param {module:ol/interaction/Draw~Options} options Options.
* @api * @api
*/ */
const Draw = function(options) { const Draw = function(options) {
@@ -138,14 +201,14 @@ const Draw = function(options) {
/** /**
* Target source for drawn features. * Target source for drawn features.
* @type {ol.source.Vector} * @type {module:ol/source/Vector~Vector}
* @private * @private
*/ */
this.source_ = options.source ? options.source : null; this.source_ = options.source ? options.source : null;
/** /**
* Target collection for drawn features. * Target collection for drawn features.
* @type {ol.Collection.<module:ol/Feature~Feature>} * @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
* @private * @private
*/ */
this.features_ = options.features ? options.features : null; this.features_ = options.features ? options.features : null;
@@ -166,7 +229,7 @@ const Draw = function(options) {
/** /**
* Drawing mode (derived from geometry type. * Drawing mode (derived from geometry type.
* @type {ol.interaction.Mode} * @type {module:ol/interaction/Draw~Mode}
* @private * @private
*/ */
this.mode_ = getMode(this.type_); this.mode_ = getMode(this.type_);
@@ -201,7 +264,7 @@ const Draw = function(options) {
/** /**
* A function to decide if a potential finish coordinate is permissible * A function to decide if a potential finish coordinate is permissible
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.finishCondition_ = options.finishCondition ? options.finishCondition : TRUE; this.finishCondition_ = options.finishCondition ? options.finishCondition : TRUE;
@@ -260,7 +323,7 @@ const Draw = function(options) {
} }
/** /**
* @type {ol.DrawGeometryFunctionType} * @type {module:ol/interaction/Draw~GeometryFunction}
* @private * @private
*/ */
this.geometryFunction_ = geometryFunction; this.geometryFunction_ = geometryFunction;
@@ -326,7 +389,7 @@ const Draw = function(options) {
/** /**
* Draw overlay where our sketch features are drawn. * Draw overlay where our sketch features are drawn.
* @type {ol.layer.Vector} * @type {module:ol/layer/Vector~Vector}
* @private * @private
*/ */
this.overlay_ = new VectorLayer({ this.overlay_ = new VectorLayer({
@@ -348,13 +411,13 @@ const Draw = function(options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : noModifierKeys; this.condition_ = options.condition ? options.condition : noModifierKeys;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.freehandCondition_; this.freehandCondition_;
if (options.freehand) { if (options.freehand) {
@@ -398,7 +461,7 @@ Draw.prototype.setMap = function(map) {
* draw or finish the drawing. * draw or finish the drawing.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Draw} * @this {module:ol/interaction/Draw~Draw}
* @api * @api
*/ */
export function handleEvent(event) { export function handleEvent(event) {
@@ -448,9 +511,9 @@ export function handleEvent(event) {
/** /**
* @param {ol.MapBrowserPointerEvent} event Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.Draw} * @this {module:ol/interaction/Draw~Draw}
*/ */
function handleDownEvent(event) { function handleDownEvent(event) {
this.shouldHandle_ = !this.freehand_; this.shouldHandle_ = !this.freehand_;
@@ -476,9 +539,9 @@ function handleDownEvent(event) {
/** /**
* @param {ol.MapBrowserPointerEvent} event Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.Draw} * @this {module:ol/interaction/Draw~Draw}
*/ */
function handleUpEvent(event) { function handleUpEvent(event) {
let pass = true; let pass = true;
@@ -764,8 +827,8 @@ Draw.prototype.removeLastPoint = function() {
/** /**
* Stop drawing and add the sketch feature to the target layer. * Stop drawing and add the sketch feature to the target layer.
* The {@link ol.interaction.DrawEventType.DRAWEND} event is dispatched before * The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is
* inserting the feature. * dispatched before inserting the feature.
* @api * @api
*/ */
Draw.prototype.finishDrawing = function() { Draw.prototype.finishDrawing = function() {
@@ -895,7 +958,7 @@ Draw.prototype.updateState_ = function() {
* @param {number=} opt_angle Angle of the first point in radians. 0 means East. * @param {number=} opt_angle Angle of the first point in radians. 0 means East.
* Default is the angle defined by the heading from the center of the * Default is the angle defined by the heading from the center of the
* regular polygon to the current pointer position. * regular polygon to the current pointer position.
* @return {ol.DrawGeometryFunctionType} Function that draws a * @return {module:ol/interaction/Draw~GeometryFunction} Function that draws a
* polygon. * polygon.
* @api * @api
*/ */
@@ -921,7 +984,7 @@ export function createRegularPolygon(opt_sides, opt_angle) {
* Create a `geometryFunction` that will create a box-shaped polygon (aligned * Create a `geometryFunction` that will create a box-shaped polygon (aligned
* with the coordinate system axes). Use this with the draw interaction and * with the coordinate system axes). Use this with the draw interaction and
* `type: 'Circle'` to return a box instead of a circle geometry. * `type: 'Circle'` to return a box instead of a circle geometry.
* @return {ol.DrawGeometryFunctionType} Function that draws a box-shaped polygon. * @return {module:ol/interaction/Draw~GeometryFunction} Function that draws a box-shaped polygon.
* @api * @api
*/ */
export function createBox() { export function createBox() {
@@ -946,7 +1009,7 @@ export function createBox() {
* Get the drawing mode. The mode for mult-part geometries is the same as for * Get the drawing mode. The mode for mult-part geometries is the same as for
* their single-part cousins. * their single-part cousins.
* @param {module:ol/geom/GeometryType~GeometryType} type Geometry type. * @param {module:ol/geom/GeometryType~GeometryType} type Geometry type.
* @return {ol.interaction.Mode} Drawing mode. * @return {module:ol/interaction/Draw~Mode} Drawing mode.
*/ */
function getMode(type) { function getMode(type) {
let mode; let mode;
@@ -962,7 +1025,7 @@ function getMode(type) {
} else if (type === GeometryType.CIRCLE) { } else if (type === GeometryType.CIRCLE) {
mode = Mode.CIRCLE; mode = Mode.CIRCLE;
} }
return /** @type {!ol.interaction.Mode} */ (mode); return /** @type {!module:ol/interaction/Draw~Mode} */ (mode);
} }

View File

@@ -11,22 +11,51 @@ import {boundingExtent, getArea} from '../extent.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import {fromExtent as polygonFromExtent} from '../geom/Polygon.js'; import {fromExtent as polygonFromExtent} from '../geom/Polygon.js';
import ExtentEventType from '../interaction/ExtentEventType.js';
import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js'; import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import VectorLayer from '../layer/Vector.js'; import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js'; import VectorSource from '../source/Vector.js';
import {createEditingStyle} from '../style/Style.js'; import {createEditingStyle} from '../style/Style.js';
/**
* @typedef {Object} Options
* @property {module:ol/extent~Extent} [extent] Initial extent. Defaults to no
* initial extent.
* @property {module:ol/style/Style~Style|Array.<module:ol/style/Style~Style>|module:ol/style~StyleFunction} [boxStyle]
* Style for the drawn extent box. Defaults to
* {@link module:ol/style/Style~createEditing()[module:ol/geom/GeometryType~GeometryType.POLYGON]}
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the
* pointer close enough to a segment or vertex for editing.
* @property {module:ol/style/Style~Style|Array.<module:ol/style/Style~Style>|module:ol/style~StyleFunction} [pointerStyle]
* Style for the cursor used to draw the extent. Defaults to
* {@link module:ol/style/Style~createEditing()[module:ol/geom/GeometryType~GeometryType.POINT]}
* @property {boolean} [wrapX=false] Wrap the drawn extent across multiple maps
* in the X direction? Only affects visuals, not functionality.
*/
/**
* @enum {string}
*/
const ExtentEventType = {
/**
* Triggered after the extent is changed
* @event module:ol/interaction/Extent~ExtentEventType#extentchanged
* @api
*/
EXTENTCHANGED: 'extentchanged'
};
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.Extent} instances are instances of * Events emitted by {@link module:ol/interaction/Extent~Extent} instances are
* this type. * instances of this type.
* *
* @constructor * @constructor
* @implements {oli.ExtentEvent} * @implements {oli.ExtentEvent}
* @param {module:ol/extent~Extent} extent the new extent * @param {module:ol/extent~Extent} extent the new extent
* @extends {ol.events.Event} * @extends {module:ol/events/Event~Event}
*/ */
const ExtentInteractionEvent = function(extent) { const ExtentInteractionEvent = function(extent) {
Event.call(this, ExtentEventType.EXTENTCHANGED); Event.call(this, ExtentEventType.EXTENTCHANGED);
@@ -49,9 +78,9 @@ inherits(ExtentInteractionEvent, Event);
* This interaction is only supported for mouse devices. * This interaction is only supported for mouse devices.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @fires ol.interaction.Extent.Event * @fires module:ol/interaction/Extent~Event
* @param {olx.interaction.ExtentOptions=} opt_options Options. * @param {module:ol/interaction/Extent~Options=} opt_options Options.
* @api * @api
*/ */
const ExtentInteraction = function(opt_options) { const ExtentInteraction = function(opt_options) {
@@ -105,7 +134,6 @@ const ExtentInteraction = function(opt_options) {
opt_options = {}; opt_options = {};
} }
/* Inherit ol.interaction.Pointer */
PointerInteraction.call(this, { PointerInteraction.call(this, {
handleDownEvent: handleDownEvent, handleDownEvent: handleDownEvent,
handleDragEvent: handleDragEvent, handleDragEvent: handleDragEvent,
@@ -115,7 +143,7 @@ const ExtentInteraction = function(opt_options) {
/** /**
* Layer for the extentFeature * Layer for the extentFeature
* @type {ol.layer.Vector} * @type {module:ol/layer/Vector~Vector}
* @private * @private
*/ */
this.extentOverlay_ = new VectorLayer({ this.extentOverlay_ = new VectorLayer({
@@ -130,7 +158,7 @@ const ExtentInteraction = function(opt_options) {
/** /**
* Layer for the vertexFeature * Layer for the vertexFeature
* @type {ol.layer.Vector} * @type {module:ol/layer/Vector~Vector}
* @private * @private
*/ */
this.vertexOverlay_ = new VectorLayer({ this.vertexOverlay_ = new VectorLayer({
@@ -153,7 +181,7 @@ inherits(ExtentInteraction, PointerInteraction);
/** /**
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Event.
* @return {boolean} Propagate event? * @return {boolean} Propagate event?
* @this {ol.interaction.Extent} * @this {module:ol/interaction/Extent~Extent}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) { if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
@@ -170,9 +198,9 @@ function handleEvent(mapBrowserEvent) {
} }
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Event handled? * @return {boolean} Event handled?
* @this {ol.interaction.Extent} * @this {module:ol/interaction/Extent~Extent}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
const pixel = mapBrowserEvent.pixel; const pixel = mapBrowserEvent.pixel;
@@ -229,9 +257,9 @@ function handleDownEvent(mapBrowserEvent) {
} }
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Event handled? * @return {boolean} Event handled?
* @this {ol.interaction.Extent} * @this {module:ol/interaction/Extent~Extent}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
if (this.pointerHandler_) { if (this.pointerHandler_) {
@@ -243,9 +271,9 @@ function handleDragEvent(mapBrowserEvent) {
} }
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.Extent} * @this {module:ol/interaction/Extent~Extent}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
this.pointerHandler_ = null; this.pointerHandler_ = null;
@@ -325,7 +353,7 @@ function getSegments(extent) {
/** /**
* @param {module:ol~Pixel} pixel cursor location * @param {module:ol~Pixel} pixel cursor location
* @param {ol.PluggableMap} map map * @param {module:ol/PluggableMap~PluggableMap} map map
* @returns {module:ol/coordinate~Coordinate|null} snapped vertex on extent * @returns {module:ol/coordinate~Coordinate|null} snapped vertex on extent
* @private * @private
*/ */

View File

@@ -1,15 +0,0 @@
/**
* @module ol/interaction/ExtentEventType
*/
/**
* @enum {string}
*/
export default {
/**
* Triggered after the extent is changed
* @event ol.interaction.Extent.Event#extentchanged
* @api
*/
EXTENTCHANGED: 'extentchanged'
};

View File

@@ -8,6 +8,20 @@ import KeyCode from '../events/KeyCode.js';
import {noModifierKeys, targetNotEditable} from '../events/condition.js'; import {noModifierKeys, targetNotEditable} from '../events/condition.js';
import Interaction, {pan} from '../interaction/Interaction.js'; import Interaction, {pan} from '../interaction/Interaction.js';
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled. Default is
* {@link module:ol/events/condition~noModifierKeys} and
* {@link module:ol/events/condition~targetNotEditable}.
* @property {number} [duration=100] Animation duration in milliseconds.
* @property {number} [pixelDelta=128] The amount of pixels to pan on each key
* press.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to pan the map using keyboard arrows. * Allows the user to pan the map using keyboard arrows.
@@ -15,14 +29,14 @@ import Interaction, {pan} from '../interaction/Interaction.js';
* the keys can only be used when browser focus is on the element to which * the keys can only be used when browser focus is on the element to which
* the keyboard events are attached. By default, this is the map div, * the keyboard events are attached. By default, this is the map div,
* though you can change this with the `keyboardEventTarget` in * though you can change this with the `keyboardEventTarget` in
* {@link ol.Map}. `document` never loses focus but, for any other element, * {@link module:ol/Map~Map}. `document` never loses focus but, for any other
* focus will have to be on, and returned to, this element if the keys are to * element, focus will have to be on, and returned to, this element if the keys
* function. * are to function.
* See also {@link ol.interaction.KeyboardZoom}. * See also {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}.
* *
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @param {olx.interaction.KeyboardPanOptions=} opt_options Options. * @param {module:ol/interaction/KeyboardPan~Options=} opt_options Options.
* @api * @api
*/ */
const KeyboardPan = function(opt_options) { const KeyboardPan = function(opt_options) {
@@ -45,7 +59,7 @@ const KeyboardPan = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition !== undefined ? this.condition_ = options.condition !== undefined ?
options.condition : this.defaultCondition_; options.condition : this.defaultCondition_;
@@ -73,7 +87,7 @@ inherits(KeyboardPan, Interaction);
* pressed). * pressed).
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardPan} * @this {module:ol/interaction/KeyboardPan~KeyboardPan}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
let stopEvent = false; let stopEvent = false;

View File

@@ -6,6 +6,18 @@ import EventType from '../events/EventType.js';
import {targetNotEditable} from '../events/condition.js'; import {targetNotEditable} from '../events/condition.js';
import Interaction, {zoomByDelta} from '../interaction/Interaction.js'; import Interaction, {zoomByDelta} from '../interaction/Interaction.js';
/**
* @typedef {Object} Options
* @property {number} [duration=100] Animation duration in milliseconds.
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled. Default is
* {@link module:ol/events/condition~targetNotEditable}.
* @property {number} [delta=1] The zoom level delta on each key press.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to zoom the map using keyboard + and -. * Allows the user to zoom the map using keyboard + and -.
@@ -13,14 +25,14 @@ import Interaction, {zoomByDelta} from '../interaction/Interaction.js';
* the keys can only be used when browser focus is on the element to which * the keys can only be used when browser focus is on the element to which
* the keyboard events are attached. By default, this is the map div, * the keyboard events are attached. By default, this is the map div,
* though you can change this with the `keyboardEventTarget` in * though you can change this with the `keyboardEventTarget` in
* {@link ol.Map}. `document` never loses focus but, for any other element, * {@link module:ol/Map~Map}. `document` never loses focus but, for any other
* focus will have to be on, and returned to, this element if the keys are to * element, focus will have to be on, and returned to, this element if the keys
* function. * are to function.
* See also {@link ol.interaction.KeyboardPan}. * See also {@link moudle:ol/interaction/KeyboardPan~KeyboardPan}.
* *
* @constructor * @constructor
* @param {olx.interaction.KeyboardZoomOptions=} opt_options Options. * @param {module:ol/interaction/KeyboardZoom~Options=} opt_options Options.
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @api * @api
*/ */
const KeyboardZoom = function(opt_options) { const KeyboardZoom = function(opt_options) {
@@ -33,7 +45,7 @@ const KeyboardZoom = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : targetNotEditable; this.condition_ = options.condition ? options.condition : targetNotEditable;
@@ -60,7 +72,7 @@ inherits(KeyboardZoom, Interaction);
* key pressed was '+' or '-'). * key pressed was '+' or '-').
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardZoom} * @this {module:ol/interaction/KeyboardZoom~KeyboardZoom}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
let stopEvent = false; let stopEvent = false;

View File

@@ -43,18 +43,62 @@ const ModifyEventType = {
}; };
/**
* @typedef {Object} SegmentData
* @property {Array.<number>} [depth]
* @property {module:ol/Feature~Feature} feature
* @property {module:ol/geom/SimpleGeometry~SimpleGeometry} geometry
* @property {number} index
* @property {Array.<module:ol/extent~Extent>} segment
* @property {Array.<module:ol/interaction/Modify~SegmentData>} [featureSegments]
*/
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event will be considered to add or move a
* vertex to the sketch. Default is
* {@link module:ol/events/condition~primaryAction}.
* @property {module:ol/events/condition~Condition} [deleteCondition] A function
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled. By default,
* {@link module:ol/events/condition~singleClick} with
* {@link module:ol/events/condition~altKeyOnly} results in a vertex deletion.
* @property {module:ol/events/condition~Condition} [insertVertexCondition] A
* function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and
* returns a boolean to indicate whether a new vertex can be added to the sketch
* features. Default is {@link module:ol/events/condition~always}.
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the
* pointer close enough to a segment or vertex for editing.
* @property {module:ol/style/Style~Style|Array.<module:ol/style/Style~Style>|module:ol/style~StyleFunction} [style]
* Style used for the features being modified. By default the default edit
* style is used (see {@link module:ol/style}).
* @property {module:ol/source/Vector~Vector} [source] The vector source with
* features to modify. If a vector source is not provided, a feature collection
* must be provided with the features option.
* @property {module:ol/Collection~Collection.<module:ol/Feature~Feature>} [features]
* The features the interaction works on. If a feature collection is not
* provided, a vector source must be provided with the source option.
* @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch
* overlay.
*/
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.Modify} instances are instances of * Events emitted by {@link module:ol/interaction/Modify~Modify} instances are
* this type. * instances of this type.
* *
* @constructor * @constructor
* @extends {ol.events.Event} * @extends {module:ol/events/Event~Event}
* @implements {oli.ModifyEvent} * @implements {oli.ModifyEvent}
* @param {ModifyEventType} type Type. * @param {ModifyEventType} type Type.
* @param {ol.Collection.<module:ol/Feature~Feature>} features The features modified. * @param {module:ol/Collection~Collection.<module:ol/Feature~Feature>} features
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated * The features modified.
* {@link ol.MapBrowserPointerEvent}. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserPointerEvent
* Associated {@link module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent}.
*/ */
export const ModifyEvent = function(type, features, mapBrowserPointerEvent) { export const ModifyEvent = function(type, features, mapBrowserPointerEvent) {
@@ -62,7 +106,7 @@ export const ModifyEvent = function(type, features, mapBrowserPointerEvent) {
/** /**
* The features being modified. * The features being modified.
* @type {ol.Collection.<module:ol/Feature~Feature>} * @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
* @api * @api
*/ */
this.features = features; this.features = features;
@@ -92,9 +136,9 @@ inherits(ModifyEvent, Event);
* for deletion, use the `deleteCondition` option. * for deletion, use the `deleteCondition` option.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.ModifyOptions} options Options. * @param {module:ol/interaction/Modify~Options} options Options.
* @fires ol.interaction.ModifyEvent * @fires module:ol/interaction/Modify~ModifyEvent
* @api * @api
*/ */
const Modify = function(options) { const Modify = function(options) {
@@ -108,7 +152,7 @@ const Modify = function(options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : primaryAction; this.condition_ = options.condition ? options.condition : primaryAction;
@@ -123,14 +167,14 @@ const Modify = function(options) {
}; };
/** /**
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
* @private * @private
*/ */
this.deleteCondition_ = options.deleteCondition ? this.deleteCondition_ = options.deleteCondition ?
options.deleteCondition : this.defaultDeleteCondition_; options.deleteCondition : this.defaultDeleteCondition_;
/** /**
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
* @private * @private
*/ */
this.insertVertexCondition_ = options.insertVertexCondition ? this.insertVertexCondition_ = options.insertVertexCondition ?
@@ -172,7 +216,7 @@ const Modify = function(options) {
/** /**
* Segment RTree for each layer * Segment RTree for each layer
* @type {ol.structs.RBush.<ol.ModifySegmentDataType>} * @type {module:ol/structs/RBush~RBush.<module:ol/interaction/Modify~SegmentData>}
* @private * @private
*/ */
this.rBush_ = new RBush(); this.rBush_ = new RBush();
@@ -206,7 +250,7 @@ const Modify = function(options) {
/** /**
* Draw overlay where sketch features are drawn. * Draw overlay where sketch features are drawn.
* @type {ol.layer.Vector} * @type {module:ol/layer/Vector~Vector}
* @private * @private
*/ */
this.overlay_ = new VectorLayer({ this.overlay_ = new VectorLayer({
@@ -239,7 +283,7 @@ const Modify = function(options) {
/** /**
* @type {ol.source.Vector} * @type {module:ol/source/Vector~Vector}
* @private * @private
*/ */
this.source_ = null; this.source_ = null;
@@ -260,7 +304,7 @@ const Modify = function(options) {
} }
/** /**
* @type {ol.Collection.<module:ol/Feature~Feature>} * @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
* @private * @private
*/ */
this.features_ = features; this.features_ = features;
@@ -272,7 +316,7 @@ const Modify = function(options) {
this.handleFeatureRemove_, this); this.handleFeatureRemove_, this);
/** /**
* @type {ol.MapBrowserPointerEvent} * @type {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent}
* @private * @private
*/ */
this.lastPointerEvent_ = null; this.lastPointerEvent_ = null;
@@ -316,7 +360,7 @@ Modify.prototype.addFeature_ = function(feature) {
/** /**
* @param {ol.MapBrowserPointerEvent} evt Map browser event * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Map browser event
* @private * @private
*/ */
Modify.prototype.willModifyFeatures_ = function(evt) { Modify.prototype.willModifyFeatures_ = function(evt) {
@@ -351,10 +395,10 @@ Modify.prototype.removeFeature_ = function(feature) {
*/ */
Modify.prototype.removeFeatureSegmentData_ = function(feature) { Modify.prototype.removeFeatureSegmentData_ = function(feature) {
const rBush = this.rBush_; const rBush = this.rBush_;
const /** @type {Array.<ol.ModifySegmentDataType>} */ nodesToRemove = []; const /** @type {Array.<module:ol/interaction/Modify~SegmentData>} */ nodesToRemove = [];
rBush.forEach( rBush.forEach(
/** /**
* @param {ol.ModifySegmentDataType} node RTree node. * @param {module:ol/interaction/Modify~SegmentData} node RTree node.
*/ */
function(node) { function(node) {
if (feature === node.feature) { if (feature === node.feature) {
@@ -389,7 +433,7 @@ Modify.prototype.setMap = function(map) {
/** /**
* @param {ol.source.Vector.Event} event Event. * @param {module:ol/source/Vector~VectorSourceEvent} event Event.
* @private * @private
*/ */
Modify.prototype.handleSourceAdd_ = function(event) { Modify.prototype.handleSourceAdd_ = function(event) {
@@ -400,7 +444,7 @@ Modify.prototype.handleSourceAdd_ = function(event) {
/** /**
* @param {ol.source.Vector.Event} event Event. * @param {module:ol/source/Vector~VectorSourceEvent} event Event.
* @private * @private
*/ */
Modify.prototype.handleSourceRemove_ = function(event) { Modify.prototype.handleSourceRemove_ = function(event) {
@@ -411,7 +455,7 @@ Modify.prototype.handleSourceRemove_ = function(event) {
/** /**
* @param {ol.CollectionEvent} evt Event. * @param {module:ol/Collection~CollectionEvent} evt Event.
* @private * @private
*/ */
Modify.prototype.handleFeatureAdd_ = function(evt) { Modify.prototype.handleFeatureAdd_ = function(evt) {
@@ -420,7 +464,7 @@ Modify.prototype.handleFeatureAdd_ = function(evt) {
/** /**
* @param {ol.events.Event} evt Event. * @param {module:ol/events/Event~Event} evt Event.
* @private * @private
*/ */
Modify.prototype.handleFeatureChange_ = function(evt) { Modify.prototype.handleFeatureChange_ = function(evt) {
@@ -433,7 +477,7 @@ Modify.prototype.handleFeatureChange_ = function(evt) {
/** /**
* @param {ol.CollectionEvent} evt Event. * @param {module:ol/Collection~CollectionEvent} evt Event.
* @private * @private
*/ */
Modify.prototype.handleFeatureRemove_ = function(evt) { Modify.prototype.handleFeatureRemove_ = function(evt) {
@@ -449,7 +493,7 @@ Modify.prototype.handleFeatureRemove_ = function(evt) {
*/ */
Modify.prototype.writePointGeometry_ = function(feature, geometry) { Modify.prototype.writePointGeometry_ = function(feature, geometry) {
const coordinates = geometry.getCoordinates(); const coordinates = geometry.getCoordinates();
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
segment: [coordinates, coordinates] segment: [coordinates, coordinates]
@@ -467,7 +511,7 @@ Modify.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
const points = geometry.getCoordinates(); const points = geometry.getCoordinates();
for (let i = 0, ii = points.length; i < ii; ++i) { for (let i = 0, ii = points.length; i < ii; ++i) {
const coordinates = points[i]; const coordinates = points[i];
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
depth: [i], depth: [i],
@@ -488,7 +532,7 @@ Modify.prototype.writeLineStringGeometry_ = function(feature, geometry) {
const coordinates = geometry.getCoordinates(); const coordinates = geometry.getCoordinates();
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
index: i, index: i,
@@ -510,7 +554,7 @@ Modify.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
const coordinates = lines[j]; const coordinates = lines[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
depth: [j], depth: [j],
@@ -534,7 +578,7 @@ Modify.prototype.writePolygonGeometry_ = function(feature, geometry) {
const coordinates = rings[j]; const coordinates = rings[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
depth: [j], depth: [j],
@@ -560,7 +604,7 @@ Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
const coordinates = rings[j]; const coordinates = rings[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
depth: [j, k], depth: [j, k],
@@ -587,13 +631,13 @@ Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
*/ */
Modify.prototype.writeCircleGeometry_ = function(feature, geometry) { Modify.prototype.writeCircleGeometry_ = function(feature, geometry) {
const coordinates = geometry.getCenter(); const coordinates = geometry.getCenter();
const centerSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ const centerSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
index: CIRCLE_CENTER_INDEX, index: CIRCLE_CENTER_INDEX,
segment: [coordinates, coordinates] segment: [coordinates, coordinates]
}); });
const circumferenceSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ const circumferenceSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
index: CIRCLE_CIRCUMFERENCE_INDEX, index: CIRCLE_CIRCUMFERENCE_INDEX,
@@ -639,8 +683,8 @@ Modify.prototype.createOrUpdateVertexFeature_ = function(coordinates) {
/** /**
* @param {ol.ModifySegmentDataType} a The first segment data. * @param {module:ol/interaction/Modify~SegmentData} a The first segment data.
* @param {ol.ModifySegmentDataType} b The second segment data. * @param {module:ol/interaction/Modify~SegmentData} b The second segment data.
* @return {number} The difference in indexes. * @return {number} The difference in indexes.
*/ */
function compareIndexes(a, b) { function compareIndexes(a, b) {
@@ -649,9 +693,9 @@ function compareIndexes(a, b) {
/** /**
* @param {ol.MapBrowserPointerEvent} evt Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.Modify} * @this {module:ol/interaction/Modify~Modify}
*/ */
function handleDownEvent(evt) { function handleDownEvent(evt) {
if (!this.condition_(evt)) { if (!this.condition_(evt)) {
@@ -725,8 +769,8 @@ function handleDownEvent(evt) {
/** /**
* @param {ol.MapBrowserPointerEvent} evt Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event.
* @this {ol.interaction.Modify} * @this {module:ol/interaction/Modify~Modify}
*/ */
function handleDragEvent(evt) { function handleDragEvent(evt) {
this.ignoreNextSingleClick_ = false; this.ignoreNextSingleClick_ = false;
@@ -801,9 +845,9 @@ function handleDragEvent(evt) {
/** /**
* @param {ol.MapBrowserPointerEvent} evt Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.Modify} * @this {module:ol/interaction/Modify~Modify}
*/ */
function handleUpEvent(evt) { function handleUpEvent(evt) {
for (let i = this.dragSegments_.length - 1; i >= 0; --i) { for (let i = this.dragSegments_.length - 1; i >= 0; --i) {
@@ -835,7 +879,7 @@ function handleUpEvent(evt) {
* geometry. * geometry.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Modify} * @this {module:ol/interaction/Modify~Modify}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) { if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
@@ -877,7 +921,7 @@ Modify.prototype.handlePointerMove_ = function(evt) {
/** /**
* @param {module:ol~Pixel} pixel Pixel * @param {module:ol~Pixel} pixel Pixel
* @param {ol.PluggableMap} map Map. * @param {module:ol/PluggableMap~PluggableMap} map Map.
* @private * @private
*/ */
Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
@@ -948,7 +992,7 @@ Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
* *
* @param {module:ol/coordinate~Coordinate} pointCoordinates The coordinates of the point from * @param {module:ol/coordinate~Coordinate} pointCoordinates The coordinates of the point from
* which to calculate the distance. * which to calculate the distance.
* @param {ol.ModifySegmentDataType} segmentData The object describing the line * @param {module:ol/interaction/Modify~SegmentData} segmentData The object describing the line
* segment we are calculating the distance to. * segment we are calculating the distance to.
* @return {number} The square of the distance between a point and a line segment. * @return {number} The square of the distance between a point and a line segment.
*/ */
@@ -974,7 +1018,7 @@ function pointDistanceToSegmentDataSquared(pointCoordinates, segmentData) {
* *
* @param {module:ol/coordinate~Coordinate} pointCoordinates The point to which a closest point * @param {module:ol/coordinate~Coordinate} pointCoordinates The point to which a closest point
* should be found. * should be found.
* @param {ol.ModifySegmentDataType} segmentData The object describing the line * @param {module:ol/interaction/Modify~SegmentData} segmentData The object describing the line
* segment which should contain the closest point. * segment which should contain the closest point.
* @return {module:ol/coordinate~Coordinate} The point closest to the specified line segment. * @return {module:ol/coordinate~Coordinate} The point closest to the specified line segment.
*/ */
@@ -990,7 +1034,7 @@ function closestOnSegmentData(pointCoordinates, segmentData) {
/** /**
* @param {ol.ModifySegmentDataType} segmentData Segment data. * @param {module:ol/interaction/Modify~SegmentData} segmentData Segment data.
* @param {module:ol/coordinate~Coordinate} vertex Vertex. * @param {module:ol/coordinate~Coordinate} vertex Vertex.
* @private * @private
*/ */
@@ -1031,7 +1075,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) {
const rTree = this.rBush_; const rTree = this.rBush_;
rTree.remove(segmentData); rTree.remove(segmentData);
this.updateSegmentIndices_(geometry, index, depth, 1); this.updateSegmentIndices_(geometry, index, depth, 1);
const newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ const newSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
segment: [segment[0], vertex], segment: [segment[0], vertex],
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
@@ -1042,7 +1086,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) {
newSegmentData); newSegmentData);
this.dragSegments_.push([newSegmentData, 1]); this.dragSegments_.push([newSegmentData, 1]);
const newSegmentData2 = /** @type {ol.ModifySegmentDataType} */ ({ const newSegmentData2 = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
segment: [vertex, segment[1]], segment: [vertex, segment[1]],
feature: feature, feature: feature,
geometry: geometry, geometry: geometry,
@@ -1167,7 +1211,7 @@ Modify.prototype.removeVertex_ = function() {
segments.push(right.segment[1]); segments.push(right.segment[1]);
} }
if (left !== undefined && right !== undefined) { if (left !== undefined && right !== undefined) {
const newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ const newSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
depth: segmentData.depth, depth: segmentData.depth,
feature: segmentData.feature, feature: segmentData.feature,
geometry: segmentData.geometry, geometry: segmentData.geometry,

View File

@@ -27,13 +27,30 @@ export const Mode = {
}; };
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled. Default is
* {@link module:ol/events/condition~always}.
* @property {number} [duration=250] Animation duration in milliseconds.
* @property {number} [timeout=80] Mouse wheel timeout duration in milliseconds.
* @property {boolean} [constrainResolution=false] When using a trackpad or
* magic mouse, zoom to the closest integer zoom level after the scroll gesture
* ends.
* @property {boolean} [useAnchor=true] Enable zooming using the mouse's
* location as the anchor. When set to `false`, zooming in and out will zoom to
* the center of the screen instead of zooming on the mouse's location.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to zoom the map by scrolling the mouse wheel. * Allows the user to zoom the map by scrolling the mouse wheel.
* *
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options. * @param {module:ol/interaction/MouseWheelZoom~Options=} opt_options Options.
* @api * @api
*/ */
const MouseWheelZoom = function(opt_options) { const MouseWheelZoom = function(opt_options) {
@@ -76,7 +93,7 @@ const MouseWheelZoom = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : always; this.condition_ = options.condition ? options.condition : always;
@@ -100,7 +117,7 @@ const MouseWheelZoom = function(opt_options) {
/** /**
* @private * @private
* @type {ol.interaction.Mode|undefined} * @type {module:ol/interaction/MouseWheelZoom~Mode|undefined}
*/ */
this.mode_ = undefined; this.mode_ = undefined;
@@ -140,7 +157,7 @@ inherits(MouseWheelZoom, Interaction);
* mousewheel-event) and eventually zooms the map. * mousewheel-event) and eventually zooms the map.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} Allow event propagation. * @return {boolean} Allow event propagation.
* @this {ol.interaction.MouseWheelZoom} * @this {module:ol/interaction/MouseWheelZoom~MouseWheelZoom}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) { if (!this.condition_(mapBrowserEvent)) {
@@ -271,7 +288,7 @@ MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
/** /**
* @private * @private
* @param {ol.PluggableMap} map Map. * @param {module:ol/PluggableMap~PluggableMap} map Map.
*/ */
MouseWheelZoom.prototype.handleWheelZoom_ = function(map) { MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
const view = map.getView(); const view = map.getView();

View File

@@ -8,14 +8,23 @@ import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js'; import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
import {disable} from '../rotationconstraint.js'; import {disable} from '../rotationconstraint.js';
/**
* @typedef {Object} Options
* @property {number} [duration=250] The duration of the animation in
* milliseconds.
* @property {number} [threshold=0.3] Minimal angle in radians to start a rotation.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to rotate the map by twisting with two fingers * Allows the user to rotate the map by twisting with two fingers
* on a touch screen. * on a touch screen.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.PinchRotateOptions=} opt_options Options. * @param {module:ol/interaction/PinchRotate~Options=} opt_options Options.
* @api * @api
*/ */
const PinchRotate = function(opt_options) { const PinchRotate = function(opt_options) {
@@ -70,8 +79,8 @@ inherits(PinchRotate, PointerInteraction);
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.PinchRotate} * @this {module:ol/interaction/PinchRotate~PinchRotate}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
let rotationDelta = 0.0; let rotationDelta = 0.0;
@@ -120,9 +129,9 @@ function handleDragEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.PinchRotate} * @this {module:ol/interaction/PinchRotate~PinchRotate}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
if (this.targetPointers.length < 2) { if (this.targetPointers.length < 2) {
@@ -141,9 +150,9 @@ function handleUpEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.PinchRotate} * @this {module:ol/interaction/PinchRotate~PinchRotate}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
if (this.targetPointers.length >= 2) { if (this.targetPointers.length >= 2) {

View File

@@ -7,14 +7,23 @@ import {FALSE} from '../functions.js';
import {zoom, zoomWithoutConstraints} from '../interaction/Interaction.js'; import {zoom, zoomWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js'; import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
/**
* @typedef {Object} Options
* @property {number} [duration=400] Animation duration in milliseconds.
* @property {boolean} [constrainResolution=false] Zoom to the closest integer
* zoom level after the pinch gesture ends.
*/
/** /**
* @classdesc * @classdesc
* Allows the user to zoom the map by pinching with two fingers * Allows the user to zoom the map by pinching with two fingers
* on a touch screen. * on a touch screen.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.PinchZoomOptions=} opt_options Options. * @param {module:ol/interaction/PinchZoom~Options=} opt_options Options.
* @api * @api
*/ */
const PinchZoom = function(opt_options) { const PinchZoom = function(opt_options) {
@@ -63,8 +72,8 @@ inherits(PinchZoom, PointerInteraction);
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.PinchZoom} * @this {module:ol/interaction/PinchZoom~PinchZoom}
*/ */
function handleDragEvent(mapBrowserEvent) { function handleDragEvent(mapBrowserEvent) {
let scaleDelta = 1.0; let scaleDelta = 1.0;
@@ -115,9 +124,9 @@ function handleDragEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.PinchZoom} * @this {module:ol/interaction/PinchZoom~PinchZoom}
*/ */
function handleUpEvent(mapBrowserEvent) { function handleUpEvent(mapBrowserEvent) {
if (this.targetPointers.length < 2) { if (this.targetPointers.length < 2) {
@@ -142,9 +151,9 @@ function handleUpEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.PinchZoom} * @this {module:ol/interaction/PinchZoom~PinchZoom}
*/ */
function handleDownEvent(mapBrowserEvent) { function handleDownEvent(mapBrowserEvent) {
if (this.targetPointers.length >= 2) { if (this.targetPointers.length >= 2) {

View File

@@ -10,35 +10,58 @@ import {getValues} from '../obj.js';
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.Pointer} * @this {module:ol/interaction/Pointer~Pointer}
*/ */
const handleDragEvent = UNDEFINED; const handleDragEvent = UNDEFINED;
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Capture dragging. * @return {boolean} Capture dragging.
* @this {ol.interaction.Pointer} * @this {module:ol/interaction/Pointer~Pointer}
*/ */
const handleUpEvent = FALSE; const handleUpEvent = FALSE;
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Capture dragging. * @return {boolean} Capture dragging.
* @this {ol.interaction.Pointer} * @this {module:ol/interaction/Pointer~Pointer}
*/ */
const handleDownEvent = FALSE; const handleDownEvent = FALSE;
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @this {ol.interaction.Pointer} * @this {module:ol/interaction/Pointer~Pointer}
*/ */
const handleMoveEvent = UNDEFINED; const handleMoveEvent = UNDEFINED;
/**
* @typedef {Object} Options
* @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean)} [handleDownEvent]
* Function handling "down" events. If the function returns `true` then a drag
* sequence is started.
* @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent))} [handleDragEvent]
* Function handling "drag" events. This function is called on "move" events
* during a drag sequence.
* @property {(function(module:ol/MapBrowserEvent~MapBrowserEvent):boolean)} [handleEvent]
* Method called by the map to notify the interaction that a browser event was
* dispatched to the map. The function may return `false` to prevent the
* propagation of the event to other interactions in the map's interactions
* chain.
* @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent))} [handleMoveEvent]
* Function handling "move" events. This function is called on "move" events,
* also during a drag sequence (so during a drag sequence both the
* `handleDragEvent` function and this function are called).
* @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean)} [handleUpEvent]
Function handling "up" events. If the function returns `false` then the
* current drag sequence is stopped.
*/
/** /**
* @classdesc * @classdesc
* Base class that calls user-defined functions on `down`, `move` and `up` * Base class that calls user-defined functions on `down`, `move` and `up`
@@ -50,8 +73,8 @@ const handleMoveEvent = UNDEFINED;
* user function is called and returns `false`. * user function is called and returns `false`.
* *
* @constructor * @constructor
* @param {olx.interaction.PointerOptions=} opt_options Options. * @param {module:ol/interaction/Pointer~Options=} opt_options Options.
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @api * @api
*/ */
const PointerInteraction = function(opt_options) { const PointerInteraction = function(opt_options) {
@@ -63,28 +86,28 @@ const PointerInteraction = function(opt_options) {
}); });
/** /**
* @type {function(ol.MapBrowserPointerEvent):boolean} * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean}
* @private * @private
*/ */
this.handleDownEvent_ = options.handleDownEvent ? this.handleDownEvent_ = options.handleDownEvent ?
options.handleDownEvent : handleDownEvent; options.handleDownEvent : handleDownEvent;
/** /**
* @type {function(ol.MapBrowserPointerEvent)} * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent)}
* @private * @private
*/ */
this.handleDragEvent_ = options.handleDragEvent ? this.handleDragEvent_ = options.handleDragEvent ?
options.handleDragEvent : handleDragEvent; options.handleDragEvent : handleDragEvent;
/** /**
* @type {function(ol.MapBrowserPointerEvent)} * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent)}
* @private * @private
*/ */
this.handleMoveEvent_ = options.handleMoveEvent ? this.handleMoveEvent_ = options.handleMoveEvent ?
options.handleMoveEvent : handleMoveEvent; options.handleMoveEvent : handleMoveEvent;
/** /**
* @type {function(ol.MapBrowserPointerEvent):boolean} * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean}
* @private * @private
*/ */
this.handleUpEvent_ = options.handleUpEvent ? this.handleUpEvent_ = options.handleUpEvent ?
@@ -97,13 +120,13 @@ const PointerInteraction = function(opt_options) {
this.handlingDownUpSequence = false; this.handlingDownUpSequence = false;
/** /**
* @type {!Object.<string, ol.pointer.PointerEvent>} * @type {!Object.<string, module:ol/pointer/PointerEvent~PointerEvent>}
* @private * @private
*/ */
this.trackedPointers_ = {}; this.trackedPointers_ = {};
/** /**
* @type {Array.<ol.pointer.PointerEvent>} * @type {Array.<module:ol/pointer/PointerEvent~PointerEvent>}
* @protected * @protected
*/ */
this.targetPointers = []; this.targetPointers = [];
@@ -114,7 +137,7 @@ inherits(PointerInteraction, Interaction);
/** /**
* @param {Array.<ol.pointer.PointerEvent>} pointerEvents List of events. * @param {Array.<module:ol/pointer/PointerEvent~PointerEvent>} pointerEvents List of events.
* @return {module:ol~Pixel} Centroid pixel. * @return {module:ol~Pixel} Centroid pixel.
*/ */
export function centroid(pointerEvents) { export function centroid(pointerEvents) {
@@ -130,7 +153,7 @@ export function centroid(pointerEvents) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Whether the event is a pointerdown, pointerdrag * @return {boolean} Whether the event is a pointerdown, pointerdrag
* or pointerup event. * or pointerup event.
*/ */
@@ -143,7 +166,7 @@ function isPointerDraggingEvent(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
* @private * @private
*/ */
PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent) { PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent) {
@@ -171,7 +194,7 @@ PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent)
* detected. * detected.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Pointer} * @this {module:ol/interaction/Pointer~Pointer}
* @api * @api
*/ */
export function handleEvent(mapBrowserEvent) { export function handleEvent(mapBrowserEvent) {

View File

@@ -29,9 +29,77 @@ const SelectEventType = {
}; };
/**
* A function that takes an {@link module:ol/Feature~Feature} or
* {@link module:ol/render/Feature~Feature} and an
* {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be
* selected or `false` otherwise.
* @typedef {function((module:ol/Feature~Feature|module:ol/render/Feature~Feature), module:ol/layer/Layer~Layer):
* boolean} FilterFunction
*/
/**
* @typedef {Object} Options
* @property {module:ol/events/condition~Condition} [addCondition] A function
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled.
* By default, this is {@link module:ol/events/condition~never}. Use this if you
* want to use different events for add and remove instead of `toggle`.
* @property {module:ol/events/condition~Condition} [condition] A function that
* takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled. This is the event
* for the selected features as a whole. By default, this is
* {@link module:ol/events/condition~singleClick}. Clicking on a feature selects that
* feature and removes any that were in the selection. Clicking outside any
* feature removes all from the selection.
* See `toggle`, `add`, `remove` options for adding/removing extra features to/
* from the selection.
* @property {Array.<module:ol/layer/Layer~Layer>|function(module:ol/layer/Layer~Layer): boolean} [layers]
* A list of layers from which features should be selected. Alternatively, a
* filter function can be provided. The function will be called for each layer
* in the map and should return `true` for layers that you want to be
* selectable. If the option is absent, all visible layers will be considered
* selectable.
* @property {module:ol/style/Style~Style|Array.<module:ol/style/Style~Style>|module:ol/style~StyleFunction} [style]
* Style for the selected features. By default the default edit style is used
* (see {@link module:ol/style}).
* @property {module:ol/events/condition~Condition} [removeCondition] A function
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled.
* By default, this is {@link module:ol/events/condition~never}. Use this if you
* want to use different events for add and remove instead of `toggle`.
* @property {module:ol/events/condition~Condition} [toggleCondition] A function
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* boolean to indicate whether that event should be handled. This is in addition
* to the `condition` event. By default,
* {@link module:ol/events/condition~shiftKeyOnly}, i.e. pressing `shift` as
* well as the `condition` event, adds that feature to the current selection if
* it is not currently selected, and removes it if it is. See `add` and `remove`
* if you want to use different events instead of a toggle.
* @property {boolean} [multi=false] A boolean that determines if the default
* behaviour should select only single features or all (overlapping) features at
* the clicked map position. The default of `false` means single select.
* @property {module:ol/Collection~Collection.<module:ol/Feature~Feature>} [features]
* Collection where the interaction will place selected features. Optional. If
* not set the interaction will create a collection. In any case the collection
* used by the interaction is returned by
* {@link module:ol/interaction/Select~Select#getFeatures}.
* @property {module:ol/interaction/Select~FilterFunction} [filter] A function
* that takes an {@link module:ol/Feature~Feature} and an
* {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be
* selected or `false` otherwise.
* @property {boolean} [wrapX=true] Wrap the world horizontally on the selection
* overlay.
* @property {number} [hitTolerance=0] Hit-detection tolerance. Pixels inside
* the radius around the given position will be checked for features. This only
* works for the canvas renderer and not for WebGL.
*/
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.Select} instances are instances of * Events emitted by {@link module:ol/interaction/Select~Select} instances are instances of
* this type. * this type.
* *
* @param {SelectEventType} type The event type. * @param {SelectEventType} type The event type.
@@ -40,7 +108,7 @@ const SelectEventType = {
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Associated * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Associated
* {@link module:ol/MapBrowserEvent~MapBrowserEvent}. * {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
* @implements {oli.SelectEvent} * @implements {oli.SelectEvent}
* @extends {ol.events.Event} * @extends {module:ol/events/Event~Event}
* @constructor * @constructor
*/ */
const SelectEvent = function(type, selected, deselected, mapBrowserEvent) { const SelectEvent = function(type, selected, deselected, mapBrowserEvent) {
@@ -84,8 +152,8 @@ inherits(SelectEvent, Event);
* Selected features are added to an internal unmanaged layer. * Selected features are added to an internal unmanaged layer.
* *
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {module:ol/interaction/Interaction~Interaction}
* @param {olx.interaction.SelectOptions=} opt_options Options. * @param {module:ol/interaction/Select~Options=} opt_options Options.
* @fires SelectEvent * @fires SelectEvent
* @api * @api
*/ */
@@ -99,25 +167,25 @@ const Select = function(opt_options) {
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.condition_ = options.condition ? options.condition : singleClick; this.condition_ = options.condition ? options.condition : singleClick;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.addCondition_ = options.addCondition ? options.addCondition : never; this.addCondition_ = options.addCondition ? options.addCondition : never;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.removeCondition_ = options.removeCondition ? options.removeCondition : never; this.removeCondition_ = options.removeCondition ? options.removeCondition : never;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {module:ol/events/condition~Condition}
*/ */
this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly; this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly;
@@ -129,7 +197,7 @@ const Select = function(opt_options) {
/** /**
* @private * @private
* @type {ol.SelectFilterFunction} * @type {module:ol/interaction/Select~FilterFunction}
*/ */
this.filter_ = options.filter ? options.filter : TRUE; this.filter_ = options.filter ? options.filter : TRUE;
@@ -153,11 +221,11 @@ const Select = function(opt_options) {
/** /**
* @private * @private
* @type {ol.layer.Vector} * @type {module:ol/layer/Vector~Vector}
*/ */
this.featureOverlay_ = featureOverlay; this.featureOverlay_ = featureOverlay;
/** @type {function(ol.layer.Layer): boolean} */ /** @type {function(module:ol/layer/Layer~Layer): boolean} */
let layerFilter; let layerFilter;
if (options.layers) { if (options.layers) {
if (typeof options.layers === 'function') { if (typeof options.layers === 'function') {
@@ -174,7 +242,7 @@ const Select = function(opt_options) {
/** /**
* @private * @private
* @type {function(ol.layer.Layer): boolean} * @type {function(module:ol/layer/Layer~Layer): boolean}
*/ */
this.layerFilter_ = layerFilter; this.layerFilter_ = layerFilter;
@@ -182,7 +250,7 @@ const Select = function(opt_options) {
* An association between selected feature (key) * An association between selected feature (key)
* and layer (value) * and layer (value)
* @private * @private
* @type {Object.<number, ol.layer.Layer>} * @type {Object.<number, module:ol/layer/Layer~Layer>}
*/ */
this.featureLayerAssociation_ = {}; this.featureLayerAssociation_ = {};
@@ -198,8 +266,8 @@ inherits(Select, Interaction);
/** /**
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
* @param {ol.layer.Layer} layer Layer. * @param {module:ol/layer/Layer~Layer} layer Layer.
* @private * @private
*/ */
Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) { Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
@@ -210,7 +278,7 @@ Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
/** /**
* Get the selected features. * Get the selected features.
* @return {ol.Collection.<module:ol/Feature~Feature>} Features collection. * @return {module:ol/Collection~Collection.<module:ol/Feature~Feature>} Features collection.
* @api * @api
*/ */
Select.prototype.getFeatures = function() { Select.prototype.getFeatures = function() {
@@ -229,17 +297,17 @@ Select.prototype.getHitTolerance = function() {
/** /**
* Returns the associated {@link ol.layer.Vector vectorlayer} of * Returns the associated {@link module:ol/layer/Vector~Vector vectorlayer} of
* the (last) selected feature. Note that this will not work with any * the (last) selected feature. Note that this will not work with any
* programmatic method like pushing features to * programmatic method like pushing features to
* {@link ol.interaction.Select#getFeatures collection}. * {@link module:ol/interaction/Select~Select#getFeatures collection}.
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature
* @return {ol.layer.Vector} Layer. * @return {module:ol/layer/Vector~Vector} Layer.
* @api * @api
*/ */
Select.prototype.getLayer = function(feature) { Select.prototype.getLayer = function(feature) {
const key = getUid(feature); const key = getUid(feature);
return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]); return /** @type {module:ol/layer/Vector~Vector} */ (this.featureLayerAssociation_[key]);
}; };
@@ -248,7 +316,7 @@ Select.prototype.getLayer = function(feature) {
* selected state of features. * selected state of features.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Select} * @this {module:ol/interaction/Select~Select}
*/ */
function handleEvent(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) { if (!this.condition_(mapBrowserEvent)) {
@@ -270,8 +338,8 @@ function handleEvent(mapBrowserEvent) {
map.forEachFeatureAtPixel(mapBrowserEvent.pixel, map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
( (
/** /**
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
* @param {ol.layer.Layer} layer Layer. * @param {module:ol/layer/Layer~Layer} layer Layer.
* @return {boolean|undefined} Continue to iterate over the features. * @return {boolean|undefined} Continue to iterate over the features.
*/ */
function(feature, layer) { function(feature, layer) {
@@ -303,8 +371,8 @@ function handleEvent(mapBrowserEvent) {
map.forEachFeatureAtPixel(mapBrowserEvent.pixel, map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
( (
/** /**
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
* @param {ol.layer.Layer} layer Layer. * @param {module:ol/layer/Layer~Layer} layer Layer.
* @return {boolean|undefined} Continue to iterate over the features. * @return {boolean|undefined} Continue to iterate over the features.
*/ */
function(feature, layer) { function(feature, layer) {
@@ -351,7 +419,7 @@ Select.prototype.setHitTolerance = function(hitTolerance) {
/** /**
* Remove the interaction from its current map, if any, and attach it to a new * Remove the interaction from its current map, if any, and attach it to a new
* map, if any. Pass `null` to just remove the interaction from the current map. * map, if any. Pass `null` to just remove the interaction from the current map.
* @param {ol.PluggableMap} map Map. * @param {module:ol/PluggableMap~PluggableMap} map Map.
* @override * @override
* @api * @api
*/ */
@@ -388,7 +456,7 @@ function getDefaultStyleFunction() {
/** /**
* @param {ol.CollectionEvent} evt Event. * @param {module:ol/Collection~CollectionEvent} evt Event.
* @private * @private
*/ */
Select.prototype.addFeature_ = function(evt) { Select.prototype.addFeature_ = function(evt) {
@@ -400,7 +468,7 @@ Select.prototype.addFeature_ = function(evt) {
/** /**
* @param {ol.CollectionEvent} evt Event. * @param {module:ol/Collection~CollectionEvent} evt Event.
* @private * @private
*/ */
Select.prototype.removeFeature_ = function(evt) { Select.prototype.removeFeature_ = function(evt) {
@@ -412,7 +480,7 @@ Select.prototype.removeFeature_ = function(evt) {
/** /**
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
* @private * @private
*/ */
Select.prototype.removeFeatureLayerAssociation_ = function(feature) { Select.prototype.removeFeatureLayerAssociation_ = function(feature) {

View File

@@ -17,10 +17,37 @@ import {VectorSourceEvent} from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js'; import VectorEventType from '../source/VectorEventType.js';
import RBush from '../structs/RBush.js'; import RBush from '../structs/RBush.js';
/**
* @typedef {Object} Result
* @property {boolean} snapped
* @property {module:ol/coordinate~Coordinate|null} vertex
* @property {module:ol~Pixel|null} vertexPixel
*/
/**
* @typedef {Object} SegmentData
* @property {module:ol/Feature~Feature} feature
* @property {Array.<module:ol/coordinate~Coordinate>} segment
*/
/**
* @typedef {Object} Options
* @property {module:ol/Collection~Collection.<module:ol/Feature~Feature>|undefined} features Snap to these features. Either this option or source should be provided.
* @property {boolean|undefined} edge Snap to edges. Default is `true`.
* @property {boolean|undefined} vertex Snap to vertices. Default is `true`.
* @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or
* vertex for snapping. Default is `10` pixels.
* @property {module:ol/source/Vector~Vector|undefined} source Snap to features from this source. Either this option or features should be provided
*/
/** /**
* @classdesc * @classdesc
* Handles snapping of vector features while modifying or drawing them. The * Handles snapping of vector features while modifying or drawing them. The
* features can come from a {@link ol.source.Vector} or {@link ol.Collection} * features can come from a {@link module:ol/source/Vector~Vector} or {@link module:ol/Collection~Collection}
* Any interaction object that allows the user to interact * Any interaction object that allows the user to interact
* with the features using the mouse can benefit from the snapping, as long * with the features using the mouse can benefit from the snapping, as long
* as it is added before. * as it is added before.
@@ -30,13 +57,15 @@ import RBush from '../structs/RBush.js';
* *
* Example: * Example:
* *
* var snap = new ol.interaction.Snap({ * import Snap from 'ol/interaction/Snap';
*
* var snap = new Snap({
* source: source * source: source
* }); * });
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @param {olx.interaction.SnapOptions=} opt_options Options. * @param {module:ol/interaction/Snap~Options=} opt_options Options.
* @api * @api
*/ */
const Snap = function(opt_options) { const Snap = function(opt_options) {
@@ -50,7 +79,7 @@ const Snap = function(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
/** /**
* @type {ol.source.Vector} * @type {module:ol/source/Vector~Vector}
* @private * @private
*/ */
this.source_ = options.source ? options.source : null; this.source_ = options.source ? options.source : null;
@@ -68,7 +97,7 @@ const Snap = function(opt_options) {
this.edge_ = options.edge !== undefined ? options.edge : true; this.edge_ = options.edge !== undefined ? options.edge : true;
/** /**
* @type {ol.Collection.<module:ol/Feature~Feature>} * @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
* @private * @private
*/ */
this.features_ = options.features ? options.features : null; this.features_ = options.features ? options.features : null;
@@ -117,7 +146,7 @@ const Snap = function(opt_options) {
options.pixelTolerance : 10; options.pixelTolerance : 10;
/** /**
* @type {function(ol.SnapSegmentDataType, ol.SnapSegmentDataType): number} * @type {function(module:ol/interaction/Snap~SegmentData, module:ol/interaction/Snap~SegmentData): number}
* @private * @private
*/ */
this.sortByDistance_ = sortByDistance.bind(this); this.sortByDistance_ = sortByDistance.bind(this);
@@ -125,7 +154,7 @@ const Snap = function(opt_options) {
/** /**
* Segment RTree for each layer * Segment RTree for each layer
* @type {ol.structs.RBush.<ol.SnapSegmentDataType>} * @type {module:ol/structs/RBush~RBush.<module:ol/interaction/Snap~SegmentData>}
* @private * @private
*/ */
this.rBush_ = new RBush(); this.rBush_ = new RBush();
@@ -199,7 +228,7 @@ Snap.prototype.forEachFeatureRemove_ = function(feature) {
/** /**
* @return {ol.Collection.<module:ol/Feature~Feature>|Array.<module:ol/Feature~Feature>} Features. * @return {module:ol/Collection~Collection.<module:ol/Feature~Feature>|Array.<module:ol/Feature~Feature>} Features.
* @private * @private
*/ */
Snap.prototype.getFeatures_ = function() { Snap.prototype.getFeatures_ = function() {
@@ -209,12 +238,12 @@ Snap.prototype.getFeatures_ = function() {
} else if (this.source_) { } else if (this.source_) {
features = this.source_.getFeatures(); features = this.source_.getFeatures();
} }
return /** @type {!Array.<module:ol/Feature~Feature>|!ol.Collection.<module:ol/Feature~Feature>} */ (features); return /** @type {!Array.<module:ol/Feature~Feature>|!module:ol/Collection~Collection.<module:ol/Feature~Feature>} */ (features);
}; };
/** /**
* @param {ol.source.Vector.Event|ol.CollectionEvent} evt Event. * @param {module:ol/source/Vector~Vector.Event|module:ol/Collection~CollectionEvent} evt Event.
* @private * @private
*/ */
Snap.prototype.handleFeatureAdd_ = function(evt) { Snap.prototype.handleFeatureAdd_ = function(evt) {
@@ -229,7 +258,7 @@ Snap.prototype.handleFeatureAdd_ = function(evt) {
/** /**
* @param {ol.source.Vector.Event|ol.CollectionEvent} evt Event. * @param {module:ol/source/Vector~Vector.Event|module:ol/Collection~CollectionEvent} evt Event.
* @private * @private
*/ */
Snap.prototype.handleFeatureRemove_ = function(evt) { Snap.prototype.handleFeatureRemove_ = function(evt) {
@@ -244,7 +273,7 @@ Snap.prototype.handleFeatureRemove_ = function(evt) {
/** /**
* @param {ol.events.Event} evt Event. * @param {module:ol/events/Event~Event} evt Event.
* @private * @private
*/ */
Snap.prototype.handleFeatureChange_ = function(evt) { Snap.prototype.handleFeatureChange_ = function(evt) {
@@ -336,8 +365,8 @@ Snap.prototype.shouldStopEvent = FALSE;
/** /**
* @param {module:ol~Pixel} pixel Pixel * @param {module:ol~Pixel} pixel Pixel
* @param {module:ol/coordinate~Coordinate} pixelCoordinate Coordinate * @param {module:ol/coordinate~Coordinate} pixelCoordinate Coordinate
* @param {ol.PluggableMap} map Map. * @param {module:ol/PluggableMap~PluggableMap} map Map.
* @return {ol.SnapResultType} Snap result * @return {module:ol/interaction/Snap~Result} Snap result
*/ */
Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
@@ -408,7 +437,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
vertexPixel = [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])]; vertexPixel = [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])];
} }
} }
return /** @type {ol.SnapResultType} */ ({ return /** @type {module:ol/interaction/Snap~Result} */ ({
snapped: snapped, snapped: snapped,
vertex: vertex, vertex: vertex,
vertexPixel: vertexPixel vertexPixel: vertexPixel
@@ -436,7 +465,7 @@ Snap.prototype.writeCircleGeometry_ = function(feature, geometry) {
const coordinates = polygon.getCoordinates()[0]; const coordinates = polygon.getCoordinates()[0];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: segment segment: segment
}); });
@@ -470,7 +499,7 @@ Snap.prototype.writeLineStringGeometry_ = function(feature, geometry) {
const coordinates = geometry.getCoordinates(); const coordinates = geometry.getCoordinates();
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: segment segment: segment
}); });
@@ -490,7 +519,7 @@ Snap.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
const coordinates = lines[j]; const coordinates = lines[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: segment segment: segment
}); });
@@ -509,7 +538,7 @@ Snap.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
const points = geometry.getCoordinates(); const points = geometry.getCoordinates();
for (let i = 0, ii = points.length; i < ii; ++i) { for (let i = 0, ii = points.length; i < ii; ++i) {
const coordinates = points[i]; const coordinates = points[i];
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: [coordinates, coordinates] segment: [coordinates, coordinates]
}); });
@@ -531,7 +560,7 @@ Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
const coordinates = rings[j]; const coordinates = rings[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: segment segment: segment
}); });
@@ -549,7 +578,7 @@ Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
*/ */
Snap.prototype.writePointGeometry_ = function(feature, geometry) { Snap.prototype.writePointGeometry_ = function(feature, geometry) {
const coordinates = geometry.getCoordinates(); const coordinates = geometry.getCoordinates();
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: [coordinates, coordinates] segment: [coordinates, coordinates]
}); });
@@ -568,7 +597,7 @@ Snap.prototype.writePolygonGeometry_ = function(feature, geometry) {
const coordinates = rings[j]; const coordinates = rings[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2); const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
feature: feature, feature: feature,
segment: segment segment: segment
}); });
@@ -582,7 +611,7 @@ Snap.prototype.writePolygonGeometry_ = function(feature, geometry) {
* Handle all pointer events events. * Handle all pointer events events.
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt A move event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt A move event.
* @return {boolean} Pass the event to other interactions. * @return {boolean} Pass the event to other interactions.
* @this {ol.interaction.Snap} * @this {module:ol/interaction/Snap~Snap}
*/ */
export function handleEvent(evt) { export function handleEvent(evt) {
const result = this.snapTo(evt.pixel, evt.coordinate, evt.map); const result = this.snapTo(evt.pixel, evt.coordinate, evt.map);
@@ -595,9 +624,9 @@ export function handleEvent(evt) {
/** /**
* @param {ol.MapBrowserPointerEvent} evt Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.Snap} * @this {module:ol/interaction/Snap~Snap}
*/ */
function handleUpEvent(evt) { function handleUpEvent(evt) {
const featuresToUpdate = getValues(this.pendingFeatures_); const featuresToUpdate = getValues(this.pendingFeatures_);
@@ -611,10 +640,10 @@ function handleUpEvent(evt) {
/** /**
* Sort segments by distance, helper function * Sort segments by distance, helper function
* @param {ol.SnapSegmentDataType} a The first segment data. * @param {module:ol/interaction/Snap~SegmentData} a The first segment data.
* @param {ol.SnapSegmentDataType} b The second segment data. * @param {module:ol/interaction/Snap~SegmentData} b The second segment data.
* @return {number} The difference in distance. * @return {number} The difference in distance.
* @this {ol.interaction.Snap} * @this {module:ol/interaction/Snap~Snap}
*/ */
function sortByDistance(a, b) { function sortByDistance(a, b) {
const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment); const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment);

View File

@@ -37,16 +37,31 @@ const TranslateEventType = {
}; };
/**
* @typedef {Object} interaction_TranslateOptions
* @property {module:ol/Collection~Collection.<module:ol/Feature~Feature>|undefined} features Only features contained in this collection will be able to be translated. If
* not specified, all features on the map will be able to be translated.
* @property {undefined|Array.<module:ol/layer/Layer~Layer>|function(module:ol/layer/Layer~Layer): boolean} layers A list of layers from which features should be
* translated. Alternatively, a filter function can be provided. The
* function will be called for each layer in the map and should return
* `true` for layers that you want to be translatable. If the option is
* absent, all visible layers will be considered translatable.
* @property {number|undefined} hitTolerance Hit-detection tolerance. Pixels inside the radius around the given position
* will be checked for features. This only works for the canvas renderer and
* not for WebGL. Default is `0`.
*/
/** /**
* @classdesc * @classdesc
* Events emitted by {@link ol.interaction.Translate} instances are instances of * Events emitted by {@link module:ol/interaction/Translate~Translate} instances
* this type. * are instances of this type.
* *
* @constructor * @constructor
* @extends {ol.events.Event} * @extends {module:ol/events/Event~Event}
* @implements {oli.interaction.TranslateEvent} * @implements {oli.interaction.TranslateEvent}
* @param {ol.interaction.TranslateEventType} type Type. * @param {module:ol/interaction/Translate~TranslateEventType} type Type.
* @param {ol.Collection.<module:ol/Feature~Feature>} features The features translated. * @param {module:ol/Collection~Collection.<module:ol/Feature~Feature>} features The features translated.
* @param {module:ol/coordinate~Coordinate} coordinate The event coordinate. * @param {module:ol/coordinate~Coordinate} coordinate The event coordinate.
*/ */
export const TranslateEvent = function(type, features, coordinate) { export const TranslateEvent = function(type, features, coordinate) {
@@ -55,7 +70,7 @@ export const TranslateEvent = function(type, features, coordinate) {
/** /**
* The features being translated. * The features being translated.
* @type {ol.Collection.<module:ol/Feature~Feature>} * @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
* @api * @api
*/ */
this.features = features; this.features = features;
@@ -77,8 +92,8 @@ inherits(TranslateEvent, Event);
* Interaction for translating (moving) features. * Interaction for translating (moving) features.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {module:ol/interaction/Pointer~Pointer}
* @fires ol.interaction.TranslateEvent * @fires module:ol/interaction/Translate~TranslateEvent
* @param {olx.interaction.TranslateOptions=} opt_options Options. * @param {olx.interaction.TranslateOptions=} opt_options Options.
* @api * @api
*/ */
@@ -101,12 +116,12 @@ const Translate = function(opt_options) {
/** /**
* @type {ol.Collection.<module:ol/Feature~Feature>} * @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
* @private * @private
*/ */
this.features_ = options.features !== undefined ? options.features : null; this.features_ = options.features !== undefined ? options.features : null;
/** @type {function(ol.layer.Layer): boolean} */ /** @type {function(module:ol/layer/Layer~Layer): boolean} */
let layerFilter; let layerFilter;
if (options.layers) { if (options.layers) {
if (typeof options.layers === 'function') { if (typeof options.layers === 'function') {
@@ -123,7 +138,7 @@ const Translate = function(opt_options) {
/** /**
* @private * @private
* @type {function(ol.layer.Layer): boolean} * @type {function(module:ol/layer/Layer~Layer): boolean}
*/ */
this.layerFilter_ = layerFilter; this.layerFilter_ = layerFilter;
@@ -149,9 +164,9 @@ inherits(Translate, PointerInteraction);
/** /**
* @param {ol.MapBrowserPointerEvent} event Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event.
* @return {boolean} Start drag sequence? * @return {boolean} Start drag sequence?
* @this {ol.interaction.Translate} * @this {module:ol/interaction/Translate~Translate}
*/ */
function handleDownEvent(event) { function handleDownEvent(event) {
this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map); this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map);
@@ -172,9 +187,9 @@ function handleDownEvent(event) {
/** /**
* @param {ol.MapBrowserPointerEvent} event Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event.
* @return {boolean} Stop drag sequence? * @return {boolean} Stop drag sequence?
* @this {ol.interaction.Translate} * @this {module:ol/interaction/Translate~Translate}
*/ */
function handleUpEvent(event) { function handleUpEvent(event) {
if (this.lastCoordinate_) { if (this.lastCoordinate_) {
@@ -194,8 +209,8 @@ function handleUpEvent(event) {
/** /**
* @param {ol.MapBrowserPointerEvent} event Event. * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event.
* @this {ol.interaction.Translate} * @this {module:ol/interaction/Translate~Translate}
*/ */
function handleDragEvent(event) { function handleDragEvent(event) {
if (this.lastCoordinate_) { if (this.lastCoordinate_) {
@@ -222,7 +237,7 @@ function handleDragEvent(event) {
/** /**
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Event. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Event.
* @this {ol.interaction.Translate} * @this {module:ol/interaction/Translate~Translate}
*/ */
function handleMoveEvent(event) { function handleMoveEvent(event) {
const elem = event.map.getViewport(); const elem = event.map.getViewport();
@@ -242,7 +257,7 @@ function handleMoveEvent(event) {
* Tests to see if the given coordinates intersects any of our selected * Tests to see if the given coordinates intersects any of our selected
* features. * features.
* @param {module:ol~Pixel} pixel Pixel coordinate to test for intersection. * @param {module:ol~Pixel} pixel Pixel coordinate to test for intersection.
* @param {ol.PluggableMap} map Map to test the intersection on. * @param {module:ol/PluggableMap~PluggableMap} map Map to test the intersection on.
* @return {module:ol/Feature~Feature} Returns the feature found at the specified pixel * @return {module:ol/Feature~Feature} Returns the feature found at the specified pixel
* coordinates. * coordinates.
* @private * @private
@@ -301,7 +316,7 @@ Translate.prototype.handleActiveChanged_ = function() {
/** /**
* @param {ol.PluggableMap} oldMap Old map. * @param {module:ol/PluggableMap~PluggableMap} oldMap Old map.
* @private * @private
*/ */
Translate.prototype.updateState_ = function(oldMap) { Translate.prototype.updateState_ = function(oldMap) {

View File

@@ -1,3 +0,0 @@
/**
* @namespace ol.interaction
*/

View File

@@ -35,8 +35,8 @@ import SourceState from '../source/State.js';
* displayed, irrespective of the source of that data. * displayed, irrespective of the source of that data.
* *
* Layers are usually added to a map with {@link ol.Map#addLayer}. Components * Layers are usually added to a map with {@link ol.Map#addLayer}. Components
* like {@link ol.interaction.Select} use unmanaged layers internally. These * like {@link module:ol/interaction/Select~Select} use unmanaged layers
* unmanaged layers are associated with the map using * internally. These unmanaged layers are associated with the map using
* {@link ol.layer.Layer#setMap} instead. * {@link ol.layer.Layer#setMap} instead.
* *
* A generic `change` event is fired when the state of the source changes. * A generic `change` event is fired when the state of the source changes.

View File

@@ -153,35 +153,6 @@ ol.CircleRenderOptions;
ol.DeclutterGroup; ol.DeclutterGroup;
/**
* A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
* {@link module:ol~Pixel}s and returns a `{boolean}`. If the condition is met,
* true should be returned.
* @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean}
*/
ol.DragBoxEndConditionType;
/**
* Function that takes an array of coordinates and an optional existing geometry as
* arguments, and returns a geometry. The optional existing geometry is the
* geometry that is returned when the function is called without a second
* argument.
* @typedef {function(!Array.<module:ol/coordinate~Coordinate>, module:ol/geom/SimpleGeometry~SimpleGeometry=):
* module:ol/geom/SimpleGeometry~SimpleGeometry}
*/
ol.DrawGeometryFunctionType;
/**
* A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
* `{boolean}`. If the condition is met, true should be returned.
*
* @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent): boolean}
*/
ol.EventsConditionType;
/** /**
* @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined), * @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined),
* y: number, yunits: (ol.style.IconAnchorUnits|undefined), * y: number, yunits: (ol.style.IconAnchorUnits|undefined),
@@ -230,17 +201,6 @@ ol.LoadingStrategy;
ol.LRUCacheEntry; ol.LRUCacheEntry;
/**
* @typedef {{depth: (Array.<number>|undefined),
* feature: module:ol/Feature~Feature,
* geometry: module:ol/geom/SimpleGeometry~SimpleGeometry,
* index: (number),
* segment: Array.<module:ol/extent~Extent>,
* featureSegments: (Array.<ol.ModifySegmentDataType>|undefined)}}
*/
ol.ModifySegmentDataType;
/** /**
* A function that takes an array of input data, performs some operation, and * A function that takes an array of input data, performs some operation, and
* returns an array of output data. * returns an array of output data.
@@ -296,35 +256,6 @@ ol.ReprojTileFunctionType;
ol.ReprojTriangle; ol.ReprojTriangle;
/**
* A function that takes an {@link module:ol/Feature~Feature} or {@link ol.render.Feature} and
* an {@link ol.layer.Layer} and returns `true` if the feature may be selected
* or `false` otherwise.
* @typedef {function((module:ol/Feature~Feature|ol.render.Feature), ol.layer.Layer):
* boolean}
*/
ol.SelectFilterFunction;
/**
* @typedef {{
* snapped: {boolean},
* vertex: (module:ol/coordinate~Coordinate|null),
* vertexPixel: (module:ol~Pixel|null)
* }}
*/
ol.SnapResultType;
/**
* @typedef {{
* feature: module:ol/Feature~Feature,
* segment: Array.<module:ol/coordinate~Coordinate>
* }}
*/
ol.SnapSegmentDataType;
/** /**
* @typedef {{attributions: (ol.AttributionLike|undefined), * @typedef {{attributions: (ol.AttributionLike|undefined),
* extent: (null|module:ol/extent~Extent|undefined), * extent: (null|module:ol/extent~Extent|undefined),