From 4b0f376f605e3bad8f116243f1a2b195f60c83a9 Mon Sep 17 00:00:00 2001 From: Florent gravin Date: Thu, 29 Mar 2018 10:11:52 +0200 Subject: [PATCH] Remove olx.source.XYZOptions --- externs/olx.js | 175 ------------------------------------------- src/ol/source/XYZ.js | 41 +++++++++- 2 files changed, 40 insertions(+), 176 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 5024d602ae..80dc8bc325 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -241,181 +241,6 @@ olx.source.TileArcGISRestOptions.prototype.transition; olx.source.TileArcGISRestOptions.prototype.urls; -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * cacheSize: (number|undefined), - * crossOrigin: (null|string|undefined), - * opaque: (boolean|undefined), - * projection: ol.ProjectionLike, - * reprojectionErrorThreshold: (number|undefined), - * maxZoom: (number|undefined), - * minZoom: (number|undefined), - * tileGrid: (ol.tilegrid.TileGrid|undefined), - * tileLoadFunction: (ol.TileLoadFunctionType|undefined), - * tilePixelRatio: (number|undefined), - * tileSize: (number|ol.Size|undefined), - * tileUrlFunction: (ol.TileUrlFunctionType|undefined), - * url: (string|undefined), - * urls: (Array.|undefined), - * wrapX: (boolean|undefined), - * transition: (number|undefined)}} - */ -olx.source.XYZOptions; - - -/** - * Attributions. - * @type {ol.AttributionLike|undefined} - * @api - */ -olx.source.XYZOptions.prototype.attributions; - - -/** - * Cache size. Default is `2048`. - * @type {number|undefined} - * @api - */ -olx.source.XYZOptions.prototype.cacheSize; - - -/** - * 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.source.XYZOptions.prototype.crossOrigin; - - -/** - * Whether the layer is opaque. - * @type {boolean|undefined} - * @api - */ -olx.source.XYZOptions.prototype.opaque; - - -/** - * Projection. Default is `EPSG:3857`. - * @type {ol.ProjectionLike} - * @api - */ -olx.source.XYZOptions.prototype.projection; - - -/** - * Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @type {number|undefined} - * @api - */ -olx.source.XYZOptions.prototype.reprojectionErrorThreshold; - - -/** - * Optional max zoom level. Default is `18`. - * @type {number|undefined} - * @api - */ -olx.source.XYZOptions.prototype.maxZoom; - - -/** - * Optional min zoom level. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.source.XYZOptions.prototype.minZoom; - - -/** - * Tile grid. - * @type {ol.tilegrid.TileGrid|undefined} - * @api - */ -olx.source.XYZOptions.prototype.tileGrid; - - -/** - * Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @type {ol.TileLoadFunctionType|undefined} - * @api - */ -olx.source.XYZOptions.prototype.tileLoadFunction; - - -/** - * The pixel ratio used by the tile service. For example, if the tile - * service advertizes 256px by 256px tiles but actually sends 512px - * by 512px images (for retina/hidpi devices) then `tilePixelRatio` - * should be set to `2`. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.source.XYZOptions.prototype.tilePixelRatio; - - -/** - * The tile size used by the tile service. Default is `[256, 256]` pixels. - * @type {number|ol.Size|undefined} - * @api - */ -olx.source.XYZOptions.prototype.tileSize; - - -/** - * Optional function to get tile URL given a tile coordinate and the projection. - * Required if url or urls are not provided. - * @type {ol.TileUrlFunctionType|undefined} - * @api - */ -olx.source.XYZOptions.prototype.tileUrlFunction; - - -/** - * URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be - * used instead of defining each one separately in the `urls` option. - * @type {string|undefined} - * @api - */ -olx.source.XYZOptions.prototype.url; - - -/** - * An array of URL templates. - * @type {Array.|undefined} - * @api - */ -olx.source.XYZOptions.prototype.urls; - - -/** - * Whether to wrap the world horizontally. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.source.XYZOptions.prototype.wrapX; - - -/** - * Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - * @type {number|undefined} - * @api - */ -olx.source.XYZOptions.prototype.transition; - - /** * @typedef {{attributions: (ol.AttributionLike|undefined), * cacheSize: (number|undefined), diff --git a/src/ol/source/XYZ.js b/src/ol/source/XYZ.js index 151793a641..b17c5de682 100644 --- a/src/ol/source/XYZ.js +++ b/src/ol/source/XYZ.js @@ -5,6 +5,45 @@ import {inherits} from '../index.js'; import TileImage from '../source/TileImage.js'; import {createXYZ, extentFromProjection} from '../tilegrid.js'; +/** + * @typedef {Object} Options + * @property {ol.AttributionLike} [attributions] Attributions. + * @property {number} [cacheSize=2048] Cache size. + * @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 {boolean} [opaque=true] Whether the layer is opaque. + * @property {ol.ProjectionLike} [projection='EPSG:3857'] Projection. + * @property {boolean} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels). + * Higher values can increase reprojection performance, but decrease precision. + * @property {number} [maxZoom=18] Optional max zoom level. + * @property {number} [maxZoom=0] Optional min zoom level. + * @property {ol.tilegrid.WMTS} tileGrid Tile grid. + * @property {ol.TileLoadFunctionType} [tileLoadFunction] Optional function to load a tile given a URL. The default is + * ```js + * function(imageTile, src) { + * imageTile.getImage().src = src; + * }; + * ``` + * @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service. + * For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px + * by 512px images (for retina/hidpi devices) then `tilePixelRatio` + * should be set to `2`. + * @property {number|ol.Size} [tileSize=[256, 256]] The tile size used by the tile service. + * @property {ol.TileUrlFunctionType} [tileUrlFunction] Optional function to get + * tile URL given a tile coordinate and the projection. + * Required if url or urls are not provided. + * @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, + * and `{z}` placeholders. A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, + * may be used instead of defining each one separately in the `urls` option. + * @property {Array.} [urls] An array of URL templates. + * @property {boolean} [wrapX=true] Whether to wrap the world horizontally. + * @property {number} [transition] Duration of the opacity transition for rendering. + * To disable the opacity transition, pass `transition: 0`. + */ + + /** * @classdesc * Layer source for tile data with URLs in a set XYZ format that are @@ -24,7 +63,7 @@ import {createXYZ, extentFromProjection} from '../tilegrid.js'; * * @constructor * @extends {ol.source.TileImage} - * @param {olx.source.XYZOptions=} opt_options XYZ options. + * @param {module:ol/source/XYZ~Options=} opt_options XYZ options. * @api */ const XYZ = function(opt_options) {