diff --git a/externs/olx.js b/externs/olx.js index ce96743b26..af0e9e79af 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -49,187 +49,6 @@ olx.render.State.prototype.resolution; olx.render.State.prototype.rotation; -/** - * @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), 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 */