diff --git a/src/ol/MapBrowserEventHandler.js b/src/ol/MapBrowserEventHandler.js index dd950f0488..4254838045 100644 --- a/src/ol/MapBrowserEventHandler.js +++ b/src/ol/MapBrowserEventHandler.js @@ -140,6 +140,7 @@ class MapBrowserEventHandler extends EventTarget { } else { // click this.clickTimeoutId_ = setTimeout( + /** @this {MapBrowserEventHandler} */ function () { this.clickTimeoutId_ = undefined; const newEvent = new MapBrowserEvent( diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index d02777b09a..26ec858de6 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -187,7 +187,7 @@ class PluggableMap extends BaseObject { /** * @private */ - this.animationDelay_ = function () { + this.animationDelay_ = /** @this {PluggableMap} */ function () { this.animationDelayKey_ = undefined; this.renderFrame_(Date.now()); }.bind(this); diff --git a/src/ol/interaction/Draw.js b/src/ol/interaction/Draw.js index dd6281a343..dc861c4131 100644 --- a/src/ol/interaction/Draw.js +++ b/src/ol/interaction/Draw.js @@ -109,8 +109,8 @@ import {squaredDistance as squaredCoordinateDistance} from '../coordinate.js'; * and a projection 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(!SketchCoordType, import("../geom/SimpleGeometry.js").default=, - * import("../proj/Projection.js").default=): + * @typedef {function(!SketchCoordType, import("../geom/SimpleGeometry.js").default, + * import("../proj/Projection.js").default): * import("../geom/SimpleGeometry.js").default} GeometryFunction */ @@ -299,13 +299,13 @@ class Draw extends PointerInteraction { if (this.type_ === GeometryType.CIRCLE) { /** * @param {!LineCoordType} coordinates The coordinates. - * @param {import("../geom/SimpleGeometry.js").default=} opt_geometry Optional geometry. + * @param {import("../geom/SimpleGeometry.js").default|undefined} geometry Optional geometry. * @param {import("../proj/Projection.js").default} projection The view projection. * @return {import("../geom/SimpleGeometry.js").default} A geometry. */ - geometryFunction = function (coordinates, opt_geometry, projection) { - const circle = opt_geometry - ? /** @type {Circle} */ (opt_geometry) + geometryFunction = function (coordinates, geometry, projection) { + const circle = geometry + ? /** @type {Circle} */ (geometry) : new Circle([NaN, NaN]); const center = fromUserCoordinate(coordinates[0], projection); const squaredLength = squaredCoordinateDistance( @@ -331,12 +331,11 @@ class Draw extends PointerInteraction { } /** * @param {!LineCoordType} coordinates The coordinates. - * @param {import("../geom/SimpleGeometry.js").default=} opt_geometry Optional geometry. + * @param {import("../geom/SimpleGeometry.js").default|undefined} geometry Optional geometry. * @param {import("../proj/Projection.js").default} projection The view projection. * @return {import("../geom/SimpleGeometry.js").default} A geometry. */ - geometryFunction = function (coordinates, opt_geometry, projection) { - let geometry = opt_geometry; + geometryFunction = function (coordinates, geometry, projection) { if (geometry) { if (mode === Mode.POLYGON) { if (coordinates[0].length) { diff --git a/src/ol/renderer/canvas/VectorLayer.js b/src/ol/renderer/canvas/VectorLayer.js index 96c7ab4deb..872a9e513a 100644 --- a/src/ol/renderer/canvas/VectorLayer.js +++ b/src/ol/renderer/canvas/VectorLayer.js @@ -338,7 +338,11 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer { */ getFeatures(pixel) { return new Promise( - function (resolve, reject) { + /** + * @param {function(Array): void} resolve Resolver function. + * @this {CanvasVectorLayerRenderer} + */ + function (resolve) { if (!this.hitDetectionImageData_ && !this.animatingOrInteracting_) { const size = [this.context.canvas.width, this.context.canvas.height]; apply(this.pixelTransform, size); @@ -622,28 +626,29 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer { const squaredTolerance = getSquaredRenderTolerance(resolution, pixelRatio); - /** - * @param {import("../../Feature.js").default} feature Feature. - * @this {CanvasVectorLayerRenderer} - */ - const render = function (feature) { - let styles; - const styleFunction = - feature.getStyleFunction() || vectorLayer.getStyleFunction(); - if (styleFunction) { - styles = styleFunction(feature, resolution); - } - if (styles) { - const dirty = this.renderFeature( - feature, - squaredTolerance, - styles, - replayGroup, - userTransform - ); - this.dirty_ = this.dirty_ || dirty; - } - }.bind(this); + const render = + /** + * @param {import("../../Feature.js").default} feature Feature. + * @this {CanvasVectorLayerRenderer} + */ + function (feature) { + let styles; + const styleFunction = + feature.getStyleFunction() || vectorLayer.getStyleFunction(); + if (styleFunction) { + styles = styleFunction(feature, resolution); + } + if (styles) { + const dirty = this.renderFeature( + feature, + squaredTolerance, + styles, + replayGroup, + userTransform + ); + this.dirty_ = this.dirty_ || dirty; + } + }.bind(this); const userExtent = toUserExtent(extent, projection); /** @type {Array} */ diff --git a/src/ol/renderer/webgl/PointsLayer.js b/src/ol/renderer/webgl/PointsLayer.js index da3d9dcb11..a756fbb02e 100644 --- a/src/ol/renderer/webgl/PointsLayer.js +++ b/src/ol/renderer/webgl/PointsLayer.js @@ -267,6 +267,10 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer { this.worker_ = createWebGLWorker(); this.worker_.addEventListener( 'message', + /** + * @param {*} event Event. + * @this {WebGLPointsLayerRenderer} + */ function (event) { const received = event.data; if (received.type === WebGLWorkerMessageType.GENERATE_BUFFERS) { diff --git a/src/ol/resolutionconstraint.js b/src/ol/resolutionconstraint.js index 0df73d9671..461c0b1f1f 100644 --- a/src/ol/resolutionconstraint.js +++ b/src/ol/resolutionconstraint.js @@ -13,7 +13,7 @@ import {linearFindNearest} from './array.js'; * Returns a modified resolution taking into account the viewport size and maximum * allowed extent. * @param {number} resolution Resolution - * @param {import("./extent.js").Extent=} maxExtent Maximum allowed extent. + * @param {import("./extent.js").Extent} maxExtent Maximum allowed extent. * @param {import("./size.js").Size} viewportSize Viewport size. * @param {boolean} showFullExtent Whether to show the full extent. * @return {number} Capped resolution.