Merge pull request #7989 from ahocevar/interaction-type
Redistribute olx types for ol/interaction
This commit is contained in:
1007
externs/olx.js
1007
externs/olx.js
File diff suppressed because it is too large
Load Diff
324
externs/xol.js
324
externs/xol.js
@@ -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
|
||||
* @property {number|undefined} opacity Opacity (0, 1). Default is `1`.
|
||||
@@ -459,7 +164,7 @@
|
||||
* rendered as vectors and can stay upright on rotated views.
|
||||
* * `'vector'`: Vector tiles are rendered as vectors. Most accurate rendering
|
||||
* even during animations, but slower performance than the other options.
|
||||
*
|
||||
*
|
||||
* When `declutter` is set to `true`, `'hybrid'` will be used instead of
|
||||
* `'image'`. The default is `'hybrid'`.
|
||||
* @property {ol.RenderOrderFunction|undefined} renderOrder Render order. Function to be used when sorting features before rendering. By
|
||||
@@ -704,7 +409,7 @@
|
||||
* access pixel data with the Canvas renderer. See
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
|
||||
* for more detail.
|
||||
*
|
||||
*
|
||||
* Default is `anonymous`.
|
||||
* @property {number|undefined} maxZoom Max zoom. Default is `19`.
|
||||
* @property {boolean|undefined} opaque Whether the layer is opaque. Default is `true`.
|
||||
@@ -984,9 +689,9 @@
|
||||
* @property {module:ol/Feature~FeatureLoader|undefined} loader The loader function used to load features, from a remote source for example.
|
||||
* If this is not set and `url` is set, the source will create and use an XHR
|
||||
* feature loader.
|
||||
*
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
*
|
||||
* ```js
|
||||
* var vectorSource = new ol.source.Vector({
|
||||
* format: new ol.format.GeoJSON(),
|
||||
@@ -1038,18 +743,18 @@
|
||||
* @property {boolean|undefined} useSpatialIndex By default, an RTree is used as spatial index. When features are removed and
|
||||
* added frequently, and the total number of features is low, setting this to
|
||||
* `false` may improve performance.
|
||||
*
|
||||
*
|
||||
* Note that
|
||||
* {@link ol.source.Vector#getFeaturesInExtent},
|
||||
* {@link ol.source.Vector#getClosestFeatureToCoordinate} and
|
||||
* {@link ol.source.Vector#getExtent} cannot be used when `useSpatialIndex` is
|
||||
* set to `false`, and {@link ol.source.Vector#forEachFeatureInExtent} will loop
|
||||
* through all features.
|
||||
*
|
||||
*
|
||||
* When set to `false`, the features will be maintained in an
|
||||
* {@link ol.Collection}, which can be retrieved through
|
||||
* {@link ol.source.Vector#getFeaturesCollection}.
|
||||
*
|
||||
*
|
||||
* The default is `true`.
|
||||
* @property {boolean|undefined} wrapX Wrap the world horizontally. Default is `true`. For vector editing across the
|
||||
* -180° and 180° meridians to work properly, this should be set to `false`. The
|
||||
@@ -1313,9 +1018,9 @@
|
||||
* Internet Explorer 10 and lower [do not support][mdn] the `setLineDash`
|
||||
* method on the `CanvasRenderingContext2D` and therefore this option will
|
||||
* have no visual effect in these browsers.
|
||||
*
|
||||
*
|
||||
* [mdn]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility
|
||||
*
|
||||
*
|
||||
* @property {number|undefined} lineDashOffset Line dash offset. Default is '0'.
|
||||
* @property {number|undefined} miterLimit Miter limit. Default is `10`.
|
||||
* @property {number|undefined} width Width.
|
||||
@@ -1369,7 +1074,7 @@
|
||||
* @property {ol.StyleRenderFunction|undefined} renderer Custom renderer. When configured, `fill`, `stroke` and `image` will be
|
||||
* ignored, and the provided function will be called with each render frame for
|
||||
* each geometry.
|
||||
*
|
||||
*
|
||||
* @property {ol.style.Stroke|undefined} stroke Stroke style.
|
||||
* @property {ol.style.Text|undefined} text Text style.
|
||||
* @property {number|undefined} zIndex Z index.
|
||||
@@ -1452,10 +1157,10 @@
|
||||
|
||||
/**
|
||||
* @typedef {Object} ViewState
|
||||
* @property {ol.Coordinate} center
|
||||
* @property {module:ol/proj/Projection~Projection} projection
|
||||
* @property {number} resolution
|
||||
* @property {number} rotation
|
||||
* @property {ol.Coordinate} center
|
||||
* @property {module:ol/proj/Projection~Projection} projection
|
||||
* @property {number} resolution
|
||||
* @property {number} rotation
|
||||
* @property {number} zoom The current zoom level.
|
||||
*/
|
||||
|
||||
@@ -1467,4 +1172,3 @@
|
||||
* `WEBGL_MAX_TEXTURE_SIZE` or 2048 if WebGL is not supported.
|
||||
* @property {number|undefined} space The space in pixels between images (default: 1).
|
||||
*/
|
||||
|
||||
|
||||
@@ -7,6 +7,14 @@ import {TRUE, FALSE} from '../functions.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
|
||||
* additionally the shift-key is pressed).
|
||||
|
||||
@@ -5,13 +5,21 @@ import {inherits} from '../index.js';
|
||||
import MapBrowserEventType from '../MapBrowserEventType.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
|
||||
* Allows the user to zoom by double-clicking on the map.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {olx.interaction.DoubleClickZoomOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @param {module:ol/interaction/DoubleClickZoom~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DoubleClickZoom = function(opt_options) {
|
||||
@@ -44,7 +52,7 @@ inherits(DoubleClickZoom, Interaction);
|
||||
* doubleclick) and eventually zooms the map.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.DoubleClickZoom}
|
||||
* @this {module:ol/interaction/DoubleClickZoom~DoubleClickZoom}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
let stopEvent = false;
|
||||
|
||||
@@ -12,13 +12,26 @@ import Interaction from '../interaction/Interaction.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}
|
||||
*/
|
||||
const DragAndDropEventType = {
|
||||
/**
|
||||
* Triggered when features are added
|
||||
* @event ol.interaction.DragAndDropEvent#addfeatures
|
||||
* @event module:ol/interaction/DragAndDrop~DragAndDropEvent#addfeatures
|
||||
* @api
|
||||
*/
|
||||
ADD_FEATURES: 'addfeatures'
|
||||
@@ -27,13 +40,13 @@ const DragAndDropEventType = {
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @implements {oli.interaction.DragAndDropEvent}
|
||||
* @param {ol.interaction.DragAndDropEventType} type Type.
|
||||
* @param {module:ol/interaction/DragAndDrop~DragAndDropEventType} type Type.
|
||||
* @param {File} file File.
|
||||
* @param {Array.<module:ol/Feature~Feature>=} opt_features Features.
|
||||
* @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.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @fires ol.interaction.DragAndDropEvent
|
||||
* @param {olx.interaction.DragAndDropOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @fires module:ol/interaction/DragAndDrop~DragAndDropEvent
|
||||
* @param {module:ol/interaction/DragAndDrop~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DragAndDrop = function(opt_options) {
|
||||
@@ -124,7 +137,7 @@ inherits(DragAndDrop, Interaction);
|
||||
|
||||
/**
|
||||
* @param {Event} event Event.
|
||||
* @this {ol.interaction.DragAndDrop}
|
||||
* @this {module:ol/interaction/DragAndDrop~DragAndDrop}
|
||||
*/
|
||||
function handleDrop(event) {
|
||||
const files = event.dataTransfer.files;
|
||||
|
||||
@@ -10,27 +10,49 @@ import PointerInteraction from '../interaction/Pointer.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}
|
||||
*/
|
||||
const DragBoxEventType = {
|
||||
/**
|
||||
* Triggered upon drag box start.
|
||||
* @event ol.interaction.DragBoxEvent#boxstart
|
||||
* @event module:ol/interaction/DragBox~DragBoxEvent#boxstart
|
||||
* @api
|
||||
*/
|
||||
BOXSTART: 'boxstart',
|
||||
|
||||
/**
|
||||
* Triggered on drag when box is active.
|
||||
* @event ol.interaction.DragBoxEvent#boxdrag
|
||||
* @event module:ol/interaction/DragBox~DragBoxEvent#boxdrag
|
||||
* @api
|
||||
*/
|
||||
BOXDRAG: 'boxdrag',
|
||||
|
||||
/**
|
||||
* Triggered upon drag box end.
|
||||
* @event ol.interaction.DragBoxEvent#boxend
|
||||
* @event module:ol/interaction/DragBox~DragBoxEvent#boxend
|
||||
* @api
|
||||
*/
|
||||
BOXEND: 'boxend'
|
||||
@@ -39,13 +61,13 @@ const DragBoxEventType = {
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @param {string} type The event type.
|
||||
* @param {module:ol/coordinate~Coordinate} coordinate The event coordinate.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Originating event.
|
||||
* @extends {ol.events.Event}
|
||||
* @extends {module:ol/events/Event~Event}
|
||||
* @constructor
|
||||
* @implements {oli.DragBoxEvent}
|
||||
*/
|
||||
@@ -75,18 +97,18 @@ inherits(DragBoxEvent, Event);
|
||||
/**
|
||||
* @classdesc
|
||||
* 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,
|
||||
* for zooming to a specific area of the map
|
||||
* (see {@link ol.interaction.DragZoom} and
|
||||
* {@link ol.interaction.DragRotateAndZoom}).
|
||||
* (see {@link module:ol/interaction/DragZoom~DragZoom} and
|
||||
* {@link module:ol/interaction/DragRotateAndZoom}).
|
||||
*
|
||||
* This interaction is only supported for mouse devices.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @fires ol.interaction.DragBoxEvent
|
||||
* @param {olx.interaction.DragBoxOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @fires module:ol/interaction/DragBox~DragBoxEvent
|
||||
* @param {module:ol/interaction/DragBox~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DragBox = function(opt_options) {
|
||||
@@ -100,7 +122,7 @@ const DragBox = function(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @type {ol.render.Box}
|
||||
* @type {module:ol/render/Box~Box}
|
||||
* @private
|
||||
*/
|
||||
this.box_ = new RenderBox(options.className || 'ol-dragbox');
|
||||
@@ -119,13 +141,13 @@ const DragBox = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : always;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.DragBoxEndConditionType}
|
||||
* @type {module:ol/interaction/DragBox~EndCondition}
|
||||
*/
|
||||
this.boxEndCondition_ = options.boxEndCondition ?
|
||||
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} endPixel The end pixel of the box.
|
||||
* @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) {
|
||||
const width = endPixel[0] - startPixel[0];
|
||||
@@ -152,8 +174,8 @@ function defaultBoxEndCondition(mapBrowserEvent, startPixel, endPixel) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragBox}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/DragBox~DragBox}
|
||||
*/
|
||||
function handleDragEvent(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?
|
||||
* @this {ol.interaction.DragBox}
|
||||
* @this {module:ol/interaction/DragBox~DragBox}
|
||||
*/
|
||||
function handleUpEvent(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?
|
||||
* @this {ol.interaction.DragBox}
|
||||
* @this {module:ol/interaction/DragBox~DragBox}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
|
||||
@@ -9,13 +9,23 @@ import {noModifierKeys} from '../events/condition.js';
|
||||
import {FALSE} from '../functions.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
|
||||
* Allows the user to pan the map by dragging the map.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.DragPanOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/DragPan~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DragPan = function(opt_options) {
|
||||
@@ -30,7 +40,7 @@ const DragPan = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Kinetic|undefined}
|
||||
* @type {module:ol/Kinetic~Kinetic|undefined}
|
||||
*/
|
||||
this.kinetic_ = options.kinetic;
|
||||
|
||||
@@ -46,7 +56,7 @@ const DragPan = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : noModifierKeys;
|
||||
|
||||
@@ -62,8 +72,8 @@ inherits(DragPan, PointerInteraction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragPan}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/DragPan~DragPan}
|
||||
*/
|
||||
function handleDragEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.DragPan}
|
||||
* @this {module:ol/interaction/DragPan~DragPan}
|
||||
*/
|
||||
function handleUpEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.DragPan}
|
||||
* @this {module:ol/interaction/DragPan~DragPan}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
|
||||
|
||||
@@ -9,17 +9,28 @@ import {FALSE} from '../functions.js';
|
||||
import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.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
|
||||
* 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.
|
||||
*
|
||||
* This interaction is only supported for mouse devices.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.DragRotateOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/DragRotate~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DragRotate = function(opt_options) {
|
||||
@@ -34,7 +45,7 @@ const DragRotate = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : altShiftKeysOnly;
|
||||
|
||||
@@ -55,8 +66,8 @@ inherits(DragRotate, PointerInteraction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragRotate}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/DragRotate~DragRotate}
|
||||
*/
|
||||
function handleDragEvent(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?
|
||||
* @this {ol.interaction.DragRotate}
|
||||
* @this {module:ol/interaction/DragRotate~DragRotate}
|
||||
*/
|
||||
function handleUpEvent(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?
|
||||
* @this {ol.interaction.DragRotate}
|
||||
* @this {module:ol/interaction/DragRotate~DragRotate}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
|
||||
@@ -8,6 +8,17 @@ import {shiftKeyOnly, mouseOnly} from '../events/condition.js';
|
||||
import {rotate, rotateWithoutConstraints, zoom, zoomWithoutConstraints} from '../interaction/Interaction.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
|
||||
* 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.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.DragRotateAndZoomOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/DragRotateAndZoom~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DragRotateAndZoom = function(opt_options) {
|
||||
@@ -35,7 +46,7 @@ const DragRotateAndZoom = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : shiftKeyOnly;
|
||||
|
||||
@@ -69,8 +80,8 @@ inherits(DragRotateAndZoom, PointerInteraction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragRotateAndZoom}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}
|
||||
*/
|
||||
function handleDragEvent(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?
|
||||
* @this {ol.interaction.DragRotateAndZoom}
|
||||
* @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}
|
||||
*/
|
||||
function handleUpEvent(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?
|
||||
* @this {ol.interaction.DragRotateAndZoom}
|
||||
* @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
|
||||
@@ -7,18 +7,32 @@ import {shiftKeyOnly} from '../events/condition.js';
|
||||
import {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.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
|
||||
* 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.
|
||||
*
|
||||
* To change the style of the box, use CSS and the `.ol-dragzoom` selector, or
|
||||
* your custom one configured with `className`.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.DragBox}
|
||||
* @param {olx.interaction.DragZoomOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/DragBox~DragBox}
|
||||
* @param {module:ol/interaction/DragZoom~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const DragZoom = function(opt_options) {
|
||||
@@ -54,7 +68,7 @@ inherits(DragZoom, DragBox);
|
||||
DragZoom.prototype.onBoxEnd = function() {
|
||||
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());
|
||||
|
||||
|
||||
@@ -29,6 +29,69 @@ import VectorSource from '../source/Vector.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
|
||||
* cousins.
|
||||
@@ -48,13 +111,13 @@ const Mode = {
|
||||
const DrawEventType = {
|
||||
/**
|
||||
* Triggered upon feature draw start
|
||||
* @event ol.interaction.Draw.Event#drawstart
|
||||
* @event module:ol/interaction/Draw~DrawEvent#drawstart
|
||||
* @api
|
||||
*/
|
||||
DRAWSTART: 'drawstart',
|
||||
/**
|
||||
* Triggered upon feature draw end
|
||||
* @event ol.interaction.Draw.Event#drawend
|
||||
* @event module:ol/interaction/Draw~DrawEvent#drawend
|
||||
* @api
|
||||
*/
|
||||
DRAWEND: 'drawend'
|
||||
@@ -63,13 +126,13 @@ const DrawEventType = {
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link ol.interaction.Draw} instances are instances of
|
||||
* this type.
|
||||
* Events emitted by {@link module:ol/interaction/Draw~Draw} instances are
|
||||
* instances of this type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @extends {module:ol/events/Event~Event}
|
||||
* @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.
|
||||
*/
|
||||
const DrawEvent = function(type, feature) {
|
||||
@@ -93,9 +156,9 @@ inherits(DrawEvent, Event);
|
||||
* Interaction for drawing feature geometries.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @fires ol.interaction.DrawEvent
|
||||
* @param {olx.interaction.DrawOptions} options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @fires module:ol/interaction/Draw~DrawEvent
|
||||
* @param {module:ol/interaction/Draw~Options} options Options.
|
||||
* @api
|
||||
*/
|
||||
const Draw = function(options) {
|
||||
@@ -138,14 +201,14 @@ const Draw = function(options) {
|
||||
|
||||
/**
|
||||
* Target source for drawn features.
|
||||
* @type {ol.source.Vector}
|
||||
* @type {module:ol/source/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
this.source_ = options.source ? options.source : null;
|
||||
|
||||
/**
|
||||
* Target collection for drawn features.
|
||||
* @type {ol.Collection.<module:ol/Feature~Feature>}
|
||||
* @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
|
||||
* @private
|
||||
*/
|
||||
this.features_ = options.features ? options.features : null;
|
||||
@@ -166,7 +229,7 @@ const Draw = function(options) {
|
||||
|
||||
/**
|
||||
* Drawing mode (derived from geometry type.
|
||||
* @type {ol.interaction.Mode}
|
||||
* @type {module:ol/interaction/Draw~Mode}
|
||||
* @private
|
||||
*/
|
||||
this.mode_ = getMode(this.type_);
|
||||
@@ -201,7 +264,7 @@ const Draw = function(options) {
|
||||
/**
|
||||
* A function to decide if a potential finish coordinate is permissible
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
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
|
||||
*/
|
||||
this.geometryFunction_ = geometryFunction;
|
||||
@@ -326,7 +389,7 @@ const Draw = function(options) {
|
||||
|
||||
/**
|
||||
* Draw overlay where our sketch features are drawn.
|
||||
* @type {ol.layer.Vector}
|
||||
* @type {module:ol/layer/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
this.overlay_ = new VectorLayer({
|
||||
@@ -348,13 +411,13 @@ const Draw = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : noModifierKeys;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.freehandCondition_;
|
||||
if (options.freehand) {
|
||||
@@ -398,7 +461,7 @@ Draw.prototype.setMap = function(map) {
|
||||
* draw or finish the drawing.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Draw}
|
||||
* @this {module:ol/interaction/Draw~Draw}
|
||||
* @api
|
||||
*/
|
||||
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?
|
||||
* @this {ol.interaction.Draw}
|
||||
* @this {module:ol/interaction/Draw~Draw}
|
||||
*/
|
||||
function handleDownEvent(event) {
|
||||
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?
|
||||
* @this {ol.interaction.Draw}
|
||||
* @this {module:ol/interaction/Draw~Draw}
|
||||
*/
|
||||
function handleUpEvent(event) {
|
||||
let pass = true;
|
||||
@@ -764,8 +827,8 @@ Draw.prototype.removeLastPoint = function() {
|
||||
|
||||
/**
|
||||
* Stop drawing and add the sketch feature to the target layer.
|
||||
* The {@link ol.interaction.DrawEventType.DRAWEND} event is dispatched before
|
||||
* inserting the feature.
|
||||
* The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is
|
||||
* dispatched before inserting the feature.
|
||||
* @api
|
||||
*/
|
||||
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.
|
||||
* Default is the angle defined by the heading from the center of the
|
||||
* 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.
|
||||
* @api
|
||||
*/
|
||||
@@ -921,7 +984,7 @@ export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
* Create a `geometryFunction` that will create a box-shaped polygon (aligned
|
||||
* with the coordinate system axes). Use this with the draw interaction and
|
||||
* `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
|
||||
*/
|
||||
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
|
||||
* their single-part cousins.
|
||||
* @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) {
|
||||
let mode;
|
||||
@@ -962,7 +1025,7 @@ function getMode(type) {
|
||||
} else if (type === GeometryType.CIRCLE) {
|
||||
mode = Mode.CIRCLE;
|
||||
}
|
||||
return /** @type {!ol.interaction.Mode} */ (mode);
|
||||
return /** @type {!module:ol/interaction/Draw~Mode} */ (mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,22 +11,51 @@ import {boundingExtent, getArea} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import Point from '../geom/Point.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 VectorLayer from '../layer/Vector.js';
|
||||
import VectorSource from '../source/Vector.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
|
||||
* Events emitted by {@link ol.interaction.Extent} instances are instances of
|
||||
* this type.
|
||||
* Events emitted by {@link module:ol/interaction/Extent~Extent} instances are
|
||||
* instances of this type.
|
||||
*
|
||||
* @constructor
|
||||
* @implements {oli.ExtentEvent}
|
||||
* @param {module:ol/extent~Extent} extent the new extent
|
||||
* @extends {ol.events.Event}
|
||||
* @extends {module:ol/events/Event~Event}
|
||||
*/
|
||||
const ExtentInteractionEvent = function(extent) {
|
||||
Event.call(this, ExtentEventType.EXTENTCHANGED);
|
||||
@@ -49,9 +78,9 @@ inherits(ExtentInteractionEvent, Event);
|
||||
* This interaction is only supported for mouse devices.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @fires ol.interaction.Extent.Event
|
||||
* @param {olx.interaction.ExtentOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @fires module:ol/interaction/Extent~Event
|
||||
* @param {module:ol/interaction/Extent~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const ExtentInteraction = function(opt_options) {
|
||||
@@ -105,7 +134,6 @@ const ExtentInteraction = function(opt_options) {
|
||||
opt_options = {};
|
||||
}
|
||||
|
||||
/* Inherit ol.interaction.Pointer */
|
||||
PointerInteraction.call(this, {
|
||||
handleDownEvent: handleDownEvent,
|
||||
handleDragEvent: handleDragEvent,
|
||||
@@ -115,7 +143,7 @@ const ExtentInteraction = function(opt_options) {
|
||||
|
||||
/**
|
||||
* Layer for the extentFeature
|
||||
* @type {ol.layer.Vector}
|
||||
* @type {module:ol/layer/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
this.extentOverlay_ = new VectorLayer({
|
||||
@@ -130,7 +158,7 @@ const ExtentInteraction = function(opt_options) {
|
||||
|
||||
/**
|
||||
* Layer for the vertexFeature
|
||||
* @type {ol.layer.Vector}
|
||||
* @type {module:ol/layer/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
this.vertexOverlay_ = new VectorLayer({
|
||||
@@ -153,7 +181,7 @@ inherits(ExtentInteraction, PointerInteraction);
|
||||
/**
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Propagate event?
|
||||
* @this {ol.interaction.Extent}
|
||||
* @this {module:ol/interaction/Extent~Extent}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.Extent}
|
||||
* @this {module:ol/interaction/Extent~Extent}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.Extent}
|
||||
* @this {module:ol/interaction/Extent~Extent}
|
||||
*/
|
||||
function handleDragEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.Extent}
|
||||
* @this {module:ol/interaction/Extent~Extent}
|
||||
*/
|
||||
function handleUpEvent(mapBrowserEvent) {
|
||||
this.pointerHandler_ = null;
|
||||
@@ -325,7 +353,7 @@ function getSegments(extent) {
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @private
|
||||
*/
|
||||
|
||||
@@ -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'
|
||||
};
|
||||
@@ -8,6 +8,20 @@ import KeyCode from '../events/KeyCode.js';
|
||||
import {noModifierKeys, targetNotEditable} from '../events/condition.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
|
||||
* 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 keyboard events are attached. By default, this is the map div,
|
||||
* though you can change this with the `keyboardEventTarget` in
|
||||
* {@link ol.Map}. `document` never loses focus but, for any other element,
|
||||
* focus will have to be on, and returned to, this element if the keys are to
|
||||
* function.
|
||||
* See also {@link ol.interaction.KeyboardZoom}.
|
||||
* {@link module:ol/Map~Map}. `document` never loses focus but, for any other
|
||||
* element, focus will have to be on, and returned to, this element if the keys
|
||||
* are to function.
|
||||
* See also {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {olx.interaction.KeyboardPanOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @param {module:ol/interaction/KeyboardPan~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const KeyboardPan = function(opt_options) {
|
||||
@@ -45,7 +59,7 @@ const KeyboardPan = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition !== undefined ?
|
||||
options.condition : this.defaultCondition_;
|
||||
@@ -73,7 +87,7 @@ inherits(KeyboardPan, Interaction);
|
||||
* pressed).
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.KeyboardPan}
|
||||
* @this {module:ol/interaction/KeyboardPan~KeyboardPan}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
let stopEvent = false;
|
||||
|
||||
@@ -6,6 +6,18 @@ import EventType from '../events/EventType.js';
|
||||
import {targetNotEditable} from '../events/condition.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
|
||||
* 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 keyboard events are attached. By default, this is the map div,
|
||||
* though you can change this with the `keyboardEventTarget` in
|
||||
* {@link ol.Map}. `document` never loses focus but, for any other element,
|
||||
* focus will have to be on, and returned to, this element if the keys are to
|
||||
* function.
|
||||
* See also {@link ol.interaction.KeyboardPan}.
|
||||
* {@link module:ol/Map~Map}. `document` never loses focus but, for any other
|
||||
* element, focus will have to be on, and returned to, this element if the keys
|
||||
* are to function.
|
||||
* See also {@link moudle:ol/interaction/KeyboardPan~KeyboardPan}.
|
||||
*
|
||||
* @constructor
|
||||
* @param {olx.interaction.KeyboardZoomOptions=} opt_options Options.
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {module:ol/interaction/KeyboardZoom~Options=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @api
|
||||
*/
|
||||
const KeyboardZoom = function(opt_options) {
|
||||
@@ -33,7 +45,7 @@ const KeyboardZoom = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : targetNotEditable;
|
||||
|
||||
@@ -60,7 +72,7 @@ inherits(KeyboardZoom, Interaction);
|
||||
* key pressed was '+' or '-').
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.KeyboardZoom}
|
||||
* @this {module:ol/interaction/KeyboardZoom~KeyboardZoom}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
let stopEvent = false;
|
||||
|
||||
@@ -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
|
||||
* Events emitted by {@link ol.interaction.Modify} instances are instances of
|
||||
* this type.
|
||||
* Events emitted by {@link module:ol/interaction/Modify~Modify} instances are
|
||||
* instances of this type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @extends {module:ol/events/Event~Event}
|
||||
* @implements {oli.ModifyEvent}
|
||||
* @param {ModifyEventType} type Type.
|
||||
* @param {ol.Collection.<module:ol/Feature~Feature>} features The features modified.
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
|
||||
* {@link ol.MapBrowserPointerEvent}.
|
||||
* @param {module:ol/Collection~Collection.<module:ol/Feature~Feature>} features
|
||||
* The features modified.
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserPointerEvent
|
||||
* Associated {@link module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent}.
|
||||
*/
|
||||
export const ModifyEvent = function(type, features, mapBrowserPointerEvent) {
|
||||
|
||||
@@ -62,7 +106,7 @@ export const ModifyEvent = function(type, features, mapBrowserPointerEvent) {
|
||||
|
||||
/**
|
||||
* The features being modified.
|
||||
* @type {ol.Collection.<module:ol/Feature~Feature>}
|
||||
* @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
|
||||
* @api
|
||||
*/
|
||||
this.features = features;
|
||||
@@ -92,9 +136,9 @@ inherits(ModifyEvent, Event);
|
||||
* for deletion, use the `deleteCondition` option.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.ModifyOptions} options Options.
|
||||
* @fires ol.interaction.ModifyEvent
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/Modify~Options} options Options.
|
||||
* @fires module:ol/interaction/Modify~ModifyEvent
|
||||
* @api
|
||||
*/
|
||||
const Modify = function(options) {
|
||||
@@ -108,7 +152,7 @@ const Modify = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
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
|
||||
*/
|
||||
this.deleteCondition_ = options.deleteCondition ?
|
||||
options.deleteCondition : this.defaultDeleteCondition_;
|
||||
|
||||
/**
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
* @private
|
||||
*/
|
||||
this.insertVertexCondition_ = options.insertVertexCondition ?
|
||||
@@ -172,7 +216,7 @@ const Modify = function(options) {
|
||||
|
||||
/**
|
||||
* Segment RTree for each layer
|
||||
* @type {ol.structs.RBush.<ol.ModifySegmentDataType>}
|
||||
* @type {module:ol/structs/RBush~RBush.<module:ol/interaction/Modify~SegmentData>}
|
||||
* @private
|
||||
*/
|
||||
this.rBush_ = new RBush();
|
||||
@@ -206,7 +250,7 @@ const Modify = function(options) {
|
||||
|
||||
/**
|
||||
* Draw overlay where sketch features are drawn.
|
||||
* @type {ol.layer.Vector}
|
||||
* @type {module:ol/layer/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
this.overlay_ = new VectorLayer({
|
||||
@@ -239,7 +283,7 @@ const Modify = function(options) {
|
||||
|
||||
|
||||
/**
|
||||
* @type {ol.source.Vector}
|
||||
* @type {module:ol/source/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
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
|
||||
*/
|
||||
this.features_ = features;
|
||||
@@ -272,7 +316,7 @@ const Modify = function(options) {
|
||||
this.handleFeatureRemove_, this);
|
||||
|
||||
/**
|
||||
* @type {ol.MapBrowserPointerEvent}
|
||||
* @type {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent}
|
||||
* @private
|
||||
*/
|
||||
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
|
||||
*/
|
||||
Modify.prototype.willModifyFeatures_ = function(evt) {
|
||||
@@ -351,10 +395,10 @@ Modify.prototype.removeFeature_ = function(feature) {
|
||||
*/
|
||||
Modify.prototype.removeFeatureSegmentData_ = function(feature) {
|
||||
const rBush = this.rBush_;
|
||||
const /** @type {Array.<ol.ModifySegmentDataType>} */ nodesToRemove = [];
|
||||
const /** @type {Array.<module:ol/interaction/Modify~SegmentData>} */ nodesToRemove = [];
|
||||
rBush.forEach(
|
||||
/**
|
||||
* @param {ol.ModifySegmentDataType} node RTree node.
|
||||
* @param {module:ol/interaction/Modify~SegmentData} node RTree node.
|
||||
*/
|
||||
function(node) {
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
Modify.prototype.handleFeatureRemove_ = function(evt) {
|
||||
@@ -449,7 +493,7 @@ Modify.prototype.handleFeatureRemove_ = function(evt) {
|
||||
*/
|
||||
Modify.prototype.writePointGeometry_ = function(feature, geometry) {
|
||||
const coordinates = geometry.getCoordinates();
|
||||
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
segment: [coordinates, coordinates]
|
||||
@@ -467,7 +511,7 @@ Modify.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
|
||||
const points = geometry.getCoordinates();
|
||||
for (let i = 0, ii = points.length; i < ii; ++i) {
|
||||
const coordinates = points[i];
|
||||
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
depth: [i],
|
||||
@@ -488,7 +532,7 @@ Modify.prototype.writeLineStringGeometry_ = function(feature, geometry) {
|
||||
const coordinates = geometry.getCoordinates();
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
index: i,
|
||||
@@ -510,7 +554,7 @@ Modify.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
|
||||
const coordinates = lines[j];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
depth: [j],
|
||||
@@ -534,7 +578,7 @@ Modify.prototype.writePolygonGeometry_ = function(feature, geometry) {
|
||||
const coordinates = rings[j];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
depth: [j],
|
||||
@@ -560,7 +604,7 @@ Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
|
||||
const coordinates = rings[j];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
depth: [j, k],
|
||||
@@ -587,13 +631,13 @@ Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
|
||||
*/
|
||||
Modify.prototype.writeCircleGeometry_ = function(feature, geometry) {
|
||||
const coordinates = geometry.getCenter();
|
||||
const centerSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const centerSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
index: CIRCLE_CENTER_INDEX,
|
||||
segment: [coordinates, coordinates]
|
||||
});
|
||||
const circumferenceSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const circumferenceSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
index: CIRCLE_CIRCUMFERENCE_INDEX,
|
||||
@@ -639,8 +683,8 @@ Modify.prototype.createOrUpdateVertexFeature_ = function(coordinates) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.ModifySegmentDataType} a The first segment data.
|
||||
* @param {ol.ModifySegmentDataType} b The second segment data.
|
||||
* @param {module:ol/interaction/Modify~SegmentData} a The first segment data.
|
||||
* @param {module:ol/interaction/Modify~SegmentData} b The second segment data.
|
||||
* @return {number} The difference in indexes.
|
||||
*/
|
||||
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?
|
||||
* @this {ol.interaction.Modify}
|
||||
* @this {module:ol/interaction/Modify~Modify}
|
||||
*/
|
||||
function handleDownEvent(evt) {
|
||||
if (!this.condition_(evt)) {
|
||||
@@ -725,8 +769,8 @@ function handleDownEvent(evt) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} evt Event.
|
||||
* @this {ol.interaction.Modify}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event.
|
||||
* @this {module:ol/interaction/Modify~Modify}
|
||||
*/
|
||||
function handleDragEvent(evt) {
|
||||
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?
|
||||
* @this {ol.interaction.Modify}
|
||||
* @this {module:ol/interaction/Modify~Modify}
|
||||
*/
|
||||
function handleUpEvent(evt) {
|
||||
for (let i = this.dragSegments_.length - 1; i >= 0; --i) {
|
||||
@@ -835,7 +879,7 @@ function handleUpEvent(evt) {
|
||||
* geometry.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Modify}
|
||||
* @this {module:ol/interaction/Modify~Modify}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
|
||||
@@ -877,7 +921,7 @@ Modify.prototype.handlePointerMove_ = function(evt) {
|
||||
|
||||
/**
|
||||
* @param {module:ol~Pixel} pixel Pixel
|
||||
* @param {ol.PluggableMap} map Map.
|
||||
* @param {module:ol/PluggableMap~PluggableMap} map Map.
|
||||
* @private
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
* @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
|
||||
* 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.
|
||||
* @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.
|
||||
* @private
|
||||
*/
|
||||
@@ -1031,7 +1075,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
||||
const rTree = this.rBush_;
|
||||
rTree.remove(segmentData);
|
||||
this.updateSegmentIndices_(geometry, index, depth, 1);
|
||||
const newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const newSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
segment: [segment[0], vertex],
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
@@ -1042,7 +1086,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
||||
newSegmentData);
|
||||
this.dragSegments_.push([newSegmentData, 1]);
|
||||
|
||||
const newSegmentData2 = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const newSegmentData2 = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
segment: [vertex, segment[1]],
|
||||
feature: feature,
|
||||
geometry: geometry,
|
||||
@@ -1167,7 +1211,7 @@ Modify.prototype.removeVertex_ = function() {
|
||||
segments.push(right.segment[1]);
|
||||
}
|
||||
if (left !== undefined && right !== undefined) {
|
||||
const newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||
const newSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({
|
||||
depth: segmentData.depth,
|
||||
feature: segmentData.feature,
|
||||
geometry: segmentData.geometry,
|
||||
|
||||
@@ -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
|
||||
* Allows the user to zoom the map by scrolling the mouse wheel.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @param {module:ol/interaction/MouseWheelZoom~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const MouseWheelZoom = function(opt_options) {
|
||||
@@ -76,7 +93,7 @@ const MouseWheelZoom = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : always;
|
||||
|
||||
@@ -100,7 +117,7 @@ const MouseWheelZoom = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.Mode|undefined}
|
||||
* @type {module:ol/interaction/MouseWheelZoom~Mode|undefined}
|
||||
*/
|
||||
this.mode_ = undefined;
|
||||
|
||||
@@ -140,7 +157,7 @@ inherits(MouseWheelZoom, Interaction);
|
||||
* mousewheel-event) and eventually zooms the map.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} Allow event propagation.
|
||||
* @this {ol.interaction.MouseWheelZoom}
|
||||
* @this {module:ol/interaction/MouseWheelZoom~MouseWheelZoom}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
if (!this.condition_(mapBrowserEvent)) {
|
||||
@@ -271,7 +288,7 @@ MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {ol.PluggableMap} map Map.
|
||||
* @param {module:ol/PluggableMap~PluggableMap} map Map.
|
||||
*/
|
||||
MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
|
||||
const view = map.getView();
|
||||
|
||||
@@ -8,14 +8,23 @@ import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js';
|
||||
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.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
|
||||
* Allows the user to rotate the map by twisting with two fingers
|
||||
* on a touch screen.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.PinchRotateOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/PinchRotate~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const PinchRotate = function(opt_options) {
|
||||
@@ -70,8 +79,8 @@ inherits(PinchRotate, PointerInteraction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.PinchRotate}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/PinchRotate~PinchRotate}
|
||||
*/
|
||||
function handleDragEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.PinchRotate}
|
||||
* @this {module:ol/interaction/PinchRotate~PinchRotate}
|
||||
*/
|
||||
function handleUpEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.PinchRotate}
|
||||
* @this {module:ol/interaction/PinchRotate~PinchRotate}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
if (this.targetPointers.length >= 2) {
|
||||
|
||||
@@ -7,14 +7,23 @@ import {FALSE} from '../functions.js';
|
||||
import {zoom, zoomWithoutConstraints} from '../interaction/Interaction.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
|
||||
* Allows the user to zoom the map by pinching with two fingers
|
||||
* on a touch screen.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.PinchZoomOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/PinchZoom~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const PinchZoom = function(opt_options) {
|
||||
@@ -63,8 +72,8 @@ inherits(PinchZoom, PointerInteraction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.PinchZoom}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/PinchZoom~PinchZoom}
|
||||
*/
|
||||
function handleDragEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.PinchZoom}
|
||||
* @this {module:ol/interaction/PinchZoom~PinchZoom}
|
||||
*/
|
||||
function handleUpEvent(mapBrowserEvent) {
|
||||
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?
|
||||
* @this {ol.interaction.PinchZoom}
|
||||
* @this {module:ol/interaction/PinchZoom~PinchZoom}
|
||||
*/
|
||||
function handleDownEvent(mapBrowserEvent) {
|
||||
if (this.targetPointers.length >= 2) {
|
||||
|
||||
@@ -10,35 +10,58 @@ import {getValues} from '../obj.js';
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.Pointer}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/Pointer~Pointer}
|
||||
*/
|
||||
const handleDragEvent = UNDEFINED;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Capture dragging.
|
||||
* @this {ol.interaction.Pointer}
|
||||
* @this {module:ol/interaction/Pointer~Pointer}
|
||||
*/
|
||||
const handleUpEvent = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Capture dragging.
|
||||
* @this {ol.interaction.Pointer}
|
||||
* @this {module:ol/interaction/Pointer~Pointer}
|
||||
*/
|
||||
const handleDownEvent = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.Pointer}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {module:ol/interaction/Pointer~Pointer}
|
||||
*/
|
||||
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
|
||||
* 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`.
|
||||
*
|
||||
* @constructor
|
||||
* @param {olx.interaction.PointerOptions=} opt_options Options.
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {module:ol/interaction/Pointer~Options=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @api
|
||||
*/
|
||||
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
|
||||
*/
|
||||
this.handleDownEvent_ = options.handleDownEvent ?
|
||||
options.handleDownEvent : handleDownEvent;
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent)}
|
||||
* @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent)}
|
||||
* @private
|
||||
*/
|
||||
this.handleDragEvent_ = options.handleDragEvent ?
|
||||
options.handleDragEvent : handleDragEvent;
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent)}
|
||||
* @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent)}
|
||||
* @private
|
||||
*/
|
||||
this.handleMoveEvent_ = options.handleMoveEvent ?
|
||||
options.handleMoveEvent : handleMoveEvent;
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent):boolean}
|
||||
* @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean}
|
||||
* @private
|
||||
*/
|
||||
this.handleUpEvent_ = options.handleUpEvent ?
|
||||
@@ -97,13 +120,13 @@ const PointerInteraction = function(opt_options) {
|
||||
this.handlingDownUpSequence = false;
|
||||
|
||||
/**
|
||||
* @type {!Object.<string, ol.pointer.PointerEvent>}
|
||||
* @type {!Object.<string, module:ol/pointer/PointerEvent~PointerEvent>}
|
||||
* @private
|
||||
*/
|
||||
this.trackedPointers_ = {};
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.pointer.PointerEvent>}
|
||||
* @type {Array.<module:ol/pointer/PointerEvent~PointerEvent>}
|
||||
* @protected
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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
|
||||
* or pointerup event.
|
||||
*/
|
||||
@@ -143,7 +166,7 @@ function isPointerDraggingEvent(mapBrowserEvent) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @private
|
||||
*/
|
||||
PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent) {
|
||||
@@ -171,7 +194,7 @@ PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent)
|
||||
* detected.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Pointer}
|
||||
* @this {module:ol/interaction/Pointer~Pointer}
|
||||
* @api
|
||||
*/
|
||||
export function handleEvent(mapBrowserEvent) {
|
||||
|
||||
@@ -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
|
||||
* 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.
|
||||
*
|
||||
* @param {SelectEventType} type The event type.
|
||||
@@ -40,7 +108,7 @@ const SelectEventType = {
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Associated
|
||||
* {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
||||
* @implements {oli.SelectEvent}
|
||||
* @extends {ol.events.Event}
|
||||
* @extends {module:ol/events/Event~Event}
|
||||
* @constructor
|
||||
*/
|
||||
const SelectEvent = function(type, selected, deselected, mapBrowserEvent) {
|
||||
@@ -84,8 +152,8 @@ inherits(SelectEvent, Event);
|
||||
* Selected features are added to an internal unmanaged layer.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {olx.interaction.SelectOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Interaction~Interaction}
|
||||
* @param {module:ol/interaction/Select~Options=} opt_options Options.
|
||||
* @fires SelectEvent
|
||||
* @api
|
||||
*/
|
||||
@@ -99,25 +167,25 @@ const Select = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : singleClick;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.addCondition_ = options.addCondition ? options.addCondition : never;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.removeCondition_ = options.removeCondition ? options.removeCondition : never;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
* @type {module:ol/events/condition~Condition}
|
||||
*/
|
||||
this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly;
|
||||
|
||||
@@ -129,7 +197,7 @@ const Select = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.SelectFilterFunction}
|
||||
* @type {module:ol/interaction/Select~FilterFunction}
|
||||
*/
|
||||
this.filter_ = options.filter ? options.filter : TRUE;
|
||||
|
||||
@@ -153,11 +221,11 @@ const Select = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.layer.Vector}
|
||||
* @type {module:ol/layer/Vector~Vector}
|
||||
*/
|
||||
this.featureOverlay_ = featureOverlay;
|
||||
|
||||
/** @type {function(ol.layer.Layer): boolean} */
|
||||
/** @type {function(module:ol/layer/Layer~Layer): boolean} */
|
||||
let layerFilter;
|
||||
if (options.layers) {
|
||||
if (typeof options.layers === 'function') {
|
||||
@@ -174,7 +242,7 @@ const Select = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {function(ol.layer.Layer): boolean}
|
||||
* @type {function(module:ol/layer/Layer~Layer): boolean}
|
||||
*/
|
||||
this.layerFilter_ = layerFilter;
|
||||
|
||||
@@ -182,7 +250,7 @@ const Select = function(opt_options) {
|
||||
* An association between selected feature (key)
|
||||
* and layer (value)
|
||||
* @private
|
||||
* @type {Object.<number, ol.layer.Layer>}
|
||||
* @type {Object.<number, module:ol/layer/Layer~Layer>}
|
||||
*/
|
||||
this.featureLayerAssociation_ = {};
|
||||
|
||||
@@ -198,8 +266,8 @@ inherits(Select, Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature.
|
||||
* @param {ol.layer.Layer} layer Layer.
|
||||
* @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
|
||||
* @param {module:ol/layer/Layer~Layer} layer Layer.
|
||||
* @private
|
||||
*/
|
||||
Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
|
||||
@@ -210,7 +278,7 @@ Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
* programmatic method like pushing features to
|
||||
* {@link ol.interaction.Select#getFeatures collection}.
|
||||
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature
|
||||
* @return {ol.layer.Vector} Layer.
|
||||
* {@link module:ol/interaction/Select~Select#getFeatures collection}.
|
||||
* @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature
|
||||
* @return {module:ol/layer/Vector~Vector} Layer.
|
||||
* @api
|
||||
*/
|
||||
Select.prototype.getLayer = function(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.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Select}
|
||||
* @this {module:ol/interaction/Select~Select}
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
if (!this.condition_(mapBrowserEvent)) {
|
||||
@@ -270,8 +338,8 @@ function handleEvent(mapBrowserEvent) {
|
||||
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
|
||||
(
|
||||
/**
|
||||
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature.
|
||||
* @param {ol.layer.Layer} layer Layer.
|
||||
* @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
|
||||
* @param {module:ol/layer/Layer~Layer} layer Layer.
|
||||
* @return {boolean|undefined} Continue to iterate over the features.
|
||||
*/
|
||||
function(feature, layer) {
|
||||
@@ -303,8 +371,8 @@ function handleEvent(mapBrowserEvent) {
|
||||
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
|
||||
(
|
||||
/**
|
||||
* @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature.
|
||||
* @param {ol.layer.Layer} layer Layer.
|
||||
* @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature.
|
||||
* @param {module:ol/layer/Layer~Layer} layer Layer.
|
||||
* @return {boolean|undefined} Continue to iterate over the features.
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* @api
|
||||
*/
|
||||
@@ -388,7 +456,7 @@ function getDefaultStyleFunction() {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.CollectionEvent} evt Event.
|
||||
* @param {module:ol/Collection~CollectionEvent} evt Event.
|
||||
* @private
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
Select.prototype.removeFeatureLayerAssociation_ = function(feature) {
|
||||
|
||||
@@ -17,10 +17,37 @@ import {VectorSourceEvent} from '../source/Vector.js';
|
||||
import VectorEventType from '../source/VectorEventType.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
|
||||
* 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
|
||||
* with the features using the mouse can benefit from the snapping, as long
|
||||
* as it is added before.
|
||||
@@ -30,13 +57,15 @@ import RBush from '../structs/RBush.js';
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* var snap = new ol.interaction.Snap({
|
||||
* import Snap from 'ol/interaction/Snap';
|
||||
*
|
||||
* var snap = new Snap({
|
||||
* source: source
|
||||
* });
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.SnapOptions=} opt_options Options.
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @param {module:ol/interaction/Snap~Options=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
const Snap = function(opt_options) {
|
||||
@@ -50,7 +79,7 @@ const Snap = function(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @type {ol.source.Vector}
|
||||
* @type {module:ol/source/Vector~Vector}
|
||||
* @private
|
||||
*/
|
||||
this.source_ = options.source ? options.source : null;
|
||||
@@ -68,7 +97,7 @@ const Snap = function(opt_options) {
|
||||
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
|
||||
*/
|
||||
this.features_ = options.features ? options.features : null;
|
||||
@@ -117,7 +146,7 @@ const Snap = function(opt_options) {
|
||||
options.pixelTolerance : 10;
|
||||
|
||||
/**
|
||||
* @type {function(ol.SnapSegmentDataType, ol.SnapSegmentDataType): number}
|
||||
* @type {function(module:ol/interaction/Snap~SegmentData, module:ol/interaction/Snap~SegmentData): number}
|
||||
* @private
|
||||
*/
|
||||
this.sortByDistance_ = sortByDistance.bind(this);
|
||||
@@ -125,7 +154,7 @@ const Snap = function(opt_options) {
|
||||
|
||||
/**
|
||||
* Segment RTree for each layer
|
||||
* @type {ol.structs.RBush.<ol.SnapSegmentDataType>}
|
||||
* @type {module:ol/structs/RBush~RBush.<module:ol/interaction/Snap~SegmentData>}
|
||||
* @private
|
||||
*/
|
||||
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
|
||||
*/
|
||||
Snap.prototype.getFeatures_ = function() {
|
||||
@@ -209,12 +238,12 @@ Snap.prototype.getFeatures_ = function() {
|
||||
} else if (this.source_) {
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
Snap.prototype.handleFeatureChange_ = function(evt) {
|
||||
@@ -336,8 +365,8 @@ Snap.prototype.shouldStopEvent = FALSE;
|
||||
/**
|
||||
* @param {module:ol~Pixel} pixel Pixel
|
||||
* @param {module:ol/coordinate~Coordinate} pixelCoordinate Coordinate
|
||||
* @param {ol.PluggableMap} map Map.
|
||||
* @return {ol.SnapResultType} Snap result
|
||||
* @param {module:ol/PluggableMap~PluggableMap} map Map.
|
||||
* @return {module:ol/interaction/Snap~Result} Snap result
|
||||
*/
|
||||
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])];
|
||||
}
|
||||
}
|
||||
return /** @type {ol.SnapResultType} */ ({
|
||||
return /** @type {module:ol/interaction/Snap~Result} */ ({
|
||||
snapped: snapped,
|
||||
vertex: vertex,
|
||||
vertexPixel: vertexPixel
|
||||
@@ -436,7 +465,7 @@ Snap.prototype.writeCircleGeometry_ = function(feature, geometry) {
|
||||
const coordinates = polygon.getCoordinates()[0];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: segment
|
||||
});
|
||||
@@ -470,7 +499,7 @@ Snap.prototype.writeLineStringGeometry_ = function(feature, geometry) {
|
||||
const coordinates = geometry.getCoordinates();
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: segment
|
||||
});
|
||||
@@ -490,7 +519,7 @@ Snap.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) {
|
||||
const coordinates = lines[j];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: segment
|
||||
});
|
||||
@@ -509,7 +538,7 @@ Snap.prototype.writeMultiPointGeometry_ = function(feature, geometry) {
|
||||
const points = geometry.getCoordinates();
|
||||
for (let i = 0, ii = points.length; i < ii; ++i) {
|
||||
const coordinates = points[i];
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: [coordinates, coordinates]
|
||||
});
|
||||
@@ -531,7 +560,7 @@ Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
|
||||
const coordinates = rings[j];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: segment
|
||||
});
|
||||
@@ -549,7 +578,7 @@ Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) {
|
||||
*/
|
||||
Snap.prototype.writePointGeometry_ = function(feature, geometry) {
|
||||
const coordinates = geometry.getCoordinates();
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: [coordinates, coordinates]
|
||||
});
|
||||
@@ -568,7 +597,7 @@ Snap.prototype.writePolygonGeometry_ = function(feature, geometry) {
|
||||
const coordinates = rings[j];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
const segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
|
||||
feature: feature,
|
||||
segment: segment
|
||||
});
|
||||
@@ -582,7 +611,7 @@ Snap.prototype.writePolygonGeometry_ = function(feature, geometry) {
|
||||
* Handle all pointer events events.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt A move event.
|
||||
* @return {boolean} Pass the event to other interactions.
|
||||
* @this {ol.interaction.Snap}
|
||||
* @this {module:ol/interaction/Snap~Snap}
|
||||
*/
|
||||
export function handleEvent(evt) {
|
||||
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?
|
||||
* @this {ol.interaction.Snap}
|
||||
* @this {module:ol/interaction/Snap~Snap}
|
||||
*/
|
||||
function handleUpEvent(evt) {
|
||||
const featuresToUpdate = getValues(this.pendingFeatures_);
|
||||
@@ -611,10 +640,10 @@ function handleUpEvent(evt) {
|
||||
|
||||
/**
|
||||
* Sort segments by distance, helper function
|
||||
* @param {ol.SnapSegmentDataType} a The first segment data.
|
||||
* @param {ol.SnapSegmentDataType} b The second segment data.
|
||||
* @param {module:ol/interaction/Snap~SegmentData} a The first segment data.
|
||||
* @param {module:ol/interaction/Snap~SegmentData} b The second segment data.
|
||||
* @return {number} The difference in distance.
|
||||
* @this {ol.interaction.Snap}
|
||||
* @this {module:ol/interaction/Snap~Snap}
|
||||
*/
|
||||
function sortByDistance(a, b) {
|
||||
const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment);
|
||||
|
||||
@@ -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
|
||||
* Events emitted by {@link ol.interaction.Translate} instances are instances of
|
||||
* this type.
|
||||
* Events emitted by {@link module:ol/interaction/Translate~Translate} instances
|
||||
* are instances of this type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @extends {module:ol/events/Event~Event}
|
||||
* @implements {oli.interaction.TranslateEvent}
|
||||
* @param {ol.interaction.TranslateEventType} type Type.
|
||||
* @param {ol.Collection.<module:ol/Feature~Feature>} features The features translated.
|
||||
* @param {module:ol/interaction/Translate~TranslateEventType} type Type.
|
||||
* @param {module:ol/Collection~Collection.<module:ol/Feature~Feature>} features The features translated.
|
||||
* @param {module:ol/coordinate~Coordinate} coordinate The event coordinate.
|
||||
*/
|
||||
export const TranslateEvent = function(type, features, coordinate) {
|
||||
@@ -55,7 +70,7 @@ export const TranslateEvent = function(type, features, coordinate) {
|
||||
|
||||
/**
|
||||
* The features being translated.
|
||||
* @type {ol.Collection.<module:ol/Feature~Feature>}
|
||||
* @type {module:ol/Collection~Collection.<module:ol/Feature~Feature>}
|
||||
* @api
|
||||
*/
|
||||
this.features = features;
|
||||
@@ -77,8 +92,8 @@ inherits(TranslateEvent, Event);
|
||||
* Interaction for translating (moving) features.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @fires ol.interaction.TranslateEvent
|
||||
* @extends {module:ol/interaction/Pointer~Pointer}
|
||||
* @fires module:ol/interaction/Translate~TranslateEvent
|
||||
* @param {olx.interaction.TranslateOptions=} opt_options Options.
|
||||
* @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
|
||||
*/
|
||||
this.features_ = options.features !== undefined ? options.features : null;
|
||||
|
||||
/** @type {function(ol.layer.Layer): boolean} */
|
||||
/** @type {function(module:ol/layer/Layer~Layer): boolean} */
|
||||
let layerFilter;
|
||||
if (options.layers) {
|
||||
if (typeof options.layers === 'function') {
|
||||
@@ -123,7 +138,7 @@ const Translate = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {function(ol.layer.Layer): boolean}
|
||||
* @type {function(module:ol/layer/Layer~Layer): boolean}
|
||||
*/
|
||||
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?
|
||||
* @this {ol.interaction.Translate}
|
||||
* @this {module:ol/interaction/Translate~Translate}
|
||||
*/
|
||||
function handleDownEvent(event) {
|
||||
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?
|
||||
* @this {ol.interaction.Translate}
|
||||
* @this {module:ol/interaction/Translate~Translate}
|
||||
*/
|
||||
function handleUpEvent(event) {
|
||||
if (this.lastCoordinate_) {
|
||||
@@ -194,8 +209,8 @@ function handleUpEvent(event) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} event Event.
|
||||
* @this {ol.interaction.Translate}
|
||||
* @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event.
|
||||
* @this {module:ol/interaction/Translate~Translate}
|
||||
*/
|
||||
function handleDragEvent(event) {
|
||||
if (this.lastCoordinate_) {
|
||||
@@ -222,7 +237,7 @@ function handleDragEvent(event) {
|
||||
|
||||
/**
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Event.
|
||||
* @this {ol.interaction.Translate}
|
||||
* @this {module:ol/interaction/Translate~Translate}
|
||||
*/
|
||||
function handleMoveEvent(event) {
|
||||
const elem = event.map.getViewport();
|
||||
@@ -242,7 +257,7 @@ function handleMoveEvent(event) {
|
||||
* Tests to see if the given coordinates intersects any of our selected
|
||||
* features.
|
||||
* @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
|
||||
* coordinates.
|
||||
* @private
|
||||
@@ -301,7 +316,7 @@ Translate.prototype.handleActiveChanged_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.PluggableMap} oldMap Old map.
|
||||
* @param {module:ol/PluggableMap~PluggableMap} oldMap Old map.
|
||||
* @private
|
||||
*/
|
||||
Translate.prototype.updateState_ = function(oldMap) {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @namespace ol.interaction
|
||||
*/
|
||||
@@ -35,8 +35,8 @@ import SourceState from '../source/State.js';
|
||||
* displayed, irrespective of the source of that data.
|
||||
*
|
||||
* Layers are usually added to a map with {@link ol.Map#addLayer}. Components
|
||||
* like {@link ol.interaction.Select} use unmanaged layers internally. These
|
||||
* unmanaged layers are associated with the map using
|
||||
* like {@link module:ol/interaction/Select~Select} use unmanaged layers
|
||||
* internally. These unmanaged layers are associated with the map using
|
||||
* {@link ol.layer.Layer#setMap} instead.
|
||||
*
|
||||
* A generic `change` event is fired when the state of the source changes.
|
||||
|
||||
@@ -153,35 +153,6 @@ ol.CircleRenderOptions;
|
||||
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),
|
||||
* y: number, yunits: (ol.style.IconAnchorUnits|undefined),
|
||||
@@ -230,17 +201,6 @@ ol.LoadingStrategy;
|
||||
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
|
||||
* returns an array of output data.
|
||||
@@ -296,35 +256,6 @@ ol.ReprojTileFunctionType;
|
||||
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),
|
||||
* extent: (null|module:ol/extent~Extent|undefined),
|
||||
|
||||
Reference in New Issue
Block a user