From c0148cae7c92479591aabfbce59b2ebc6ff4c0ab Mon Sep 17 00:00:00 2001 From: Roman Zoller Date: Thu, 22 Mar 2018 18:23:15 +0100 Subject: [PATCH] Move olx.layer.LayerOptions to ol/layer/Layer --- externs/olx.js | 72 ------------------------------------------ src/ol/layer/Image.js | 2 +- src/ol/layer/Layer.js | 20 +++++++++++- src/ol/layer/Tile.js | 2 +- src/ol/layer/Vector.js | 2 +- 5 files changed, 22 insertions(+), 76 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 9e3490116d..1fdab4d0a0 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,78 +5,6 @@ let olx; -/** - * @typedef {{opacity: (number|undefined), - * source: (ol.source.Source|undefined), - * visible: (boolean|undefined), - * extent: (ol.Extent|undefined), - * zIndex: (number|undefined), - * minResolution: (number|undefined), - * maxResolution: (number|undefined)}} - */ -olx.layer.LayerOptions; - - -/** - * Opacity (0, 1). Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.opacity; - - -/** - * Source for this layer. If not provided to the constructor, the source can - * be set by calling {@link ol.layer.Layer#setSource layer.setSource(source)} - * after construction. - * @type {ol.source.Source|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.source; - - -/** - * Visibility. Default is `true` (visible). - * @type {boolean|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.visible; - - -/** - * The bounding extent for layer rendering. The layer will not be rendered - * outside of this extent. - * @type {ol.Extent|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.extent; - - -/** - * The z-index for layer rendering. At rendering time, the layers will be - * ordered, first by Z-index and then by position. The default Z-index is 0. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.zIndex; - - -/** - * The minimum resolution (inclusive) at which this layer will be visible. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.minResolution; - - -/** - * The maximum resolution (exclusive) below which this layer will be visible. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.maxResolution; - - /** * @typedef {{opacity: (number|undefined), * visible: (boolean|undefined), diff --git a/src/ol/layer/Image.js b/src/ol/layer/Image.js index 641199158d..bbb1f73f3d 100644 --- a/src/ol/layer/Image.js +++ b/src/ol/layer/Image.js @@ -21,7 +21,7 @@ import Layer from '../layer/Layer.js'; */ const ImageLayer = function(opt_options) { const options = opt_options ? opt_options : {}; - Layer.call(this, /** @type {olx.layer.LayerOptions} */ (options)); + Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (options)); /** * The layer type. diff --git a/src/ol/layer/Layer.js b/src/ol/layer/Layer.js index 64a664e9b7..e77863d241 100644 --- a/src/ol/layer/Layer.js +++ b/src/ol/layer/Layer.js @@ -12,6 +12,24 @@ import RenderEventType from '../render/EventType.js'; import SourceState from '../source/State.js'; +/** + * @typedef {Object} Options + * @property {number} [opacity=1] Opacity (0, 1). + * @property {boolean} [visible=true] Visibility. + * @property {ol.Extent} [extent] The bounding extent for layer rendering. The layer will not be + * rendered outside of this extent. + * @property {number} [zIndex=0] The z-index for layer rendering. At rendering time, the layers + * will be ordered, first by Z-index and then by position. + * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be + * visible. + * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will + * be visible. + * @property {ol.source.Source} [source] Source for this layer. If not provided to the constructor, + * the source can be set by calling {@link ol.layer.Layer#setSource layer.setSource(source)} after + * construction. + */ + + /** * @typedef {Object} State * @property {module:ol/layer/Layer~Layer} layer @@ -45,7 +63,7 @@ import SourceState from '../source/State.js'; * @abstract * @extends {module:ol/layer/Base~BaseLayer} * @fires ol.render.Event - * @param {olx.layer.LayerOptions} options Layer options. + * @param {module:ol/layer/Layer~Options} options Layer options. * @api */ const Layer = function(options) { diff --git a/src/ol/layer/Tile.js b/src/ol/layer/Tile.js index 1f93ccbc1a..3f58124099 100644 --- a/src/ol/layer/Tile.js +++ b/src/ol/layer/Tile.js @@ -28,7 +28,7 @@ const TileLayer = function(opt_options) { delete baseOptions.preload; delete baseOptions.useInterimTilesOnError; - Layer.call(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); + Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (baseOptions)); this.setPreload(options.preload !== undefined ? options.preload : 0); this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ? diff --git a/src/ol/layer/Vector.js b/src/ol/layer/Vector.js index 827c4982cd..8830273691 100644 --- a/src/ol/layer/Vector.js +++ b/src/ol/layer/Vector.js @@ -41,7 +41,7 @@ const VectorLayer = function(opt_options) { delete baseOptions.renderBuffer; delete baseOptions.updateWhileAnimating; delete baseOptions.updateWhileInteracting; - Layer.call(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); + Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (baseOptions)); /** * @private