diff --git a/externs/olx.js b/externs/olx.js index 06bcb88675..846ac32599 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -49,601 +49,4 @@ olx.render.State.prototype.resolution; olx.render.State.prototype.rotation; -/** - * @typedef {{fill: (module:ol/style/Fill~Fill|undefined), - * radius: number, - * snapToPixel: (boolean|undefined), - * stroke: (module:ol/style/Stroke~Stroke|undefined), - * atlasManager: (module:ol/style/AtlasManager~AtlasManager|undefined)}} - */ -olx.style.CircleOptions; - - -/** - * Fill style. - * @type {module:ol/style/Fill~Fill|undefined} - * @api - */ -olx.style.CircleOptions.prototype.fill; - - -/** - * Circle radius. - * @type {number} - * @api - */ -olx.style.CircleOptions.prototype.radius; - - -/** - * If `true` integral numbers of pixels are used as the X and Y pixel - * coordinate when drawing the circle in the output canvas. If `false` - * fractional numbers may be used. Using `true` allows for "sharp" - * rendering (no blur), while using `false` allows for "accurate" - * rendering. Note that accuracy is important if the circle's - * position is animated. Without it, the circle may jitter noticeably. - * Default value is `true`. - * @type {boolean|undefined} - * @api - */ -olx.style.CircleOptions.prototype.snapToPixel; - - -/** - * Stroke style. - * @type {module:ol/style/Stroke~Stroke|undefined} - * @api - */ -olx.style.CircleOptions.prototype.stroke; - - -/** - * The atlas manager to use for this circle. When using WebGL it is - * recommended to use an atlas manager to avoid texture switching. - * If an atlas manager is given, the circle is added to an atlas. - * By default no atlas manager is used. - * @type {module:ol/style/AtlasManager~AtlasManager|undefined} - */ -olx.style.CircleOptions.prototype.atlasManager; - - -/** - * @typedef {{anchor: (Array.|undefined), - * anchorOrigin: (module:ol/style/IconOrigin~IconOrigin|undefined), - * anchorXUnits: (module:ol/style/IconAnchorUnits~IconAnchorUnits|undefined), - * anchorYUnits: (module:ol/style/IconAnchorUnits~IconAnchorUnits|undefined), - * color: (ol.Color|string|undefined), - * crossOrigin: (null|string|undefined), - * img: (Image|HTMLCanvasElement|undefined), - * offset: (Array.|undefined), - * offsetOrigin: (module:ol/style/IconOrigin~IconOrigin|undefined), - * opacity: (number|undefined), - * scale: (number|undefined), - * snapToPixel: (boolean|undefined), - * rotateWithView: (boolean|undefined), - * rotation: (number|undefined), - * size: (ol.Size|undefined), - * imgSize: (ol.Size|undefined), - * src: (string|undefined)}} - */ -olx.style.IconOptions; - - -/** - * Anchor. Default value is `[0.5, 0.5]` (icon center). - * @type {Array.|undefined} - * @api - */ -olx.style.IconOptions.prototype.anchor; - - -/** - * Origin of the anchor: `bottom-left`, `bottom-right`, `top-left` or - * `top-right`. Default is `top-left`. - * @type {module:ol/style/IconOrigin~IconOrigin|undefined} - * @api - */ -olx.style.IconOptions.prototype.anchorOrigin; - - -/** - * Units in which the anchor x value is specified. A value of `'fraction'` - * indicates the x value is a fraction of the icon. A value of `'pixels'` - * indicates the x value in pixels. Default is `'fraction'`. - * @type {module:ol/style/IconAnchorUnits~IconAnchorUnits|undefined} - * @api - */ -olx.style.IconOptions.prototype.anchorXUnits; - - -/** - * Units in which the anchor y value is specified. A value of `'fraction'` - * indicates the y value is a fraction of the icon. A value of `'pixels'` - * indicates the y value in pixels. Default is `'fraction'`. - * @type {module:ol/style/IconAnchorUnits~IconAnchorUnits|undefined} - * @api - */ -olx.style.IconOptions.prototype.anchorYUnits; - - -/** - * Color to tint the icon. If not specified, the icon will be left as is. - * @type {ol.Color|string|undefined} - * @api - */ -olx.style.IconOptions.prototype.color; - - -/** - * The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @type {null|string|undefined} - * @api - */ -olx.style.IconOptions.prototype.crossOrigin; - - -/** - * Image object for the icon. If the `src` option is not provided then the - * provided image must already be loaded. And in that case, it is required - * to provide the size of the image, with the `imgSize` option. - * @type {Image|HTMLCanvasElement|undefined} - * @api - */ -olx.style.IconOptions.prototype.img; - - -/** - * Offset, which, together with the size and the offset origin, - * define the sub-rectangle to use from the original icon image. Default value - * is `[0, 0]`. - * @type {Array.|undefined} - * @api - */ -olx.style.IconOptions.prototype.offset; - - -/** - * Origin of the offset: `bottom-left`, `bottom-right`, `top-left` or - * `top-right`. Default is `top-left`. - * @type {module:ol/style/IconOrigin~IconOrigin|undefined} - * @api - */ -olx.style.IconOptions.prototype.offsetOrigin; - - -/** - * Opacity of the icon. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.style.IconOptions.prototype.opacity; - - -/** - * Scale. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.style.IconOptions.prototype.scale; - - -/** - * If `true` integral numbers of pixels are used as the X and Y pixel - * coordinate when drawing the icon in the output canvas. If `false` - * fractional numbers may be used. Using `true` allows for "sharp" - * rendering (no blur), while using `false` allows for "accurate" - * rendering. Note that accuracy is important if the icon's position - * is animated. Without it, the icon may jitter noticeably. Default - * value is `true`. - * @type {boolean|undefined} - * @api - */ -olx.style.IconOptions.prototype.snapToPixel; - - -/** - * Whether to rotate the icon with the view. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.style.IconOptions.prototype.rotateWithView; - - -/** - * Rotation in radians (positive rotation clockwise). Default is `0`. - * @type {number|undefined} - * @api - */ -olx.style.IconOptions.prototype.rotation; - - -/** - * Icon size in pixel. Can be used together with `offset` to define the - * sub-rectangle to use from the origin (sprite) icon image. - * @type {ol.Size|undefined} - * @api - */ -olx.style.IconOptions.prototype.size; - - -/** - * Image size in pixels. Only required if `img` is set and `src` is not, and for - * SVG images in Internet Explorer 11. The provided `imgSize` needs to match - * the actual size of the image. - * @type {ol.Size|undefined} - * @api - */ -olx.style.IconOptions.prototype.imgSize; - - -/** - * Image source URI. - * @type {string|undefined} - * @api - */ -olx.style.IconOptions.prototype.src; - - -/** - * Specify radius for regular polygons, or radius1 and radius2 for stars. - * @typedef {{fill: (module:ol/style/Fill~Fill|undefined), - * points: number, - * radius: (number|undefined), - * radius1: (number|undefined), - * radius2: (number|undefined), - * angle: (number|undefined), - * snapToPixel: (boolean|undefined), - * stroke: (module:ol/style/Stroke~Stroke|undefined), - * rotation: (number|undefined), - * rotateWithView: (boolean|undefined), - * atlasManager: (module:ol/style/AtlasManager~AtlasManager|undefined)}} - */ -olx.style.RegularShapeOptions; - - -/** - * Fill style. - * @type {module:ol/style/Fill~Fill|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.fill; - - -/** - * Number of points for stars and regular polygons. In case of a polygon, the - * number of points is the number of sides. - * @type {number} - * @api - */ -olx.style.RegularShapeOptions.prototype.points; - - -/** - * Radius of a regular polygon. - * @type {number|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.radius; - - -/** - * Outer radius of a star. - * @type {number|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.radius1; - - -/** - * Inner radius of a star. - * @type {number|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.radius2; - - -/** - * Shape's angle in radians. A value of 0 will have one of the shape's point - * facing up. - * Default value is 0. - * @type {number|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.angle; - - -/** - * If `true` integral numbers of pixels are used as the X and Y pixel - * coordinate when drawing the shape in the output canvas. If `false` - * fractional numbers may be used. Using `true` allows for "sharp" - * rendering (no blur), while using `false` allows for "accurate" - * rendering. Note that accuracy is important if the shape's - * position is animated. Without it, the shape may jitter noticeably. - * Default value is `true`. - * @type {boolean|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.snapToPixel; - - -/** - * Stroke style. - * @type {module:ol/style/Stroke~Stroke|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.stroke; - - -/** - * Rotation in radians (positive rotation clockwise). Default is `0`. - * @type {number|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.rotation; - - -/** - * Whether to rotate the shape with the view. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.style.RegularShapeOptions.prototype.rotateWithView; - - -/** - * The atlas manager to use for this symbol. When using WebGL it is - * recommended to use an atlas manager to avoid texture switching. - * If an atlas manager is given, the symbol is added to an atlas. - * By default no atlas manager is used. - * @type {module:ol/style/AtlasManager~AtlasManager|undefined} - */ -olx.style.RegularShapeOptions.prototype.atlasManager; - - -/** - * @typedef {{font: (string|undefined), - * maxAngle: (number|undefined), - * offsetX: (number|undefined), - * offsetY: (number|undefined), - * overflow: (boolean|undefined), - * placement: (module:ol/style/Text~TextPlacement|string|undefined), - * scale: (number|undefined), - * rotateWithView: (boolean|undefined), - * rotation: (number|undefined), - * text: (string|undefined), - * textAlign: (string|undefined), - * textBaseline: (string|undefined), - * fill: (module:ol/style/Fill~Fill|undefined), - * stroke: (module:ol/style/Stroke~Stroke|undefined), - * backgroundFill: (module:ol/style/Fill~Fill|undefined), - * backgroundStroke: (module:ol/style/Stroke~Stroke|undefined), - * padding: (Array.|undefined)}} - */ -olx.style.TextOptions; - - -/** - * Font style as CSS 'font' value, see: - * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font}. - * Default is '10px sans-serif' - * @type {string|undefined} - * @api - */ -olx.style.TextOptions.prototype.font; - - -/** - * When `placement` is set to `'line'`, allow a maximum angle between adjacent - * characters. The expected value is in radians, and the default is 45° - * (`Math.PI / 4`). - * @type {number|undefined} - * @api - */ -olx.style.TextOptions.prototype.maxAngle; - - -/** - * Horizontal text offset in pixels. A positive will shift the text right. - * Default is `0`. - * @type {number|undefined} - * @api - */ -olx.style.TextOptions.prototype.offsetX; - - -/** - * Vertical text offset in pixels. A positive will shift the text down. Default - * is `0`. - * @type {number|undefined} - * @api - */ -olx.style.TextOptions.prototype.offsetY; - - -/** - * For polygon labels or when `placement` is set to `'line'`, allow text to - * exceed the width of the polygon at the label position or the length of - * the path that it follows. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.style.TextOptions.prototype.overflow; - - -/** - * Text placement. - * @type {module:ol/style/Text~TextPlacement|undefined} - * @api - */ -olx.style.TextOptions.prototype.placement; - - -/** - * Scale. - * @type {number|undefined} - * @api - */ -olx.style.TextOptions.prototype.scale; - - -/** - * Whether to rotate the text with the view. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.style.TextOptions.prototype.rotateWithView; - - -/** - * Rotation in radians (positive rotation clockwise). Default is `0`. - * @type {number|undefined} - * @api - */ -olx.style.TextOptions.prototype.rotation; - - -/** - * Text content. - * @type {string|undefined} - * @api - */ -olx.style.TextOptions.prototype.text; - - -/** - * Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'. - * Default is 'center' for `placement: 'point'`. For `placement: 'line'`, the - * default is to let the renderer choose a placement where `maxAngle` is not - * exceeded. - * @type {string|undefined} - * @api - */ -olx.style.TextOptions.prototype.textAlign; - - -/** - * Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic', - * 'hanging', 'ideographic'. Default is 'middle'. - * @type {string|undefined} - * @api - */ -olx.style.TextOptions.prototype.textBaseline; - - -/** - * Fill style. If none is provided, we'll use a dark fill-style (#333). - * @type {module:ol/style/Fill~Fill|undefined} - * @api - */ -olx.style.TextOptions.prototype.fill; - - -/** - * Stroke style. - * @type {module:ol/style/Stroke~Stroke|undefined} - * @api - */ -olx.style.TextOptions.prototype.stroke; - - -/** - * Fill style for the text background when `placement` is `'point'`. Default is - * no fill. - * @type {module:ol/style/Fill~Fill|undefined} - * @api - */ -olx.style.TextOptions.prototype.backgroundFill; - - -/** - * Stroke style for the text background when `placement` is `'point'`. Default - * is no stroke. - * @type {module:ol/style/Stroke~Stroke|undefined} - * @api - */ -olx.style.TextOptions.prototype.backgroundStroke; - - -/** - * Padding in pixels around the text for decluttering and background. The order - * of values in the array is `[top, right, bottom, left]`. Default is - * `[0, 0, 0, 0]`. - * @type {Array.|undefined} - * @api - */ -olx.style.TextOptions.prototype.padding; - - -/** - * @typedef {{geometry: (undefined|string|module:ol/geom/Geometry~Geometry|ol.StyleGeometryFunction), - * fill: (module:ol/style/Fill~Fill|undefined), - * image: (module:ol/style/Image~ImageStyle|undefined), - * renderer: (ol.StyleRenderFunction|undefined), - * stroke: (module:ol/style/Stroke~Stroke|undefined), - * text: (module:ol/style/Text~Text|undefined), - * zIndex: (number|undefined)}} - */ -olx.style.StyleOptions; - - -/** - * Feature property or geometry or function returning a geometry to render for - * this style. - * @type {undefined|string|module:ol/geom/Geometry~Geometry|ol.StyleGeometryFunction} - * @api - */ -olx.style.StyleOptions.prototype.geometry; - - -/** - * Fill style. - * @type {module:ol/style/Fill~Fill|undefined} - * @api - */ -olx.style.StyleOptions.prototype.fill; - - -/** - * Image style. - * @type {module:ol/style/Image~ImageStyle|undefined} - * @api - */ -olx.style.StyleOptions.prototype.image; - - -/** - * 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. - * - * @type {ol.StyleRenderFunction|undefined} - */ -olx.style.StyleOptions.prototype.renderer; - - -/** - * Stroke style. - * @type {module:ol/style/Stroke~Stroke|undefined} - * @api - */ -olx.style.StyleOptions.prototype.stroke; - - -/** - * Text style. - * @type {module:ol/style/Text~Text|undefined} - * @api - */ -olx.style.StyleOptions.prototype.text; - - -/** - * Z index. - * @type {number|undefined} - * @api - */ -olx.style.StyleOptions.prototype.zIndex; +/** \ No newline at end of file diff --git a/src/ol/style/Circle.js b/src/ol/style/Circle.js index 165d2dabd2..580a65f0be 100644 --- a/src/ol/style/Circle.js +++ b/src/ol/style/Circle.js @@ -4,12 +4,28 @@ import {inherits} from '../index.js'; import RegularShape from '../style/RegularShape.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/style/Fill~Fill} [fill] Fill style. + * @property {number} radius Circle radius. + * @property {boolean} [snapToPixel=true] If `true` integral numbers of pixels are used as the X and Y pixel coordinate + * when drawing the circle in the output canvas. If `false` fractional numbers may be used. Using `true` allows for + * "sharp" rendering (no blur), while using `false` allows for "accurate" rendering. Note that accuracy is important if + * the circle's position is animated. Without it, the circle may jitter noticeably. + * @property {module:ol/style/Stroke~Stroke} [stroke] Stroke style. + * @property {module:ol/style/AtlasManager~AtlasManager} [atlasManager] The atlas manager to use for this circle. + * When using WebGL it is recommended to use an atlas manager to avoid texture switching. If an atlas manager is given, + * the circle is added to an atlas. By default no atlas manager is used. + */ + + /** * @classdesc * Set circle style for vector features. * * @constructor - * @param {olx.style.CircleOptions=} opt_options Options. + * @param {module:ol/style/Circle~Options=} opt_options Options. * @extends {module:ol/style/RegularShape~RegularShape} * @api */ diff --git a/src/ol/style/Icon.js b/src/ol/style/Icon.js index f9dc715a71..503b7125ba 100644 --- a/src/ol/style/Icon.js +++ b/src/ol/style/Icon.js @@ -12,12 +12,52 @@ import {get as getIconImage} from '../style/IconImage.js'; import IconOrigin from '../style/IconOrigin.js'; import ImageStyle from '../style/Image.js'; + +/** + * @typedef {Object} Options + * @property {Array.} [anchor=[0.5, 0.5]] Anchor. Default value is the icon center. + * @property {module:ol/style/IconOrigin~IconOrigin} [anchorOrigin] Origin of the anchor: `bottom-left`, `bottom-right`, + * `top-left` or `top-right`. Default is `top-left`. + * @property {module:ol/style/IconAnchorUnits~IconAnchorUnits} [anchorXUnits] Units in which the anchor x value is + * specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates + * the x value in pixels. Default is `'fraction'`. + * @property {module:ol/style/IconAnchorUnits~IconAnchorUnits} [anchorYUnits] Units in which the anchor y value is + * specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates + * the y value in pixels. Default is `'fraction'`. + * @property {module:ol/color~Color|string} [color] Color to tint the icon. If not specified, + * the icon will be left as is. + * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that you must provide a + * `crossOrigin` value if you are using the WebGL renderer or if you want to access pixel data with the Canvas renderer. + * See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} for more detail. + * @property {Image|HTMLCanvasElement} [img] Image object for the icon. If the `src` option is not provided then the + * provided image must already be loaded. And in that case, it is required + * to provide the size of the image, with the `imgSize` option. + * @property {Array.} [offset=[0, 0]] Offset, which, together with the size and the offset origin, define the + * sub-rectangle to use from the original icon image. + * @property {module:ol/style/IconOrigin~IconOrigin} [offsetOrigin] Origin of the offset: `bottom-left`, `bottom-right`, + * `top-left` or `top-right`. Default is `top-left`. + * @property {number} [opacity=1] Opacity of the icon. + * @property {number} [scale=1] Scale. + * @property {boolean} [snapToPixel=true] If `true` integral numbers of pixels are used as the X and Y pixel coordinate + * when drawing the icon in the output canvas. If `false` fractional numbers may be used. Using `true` allows for + * "sharp" rendering (no blur), while using `false` allows for "accurate" rendering. Note that accuracy is important if + * the icon's position is animated. Without it, the icon may jitter noticeably. + * @property {boolean} [rotateWithView=false] Whether to rotate the icon with the view. + * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise). + * @property {module:ol/size~Size} [size] Icon size in pixel. Can be used together with `offset` to define the + * sub-rectangle to use from the origin (sprite) icon image. + * @property {module:ol/size~Size} [imgSize] Image size in pixels. Only required if `img` is set and `src` is not, and + * for SVG images in Internet Explorer 11. The provided `imgSize` needs to match the actual size of the image. + * @property {string} [src] Image source URI. + */ + + /** * @classdesc * Set icon style for vector features. * * @constructor - * @param {olx.style.IconOptions=} opt_options Options. + * @param {module:ol/style/Icon~Options=} opt_options Options. * @extends {module:ol/style/Image~ImageStyle} * @api */ diff --git a/src/ol/style/Image.js b/src/ol/style/Image.js index ec837daa87..d195261eb1 100644 --- a/src/ol/style/Image.js +++ b/src/ol/style/Image.js @@ -1,6 +1,18 @@ /** * @module ol/style/Image */ + + +/** + * @typedef {Object} Options + * @property {number} opacity + * @property {boolean} rotateWithView + * @property {number} rotation + * @property {number} number + * @property {boolean} snapToPixel + */ + + /** * @classdesc * A base class used for creating subclasses and not instantiated in @@ -9,7 +21,7 @@ * * @constructor * @abstract - * @param {ol.StyleImageOptions} options Options. + * @param {module:ol/style/Image~Options} options Options. * @api */ const ImageStyle = function(options) { diff --git a/src/ol/style/RegularShape.js b/src/ol/style/RegularShape.js index 33e9626597..f15784f29c 100644 --- a/src/ol/style/RegularShape.js +++ b/src/ol/style/RegularShape.js @@ -9,6 +9,30 @@ import ImageState from '../ImageState.js'; import {defaultStrokeStyle, defaultFillStyle, defaultLineCap, defaultLineWidth, defaultLineJoin, defaultMiterLimit} from '../render/canvas.js'; import ImageStyle from '../style/Image.js'; + +/** + * Specify radius for regular polygons, or radius1 and radius2 for stars. + * @typedef {Object} Options + * @property {module:ol/style/Fill~Fill} [fill] Fill style. + * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the number of points + * is the number of sides. + * @property {number} [radius] Radius of a regular polygon. + * @property {number} [radius1] Outer radius of a star. + * @property {number} [radius2] Inner radius of a star. + * @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's point facing up. + * @property {boolean} [snapToPixel=true] If `true` integral numbers of pixels are used as the X and Y pixel coordinate + * when drawing the shape in the output canvas. If `false` fractional numbers may be used. Using `true` allows for + * "sharp" rendering (no blur), while using `false` allows for "accurate" rendering. Note that accuracy is important if + * the shape's position is animated. Without it, the shape may jitter noticeably. + * @property {module:ol/style/Stroke~Stroke} [stroke] Stroke style. + * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise). + * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view. + * @property {module:ol/style/AtlasManager~AtlasManager} [atlasManager] The atlas manager to use for this symbol. When + * using WebGL it is recommended to use an atlas manager to avoid texture switching. If an atlas manager is given, the + * symbol is added to an atlas. By default no atlas manager is used. + */ + + /** * @classdesc * Set regular shape style for vector features. The resulting shape will be @@ -16,7 +40,7 @@ import ImageStyle from '../style/Image.js'; * `radius2` are provided. * * @constructor - * @param {olx.style.RegularShapeOptions} options Options. + * @param {module:ol/style/RegularShape~Options} options Options. * @extends {module:ol/style/Image~ImageStyle} * @api */ diff --git a/src/ol/style/Style.js b/src/ol/style/Style.js index e5753eac70..61cf9189cc 100644 --- a/src/ol/style/Style.js +++ b/src/ol/style/Style.js @@ -7,6 +7,40 @@ import CircleStyle from '../style/Circle.js'; import Fill from '../style/Fill.js'; import Stroke from '../style/Stroke.js'; +/** + * A function that takes an {@link module:ol/Feature~Feature} as argument and returns an + * {@link module:ol/geom/Geometry~Geometry} that will be rendered and styled for the feature. + * + * @typedef {function((module:ol/Feature~Feature|ol.render.Feature)): + * (module:ol/geom/Geometry~Geometry|ol.render.Feature|undefined)} GeometryFunction + */ + + +/** + * Custom renderer function. Takes two arguments: + * + * 1. The pixel coordinates of the geometry in GeoJSON notation. + * 2. The {@link olx.render.State} of the layer renderer. + * + * @typedef {function((module:ol/coordinate~Coordinate|Array|Array.>),olx.render.State)} + * RenderFunction + */ + + +/** + * @typedef {Object} Options + * @property {string|module:ol/geom/Geometry~Geometry|module:ol/style/Style~GeometryFunction} [geometry] Feature property or geometry + * or function returning a geometry to render for this style. + * @property {module:ol/style/Fill~Fill} [fill] Fill style. + * @property {module:ol/style/Image~ImageStyle} [image] Image style. + * @property {module:ol/style/Style~RenderFunction} [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 {module:ol/style/Stroke~Stroke} [stroke] Stroke style. + * @property {module:ol/style/Text~Text} [text] Text style. + * @property {number} [zIndex] Z index. + */ + + /** * @classdesc * Container for vector feature rendering styles. Any changes made to the style @@ -15,7 +49,7 @@ import Stroke from '../style/Stroke.js'; * * @constructor * @struct - * @param {olx.style.StyleOptions=} opt_options Style options. + * @param {module:ol/style/Style~Options=} opt_options Style options. * @api */ const Style = function(opt_options) { @@ -24,13 +58,13 @@ const Style = function(opt_options) { /** * @private - * @type {string|module:ol/geom/Geometry~Geometry|ol.StyleGeometryFunction} + * @type {string|module:ol/geom/Geometry~Geometry|module:ol/style/Style~GeometryFunction} */ this.geometry_ = null; /** * @private - * @type {!ol.StyleGeometryFunction} + * @type {!module:ol/style/Style~GeometryFunction} */ this.geometryFunction_ = defaultGeometryFunction; @@ -52,7 +86,7 @@ const Style = function(opt_options) { /** * @private - * @type {ol.StyleRenderFunction|null} + * @type {module:ol/style/Style~RenderFunction|null} */ this.renderer_ = options.renderer !== undefined ? options.renderer : null; @@ -101,7 +135,7 @@ Style.prototype.clone = function() { /** * Get the custom renderer function that was configured with * {@link #setRenderer} or the `renderer` constructor option. - * @return {ol.StyleRenderFunction|null} Custom renderer function. + * @return {module:ol/style/Style~RenderFunction|null} Custom renderer function. * @api */ Style.prototype.getRenderer = function() { @@ -112,7 +146,7 @@ Style.prototype.getRenderer = function() { /** * Sets a custom renderer function for this style. When set, `fill`, `stroke` * and `image` options of the style will be ignored. - * @param {ol.StyleRenderFunction|null} renderer Custom renderer function. + * @param {module:ol/style/Style~RenderFunction|null} renderer Custom renderer function. * @api */ Style.prototype.setRenderer = function(renderer) { @@ -122,7 +156,7 @@ Style.prototype.setRenderer = function(renderer) { /** * Get the geometry to be rendered. - * @return {string|module:ol/geom/Geometry~Geometry|ol.StyleGeometryFunction} + * @return {string|module:ol/geom/Geometry~Geometry|module:ol/style/Style~GeometryFunction} * Feature property or geometry or function that returns the geometry that will * be rendered with this style. * @api @@ -134,7 +168,7 @@ Style.prototype.getGeometry = function() { /** * Get the function used to generate a geometry for rendering. - * @return {!ol.StyleGeometryFunction} Function that is called with a feature + * @return {!module:ol/style/Style~GeometryFunction} Function that is called with a feature * and returns the geometry to render instead of the feature's geometry. * @api */ @@ -236,7 +270,7 @@ Style.prototype.getZIndex = function() { /** * Set a geometry that is rendered instead of the feature's geometry. * - * @param {string|module:ol/geom/Geometry~Geometry|ol.StyleGeometryFunction} geometry + * @param {string|module:ol/geom/Geometry~Geometry|module:ol/style/Style~GeometryFunction} geometry * Feature property or geometry or function returning a geometry to render * for this style. * @api diff --git a/src/ol/style/Text.js b/src/ol/style/Text.js index 06ab455e09..ebd5a2320e 100644 --- a/src/ol/style/Text.js +++ b/src/ol/style/Text.js @@ -14,12 +14,43 @@ import TextPlacement from '../style/TextPlacement.js'; const DEFAULT_FILL_COLOR = '#333'; +/** + * @typedef {Object} Options + * @property {string} [font] Font style as CSS 'font' value, see: + * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font}. Default is '10px sans-serif' + * @property {number} [maxAngle] When `placement` is set to `'line'`, allow a maximum angle between adjacent characters. + * The expected value is in radians, and the default is 45° (`Math.PI / 4`). + * @property {number} [offsetX=0] Horizontal text offset in pixels. A positive will shift the text right. + * @property {number} [offsetY=0] Vertical text offset in pixels. A positive will shift the text down. + * @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed + * the width of the polygon at the label position or the length of the path that it follows. + * @property {module:ol/style/Text~TextPlacement|string} [placement] Text placement. + * @property {number} [scale] Scale. + * @property {boolean} [rotateWithView=false] Whether to rotate the text with the view. + * @property {number} rotation=0 Rotation in radians (positive rotation clockwise). + * @property {string} [text] Text content. + * @property {string} [textAlign] Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'. + * Default is 'center' for `placement: 'point'`. For `placement: 'line'`, the default is to let the renderer choose a + * placement where `maxAngle` is not exceeded. + * @property {string} [textBaseline='middle'] Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic', + * 'hanging', 'ideographic'. + * @property {module:ol/style/Fill~Fill} [fill] Fill style. If none is provided, we'll use a dark fill-style (#333). + * @property {module:ol/style/Stroke~Stroke} [stroke] Stroke style. + * @property {module:ol/style/Fill~Fill} [backgroundFill] Fill style for the text background when `placement` is + * `'point'`. Default is no fill. + * @property {module:ol/style/Stroke~Stroke} [backgroundStroke] Stroke style for the text background when `placement` + * is `'point'`. Default is no stroke. + * @property {Array.} [padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of + * values in the array is `[top, right, bottom, left]`. + */ + + /** * @classdesc * Set text style for vector features. * * @constructor - * @param {olx.style.TextOptions=} opt_options Options. + * @param {module:ol/style/Text~Options=} opt_options Options. * @api */ const Text = function(opt_options) { diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 9ae0b8405e..a85c227de3 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -217,37 +217,6 @@ ol.ReprojTriangle; ol.SourceRasterRenderedState; -/** - * A function that takes an {@link module:ol/Feature~Feature} as argument and returns an - * {@link module:ol/geom/Geometry~Geometry} that will be rendered and styled for the feature. - * - * @typedef {function((module:ol/Feature~Feature|ol.render.Feature)): - * (module:ol/geom/Geometry~Geometry|ol.render.Feature|undefined)} - */ -ol.StyleGeometryFunction; - - -/** - * Custom renderer function. Takes two arguments: - * - * 1. The pixel coordinates of the geometry in GeoJSON notation. - * 2. The {@link olx.render.State} of the layer renderer. - * - * @typedef {function((module:ol/coordinate~Coordinate|Array|Array.>),olx.render.State)} - */ -ol.StyleRenderFunction; - - -/** - * @typedef {{opacity: number, - * rotateWithView: boolean, - * rotation: number, - * scale: number, - * snapToPixel: boolean}} - */ -ol.StyleImageOptions; - - /** * Number of features; bounds/extent. * @typedef {{numberOfFeatures: number,