From f306fd0aa0552749aec99feadb6f6b9854b10216 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:30:02 -0600 Subject: [PATCH 01/14] Move AtPixelOptions to PluggableMap --- externs/olx.js | 32 +------------------------------- externs/xol.js | 12 ------------ src/ol/PluggableMap.js | 19 ++++++++++++++++--- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 0d7370bdb1..949efbb640 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2,37 +2,7 @@ /** * @type {Object} */ -var olx; - - -/** - * Object literal with options for the {@link ol.Map#forEachFeatureAtPixel} and - * {@link ol.Map#hasFeatureAtPixel} methods. - * @typedef {{layerFilter: ((function(ol.layer.Layer): boolean)|undefined), - * hitTolerance: (number|undefined)}} - */ -olx.AtPixelOptions; - - -/** - * Layer filter function. The filter function will receive one argument, the - * {@link ol.layer.Layer layer-candidate} and it should return a boolean value. - * Only layers which are visible and for which this function returns `true` - * will be tested for features. By default, all visible layers will be tested. - * @type {((function(ol.layer.Layer): boolean)|undefined)} - * @api - */ -olx.AtPixelOptions.prototype.layerFilter; - - -/** - * Hit-detection tolerance in pixels. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.AtPixelOptions.prototype.hitTolerance; +let olx; /** diff --git a/externs/xol.js b/externs/xol.js index 927a41f525..129fafce20 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,16 +1,4 @@ -/** - * @typedef {Object} AtPixelOptions - * @property {((function(ol.layer.Layer): boolean)|undefined)} layerFilter Layer filter function. The filter function will receive one argument, the - * {@link ol.layer.Layer layer-candidate} and it should return a boolean value. - * Only layers which are visible and for which this function returns `true` - * will be tested for features. By default, all visible layers will be tested. - * @property {number|undefined} hitTolerance Hit-detection tolerance in pixels. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - */ - - /** * @typedef {Object} ProjectionOptions * @property {string} code The SRS identifier code, e.g. `EPSG:4326`. diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 41d518ca16..9978248f20 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -61,6 +61,19 @@ import {create as createTransform, apply as applyTransform} from './transform.js */ +/** + * @typedef {Object} AtPixelOptions + * @property {((function(ol.layer.Layer): boolean)|undefined)} layerFilter Layer filter + * function. The filter function will receive one argument, the + * {@link ol.layer.Layer layer-candidate} and it should return a boolean value. + * Only layers which are visible and for which this function returns `true` + * will be tested for features. By default, all visible layers will be tested. + * @property {number|undefined} hitTolerance Hit-detection tolerance in pixels. Pixels + * inside the radius around the given position will be checked for features. This only + * works for the canvas renderer and not for WebGL. Default is `0`. + */ + + /** * @typedef {Object} MapOptionsInternal * @property {module:ol/Collection~Collection.} [controls] @@ -554,7 +567,7 @@ PluggableMap.prototype.disposeInternal = function() { * the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for * unmanaged layers. To stop detection, callback functions can return a * truthy value. - * @param {olx.AtPixelOptions=} opt_options Optional options. + * @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options. * @return {T|undefined} Callback result, i.e. the return value of last * callback execution, or the first truthy callback return value. * @template S,T @@ -579,7 +592,7 @@ PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_opt /** * Get all features that intersect a pixel on the viewport. * @param {module:ol~Pixel} pixel Pixel. - * @param {olx.AtPixelOptions=} opt_options Optional options. + * @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options. * @return {Array.} The detected features or * `null` if none were found. * @api @@ -636,7 +649,7 @@ PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this, * Detect if features intersect a pixel on the viewport. Layers included in the * detection can be configured through `opt_layerFilter`. * @param {module:ol~Pixel} pixel Pixel. - * @param {olx.AtPixelOptions=} opt_options Optional options. + * @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options. * @return {boolean} Is there a feature at the given pixel? * @template U * @api From 70ff218a8ecdbf683b24b70f820f0575059a7934 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:34:17 -0600 Subject: [PATCH 02/14] Move ProjectionOptions to ol/proj/Projection --- externs/olx.js | 82 --------------------------------------- externs/xol.js | 17 -------- src/ol/proj/Projection.js | 25 +++++++++++- 3 files changed, 24 insertions(+), 100 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 949efbb640..89a00b2617 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,88 +5,6 @@ let olx; -/** - * Object literal with config options for the projection. - * @typedef {{code: string, - * units: (ol.proj.Units|string|undefined), - * extent: (ol.Extent|undefined), - * axisOrientation: (string|undefined), - * global: (boolean|undefined), - * metersPerUnit: (number|undefined), - * worldExtent: (ol.Extent|undefined), - * getPointResolution: (function(number, ol.Coordinate):number|undefined) }} - */ -olx.ProjectionOptions; - - -/** - * The SRS identifier code, e.g. `EPSG:4326`. - * @type {string} - * @api - */ -olx.ProjectionOptions.prototype.code; - - -/** - * Units. Required unless a proj4 projection is defined for `code`. - * @type {ol.proj.Units|string|undefined} - * @api - */ -olx.ProjectionOptions.prototype.units; - - -/** - * The validity extent for the SRS. - * @type {ol.Extent|undefined} - * @api - */ -olx.ProjectionOptions.prototype.extent; - - -/** - * The axis orientation as specified in Proj4. The default is `enu`. - * @type {string|undefined} - * @api - */ -olx.ProjectionOptions.prototype.axisOrientation; - - -/** - * Whether the projection is valid for the whole globe. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.ProjectionOptions.prototype.global; - - -/** - * The meters per unit for the SRS. If not provided, the `units` are used to get - * the meters per unit from the {@link ol.proj.METERS_PER_UNIT} lookup table. - * @type {number|undefined} - * @api - */ -olx.ProjectionOptions.prototype.metersPerUnit; - - -/** - * The world extent for the SRS. - * @type {ol.Extent|undefined} - * @api - */ -olx.ProjectionOptions.prototype.worldExtent; - - -/** - * Function to determine resolution at a point. The function is called with a - * `{number}` view resolution and an `{ol.Coordinate}` as arguments, and returns - * the `{number}` resolution at the passed coordinate. If this is `undefined`, - * the default {@link ol.proj#getPointResolution} function will be used. - * @type {(function(number, ol.Coordinate):number|undefined)} - * @api - */ -olx.ProjectionOptions.prototype.getPointResolution; - - /** * @typedef {{ * center: (ol.Coordinate|undefined), diff --git a/externs/xol.js b/externs/xol.js index 129fafce20..bc2ece3e65 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,21 +1,4 @@ -/** - * @typedef {Object} ProjectionOptions - * @property {string} code The SRS identifier code, e.g. `EPSG:4326`. - * @property {ol.proj.Units|string|undefined} units Units. Required unless a proj4 projection is defined for `code`. - * @property {ol.Extent|undefined} extent The validity extent for the SRS. - * @property {string|undefined} axisOrientation The axis orientation as specified in Proj4. The default is `enu`. - * @property {boolean|undefined} global Whether the projection is valid for the whole globe. Default is `false`. - * @property {number|undefined} metersPerUnit The meters per unit for the SRS. If not provided, the `units` are used to get - * the meters per unit from the {@link ol.proj.METERS_PER_UNIT} lookup table. - * @property {ol.Extent|undefined} worldExtent The world extent for the SRS. - * @property {(function(number, ol.Coordinate):number|undefined)} getPointResolution Function to determine resolution at a point. The function is called with a - * `{number}` view resolution and an `{ol.Coordinate}` as arguments, and returns - * the `{number}` resolution at the passed coordinate. If this is `undefined`, - * the default {@link ol.proj#getPointResolution} function will be used. - */ - - /** * @typedef {Object} AnimationOptions * @property {ol.Coordinate|undefined} center The center of the view at the end of the animation. diff --git a/src/ol/proj/Projection.js b/src/ol/proj/Projection.js index eb572f0ebc..5829dbb780 100644 --- a/src/ol/proj/Projection.js +++ b/src/ol/proj/Projection.js @@ -3,6 +3,29 @@ */ import {METERS_PER_UNIT} from '../proj/Units.js'; + +/** + * @typedef {Object} Options + * @property {string} code The SRS identifier code, e.g. `EPSG:4326`. + * @property {ol.proj.Units|string|undefined} units Units. Required unless a + * proj4 projection is defined for `code`. + * @property {ol.Extent|undefined} extent The validity extent for the SRS. + * @property {string|undefined} axisOrientation The axis orientation as specified + * in Proj4. The default is `enu`. + * @property {boolean|undefined} global Whether the projection is valid for the + * whole globe. Default is `false`. + * @property {number|undefined} metersPerUnit The meters per unit for the SRS. + * If not provided, the `units` are used to get the meters per unit from the {@link ol.proj.METERS_PER_UNIT} + * lookup table. + * @property {ol.Extent|undefined} worldExtent The world extent for the SRS. + * @property {(function(number, ol.Coordinate):number|undefined)} getPointResolution + * Function to determine resolution at a point. The function is called with a + * `{number}` view resolution and an `{ol.Coordinate}` as arguments, and returns + * the `{number}` resolution at the passed coordinate. If this is `undefined`, + * the default {@link ol.proj#getPointResolution} function will be used. + */ + + /** * @classdesc * Projection definition class. One of these is created for each projection @@ -29,7 +52,7 @@ import {METERS_PER_UNIT} from '../proj/Units.js'; * namespace for proj4, use {@link ol.proj.setProj4}. * * @constructor - * @param {olx.ProjectionOptions} options Projection options. + * @param {module:ol/proj/Projection~Options} options Projection options. * @struct * @api */ From 57d135e9f66977a9f91c93400bc7c2b3569dc9b5 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:37:57 -0600 Subject: [PATCH 03/14] Move AnimationOptions to ol/View --- externs/olx.js | 75 -------------------------------------------------- externs/xol.js | 17 ------------ src/ol/View.js | 26 +++++++++++++++-- 3 files changed, 24 insertions(+), 94 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 89a00b2617..dde9aa5af8 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,81 +5,6 @@ let olx; -/** - * @typedef {{ - * center: (ol.Coordinate|undefined), - * zoom: (number|undefined), - * resolution: (number|undefined), - * rotation: (number|undefined), - * anchor: (ol.Coordinate|undefined), - * duration: (number|undefined), - * easing: (undefined|function(number):number) - * }} - */ -olx.AnimationOptions; - - -/** - * The center of the view at the end of the animation. - * @type {ol.Coordinate|undefined} - * @api - */ -olx.AnimationOptions.prototype.center; - - -/** - * The zoom level of the view at the end of the animation. This takes - * precedence over `resolution`. - * @type {number|undefined} - * @api - */ -olx.AnimationOptions.prototype.zoom; - - -/** - * The resolution of the view at the end of the animation. If `zoom` is also - * provided, this option will be ignored. - * @type {number|undefined} - * @api - */ -olx.AnimationOptions.prototype.resolution; - - -/** - * The rotation of the view at the end of the animation. - * @type {number|undefined} - * @api - */ -olx.AnimationOptions.prototype.rotation; - - -/** - * Optional anchor to remained fixed during a rotation or resolution animation. - * @type {ol.Coordinate|undefined} - * @api - */ -olx.AnimationOptions.prototype.anchor; - - -/** - * The duration of the animation in milliseconds (defaults to `1000`). - * @type {number|undefined} - * @api - */ -olx.AnimationOptions.prototype.duration; - - -/** - * The easing function used during the animation (defaults to {@link ol.easing.inAndOut}). - * The function will be called for each frame with a number representing a - * fraction of the animation's duration. The function should return a number - * between 0 and 1 representing the progress toward the destination state. - * @type {undefined|function(number):number} - * @api - */ -olx.AnimationOptions.prototype.easing; - - /** * Namespace. * @type {Object} diff --git a/externs/xol.js b/externs/xol.js index bc2ece3e65..4a26edba5d 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,21 +1,4 @@ -/** - * @typedef {Object} AnimationOptions - * @property {ol.Coordinate|undefined} center The center of the view at the end of the animation. - * @property {number|undefined} zoom The zoom level of the view at the end of the animation. This takes - * precedence over `resolution`. - * @property {number|undefined} resolution The resolution of the view at the end of the animation. If `zoom` is also - * provided, this option will be ignored. - * @property {number|undefined} rotation The rotation of the view at the end of the animation. - * @property {ol.Coordinate|undefined} anchor Optional anchor to remained fixed during a rotation or resolution animation. - * @property {number|undefined} duration The duration of the animation in milliseconds (defaults to `1000`). - * @property {undefined|function(number):number} easing The easing function used during the animation (defaults to {@link ol.easing.inAndOut}). - * The function will be called for each frame with a number representing a - * fraction of the animation's duration. The function should return a number - * between 0 and 1 representing the progress toward the destination state. - */ - - /** * @typedef {Object} control_AttributionOptions * @property {string|undefined} className CSS class name. Default is `ol-attribution`. diff --git a/src/ol/View.js b/src/ol/View.js index 72e0ca4efe..0103a9d6cd 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -134,6 +134,28 @@ import Units from './proj/Units.js'; */ +/** + * @typedef {Object} AnimationOptions + * @property {ol.Coordinate|undefined} center The center of the view at the end of + * the animation. + * @property {number|undefined} zoom The zoom level of the view at the end of the + * animation. This takes precedence over `resolution`. + * @property {number|undefined} resolution The resolution of the view at the end + * of the animation. If `zoom` is also provided, this option will be ignored. + * @property {number|undefined} rotation The rotation of the view at the end of + * the animation. + * @property {ol.Coordinate|undefined} anchor Optional anchor to remained fixed + * during a rotation or resolution animation. + * @property {number|undefined} duration The duration of the animation in milliseconds + * (defaults to `1000`). + * @property {undefined|function(number):number} easing The easing function used + * during the animation (defaults to {@link ol.easing.inAndOut}). + * The function will be called for each frame with a number representing a + * fraction of the animation's duration. The function should return a number + * between 0 and 1 representing the progress toward the destination state. + */ + + /** * Default min zoom level for the map view. * @type {number} @@ -372,7 +394,7 @@ View.prototype.getUpdatedOptions_ = function(newOptions) { * calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()` * (or another method that calls one of these). * - * @param {...(olx.AnimationOptions|function(boolean))} var_args Animation + * @param {...(module:ol/View~AnimationOptions|function(boolean))} var_args Animation * options. Multiple animations can be run in series by passing multiple * options objects. To run multiple animations in parallel, call the method * multiple times. An optional callback can be provided as a final @@ -412,7 +434,7 @@ View.prototype.animate = function(var_args) { let rotation = this.getRotation(); const series = []; for (let i = 0; i < animationCount; ++i) { - const options = /** @type {olx.AnimationOptions} */ (arguments[i]); + const options = /** @type {module:ol/View~AnimationOptions} */ (arguments[i]); const animation = /** @type {module:ol/View~Animation} */ ({ start: start, From cddfd7cb3b200af993b6f06bcd0c00f29411f1dd Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:41:27 -0600 Subject: [PATCH 04/14] Move AttributionOptions to ol/control/Attribution --- externs/olx.js | 84 ----------------------------------- externs/xol.js | 20 --------- src/ol/control/Attribution.js | 30 ++++++++++++- 3 files changed, 29 insertions(+), 105 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index dde9aa5af8..631df3239d 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -12,90 +12,6 @@ let olx; olx.control; -/** - * @typedef {{className: (string|undefined), - * collapsible: (boolean|undefined), - * collapsed: (boolean|undefined), - * tipLabel: (string|undefined), - * label: (string|Element|undefined), - * collapseLabel: (string|Element|undefined), - * render: (function(ol.MapEvent)|undefined), - * target: (Element|string|undefined)}} - */ -olx.control.AttributionOptions; - - -/** - * CSS class name. Default is `ol-attribution`. - * @type {string|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.className; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.target; - - -/** - * Specify if attributions can be collapsed. If you use an OSM source, - * should be set to `false` — see - * {@link https://www.openstreetmap.org/copyright OSM Copyright} — - * Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.collapsible; - - -/** - * Specify if attributions should be collapsed at startup. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.collapsed; - - -/** - * Text label to use for the button tip. Default is `Attributions` - * @type {string|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.tipLabel; - - -/** - * Text label to use for the collapsed attributions button. Default is `i`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.label; - - -/** - * Text label to use for the expanded attributions button. Default is `»`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.collapseLabel; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.AttributionOptions.prototype.render; - - /** * @typedef {{element: (Element|undefined), * render: (function(ol.MapEvent)|undefined), diff --git a/externs/xol.js b/externs/xol.js index 4a26edba5d..0a3b26c149 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,24 +1,4 @@ -/** - * @typedef {Object} control_AttributionOptions - * @property {string|undefined} className CSS class name. Default is `ol-attribution`. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @property {boolean|undefined} collapsible Specify if attributions can be collapsed. If you use an OSM source, - * should be set to `false` — see - * {@link https://www.openstreetmap.org/copyright OSM Copyright} — - * Default is `true`. - * @property {boolean|undefined} collapsed Specify if attributions should be collapsed at startup. Default is `true`. - * @property {string|undefined} tipLabel Text label to use for the button tip. Default is `Attributions` - * @property {string|Element|undefined} label Text label to use for the collapsed attributions button. Default is `i`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|Element|undefined} collapseLabel Text label to use for the expanded attributions button. Default is `»`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - */ - - /** * @typedef {Object} control_ControlOptions * @property {Element|undefined} element The element is the control's container element. This only needs to be diff --git a/src/ol/control/Attribution.js b/src/ol/control/Attribution.js index 6224c417fe..27aed85ccd 100644 --- a/src/ol/control/Attribution.js +++ b/src/ol/control/Attribution.js @@ -10,6 +10,34 @@ import {listen} from '../events.js'; import EventType from '../events/EventType.js'; import {visibleAtResolution} from '../layer/Layer.js'; + +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS class name. Default is + * `'ol-attribution'`. + * @property {Element|string|undefined} target Specify a target if you + * want the control to be rendered outside of the map's + * viewport. + * @property {boolean|undefined} collapsible Specify if attributions can + * be collapsed. If you use an OSM source, should be set to `false` — see + * {@link https://www.openstreetmap.org/copyright OSM Copyright} — + * Default is `true`. + * @property {boolean|undefined} collapsed Specify if attributions should + * be collapsed at startup. Default is `true`. + * @property {string|undefined} tipLabel Text label to use for the button + * tip. Default is `'Attributions'` + * @property {string|Element|undefined} label Text label to use for the + * collapsed attributions button. Default is `'i'`. + * Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|Element|undefined} collapseLabel Text label to use + * for the expanded attributions button. Default is `'»'`. + * Instead of text, also an element (e.g. a `span` element) can be used. + * @property {function(ol.MapEvent)|undefined} render Function called when + * the control should be re-rendered. This is called in a `requestAnimationFrame` + * callback. + */ + + /** * @classdesc * Control to show all the attributions associated with the layer sources @@ -19,7 +47,7 @@ import {visibleAtResolution} from '../layer/Layer.js'; * * @constructor * @extends {ol.control.Control} - * @param {olx.control.AttributionOptions=} opt_options Attribution options. + * @param {module:ol/control/Attribution~Options=} opt_options Attribution options. * @api */ const Attribution = function(opt_options) { From 9468fd45ecc30b61ddb1ede78efa14fc23514d1a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:43:58 -0600 Subject: [PATCH 05/14] Move ControlOptions to ol/control/Control --- externs/olx.js | 35 ----------------------------------- externs/xol.js | 11 ----------- src/ol/control/Control.js | 16 +++++++++++++++- 3 files changed, 15 insertions(+), 47 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 631df3239d..47c67ff5f6 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -12,41 +12,6 @@ let olx; olx.control; -/** - * @typedef {{element: (Element|undefined), - * render: (function(ol.MapEvent)|undefined), - * target: (Element|string|undefined)}} - */ -olx.control.ControlOptions; - - -/** - * The element is the control's container element. This only needs to be - * specified if you're developing a custom control. - * @type {Element|undefined} - * @api - */ -olx.control.ControlOptions.prototype.element; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.ControlOptions.prototype.render; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.ControlOptions.prototype.target; - - /** * @typedef {{className: (string|undefined), * label: (string|Element|undefined), diff --git a/externs/xol.js b/externs/xol.js index 0a3b26c149..e538c11496 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,15 +1,4 @@ -/** - * @typedef {Object} control_ControlOptions - * @property {Element|undefined} element The element is the control's container element. This only needs to be - * specified if you're developing a custom control. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - */ - - /** * @typedef {Object} control_FullScreenOptions * @property {string|undefined} className CSS class name. Default is `ol-full-screen`. diff --git a/src/ol/control/Control.js b/src/ol/control/Control.js index 92e35f208e..489369122b 100644 --- a/src/ol/control/Control.js +++ b/src/ol/control/Control.js @@ -8,6 +8,20 @@ import BaseObject from '../Object.js'; import {removeNode} from '../dom.js'; import {listen, unlistenByKey} from '../events.js'; + +/** + * @typedef {Object} Options + * @property {Element|undefined} element The element is the control's + * container element. This only needs to be specified if you're developing + * a custom control. + * @property {function(ol.MapEvent)|undefined} render Function called when + * the control should be re-rendered. This is called in a `requestAnimationFrame` + * callback. + * @property {Element|string|undefined} target Specify a target if you want + * the control to be rendered outside of the map's viewport. + */ + + /** * @classdesc * A control is a visible widget with a DOM element in a fixed position on the @@ -34,7 +48,7 @@ import {listen, unlistenByKey} from '../events.js'; * @constructor * @extends {ol.Object} * @implements {oli.control.Control} - * @param {olx.control.ControlOptions} options Control options. + * @param {module:ol/control/Control~Options} options Control options. * @api */ const Control = function(options) { From 5dcfa1137d5ea177422e2162c8cda56c406bd7c9 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:46:56 -0600 Subject: [PATCH 06/14] Move FullScreenOptions to ol/control/FullScreen --- externs/olx.js | 70 ------------------------------------ externs/xol.js | 16 --------- src/ol/control/FullScreen.js | 23 +++++++++++- 3 files changed, 22 insertions(+), 87 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 47c67ff5f6..215b3d5227 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -12,76 +12,6 @@ let olx; olx.control; -/** - * @typedef {{className: (string|undefined), - * label: (string|Element|undefined), - * labelActive: (string|Element|undefined), - * tipLabel: (string|undefined), - * keys: (boolean|undefined), - * target: (Element|string|undefined), - * source: (Element|string|undefined)}} - */ -olx.control.FullScreenOptions; - - -/** - * CSS class name. Default is `ol-full-screen`. - * @type {string|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.className; - - -/** - * Text label to use for the button. Default is `\u2922` (NORTH EAST AND SOUTH WEST ARROW). - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.label; - - -/** - * Text label to use for the button when full-screen is active. - * Default is `\u00d7` (a cross). - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.labelActive; - - -/** - * Text label to use for the button tip. Default is `Toggle full-screen` - * @type {string|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.tipLabel; - - -/** - * Full keyboard access. - * @type {boolean|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.keys; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.target; - -/** - * The element to be displayed fullscreen. When not provided, the element containing the map viewport will be displayed fullscreen. - * @type {Element|string|undefined} - * @api - */ -olx.control.FullScreenOptions.prototype.source; - /** * @typedef {{className: (string|undefined), * coordinateFormat: (module:ol/coordinate~CoordinateFormat|undefined), diff --git a/externs/xol.js b/externs/xol.js index e538c11496..4dcb5a9ae3 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,20 +1,4 @@ -/** - * @typedef {Object} control_FullScreenOptions - * @property {string|undefined} className CSS class name. Default is `ol-full-screen`. - * @property {string|Element|undefined} label Text label to use for the button. Default is `\u2922` (NORTH EAST AND SOUTH WEST ARROW). - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|Element|undefined} labelActive Text label to use for the button when full-screen is active. - * Default is `\u00d7` (a cross). - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} tipLabel Text label to use for the button tip. Default is `Toggle full-screen` - * @property {boolean|undefined} keys Full keyboard access. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @property {Element|string|undefined} source The element to be displayed fullscreen. When not provided, the element containing the map viewport will be displayed fullscreen. - */ - - /** * @typedef {Object} control_MousePositionOptions * @property {string|undefined} className CSS class name. Default is `ol-mouse-position`. diff --git a/src/ol/control/FullScreen.js b/src/ol/control/FullScreen.js index e05459233e..b138abc152 100644 --- a/src/ol/control/FullScreen.js +++ b/src/ol/control/FullScreen.js @@ -32,6 +32,27 @@ const getChangeType = (function() { })(); +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS class name. Default is + * `'ol-full-screen'`. + * @property {string|Element|undefined} label Text label to use for the button. + * Default is `'\u2922'` (NORTH EAST AND SOUTH WEST ARROW). + * Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|Element|undefined} labelActive Text label to use for the + * button when full-screen is active. Default is `'\u00d7'` (a cross). + * Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|undefined} tipLabel Text label to use for the button tip. + * Default is `'Toggle full-screen'`. + * @property {boolean|undefined} keys Full keyboard access. + * @property {Element|string|undefined} target Specify a target if you want the + * control to be rendered outside of the map's viewport. + * @property {Element|string|undefined} source The element to be displayed + * fullscreen. When not provided, the element containing the map viewport will + * be displayed fullscreen. + */ + + /** * @classdesc * Provides a button that when clicked fills up the full screen with the map. @@ -46,7 +67,7 @@ const getChangeType = (function() { * * @constructor * @extends {ol.control.Control} - * @param {olx.control.FullScreenOptions=} opt_options Options. + * @param {module:ol/control/FullScreen~Options=} opt_options Options. * @api */ const FullScreen = function(opt_options) { From e059a50131329fb9f3bbd6a3b1afca338254d4d0 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:52:37 -0600 Subject: [PATCH 07/14] Move MousePositionOptions to ol/control/MousePosition --- externs/olx.js | 61 --------------------------------- externs/xol.js | 13 ------- src/ol/control/MousePosition.js | 19 +++++++++- 3 files changed, 18 insertions(+), 75 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 215b3d5227..b8952a324d 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -12,67 +12,6 @@ let olx; olx.control; -/** - * @typedef {{className: (string|undefined), - * coordinateFormat: (module:ol/coordinate~CoordinateFormat|undefined), - * projection: ol.ProjectionLike, - * render: (function(ol.MapEvent)|undefined), - * target: (Element|string|undefined), - * undefinedHTML: (string|undefined)}} - */ -olx.control.MousePositionOptions; - - -/** - * CSS class name. Default is `ol-mouse-position`. - * @type {string|undefined} - * @api - */ -olx.control.MousePositionOptions.prototype.className; - - -/** - * Coordinate format. - * @type {module:ol/coordinate~CoordinateFormat|undefined} - * @api - */ -olx.control.MousePositionOptions.prototype.coordinateFormat; - - -/** - * Projection. - * @type {ol.ProjectionLike} - * @api - */ -olx.control.MousePositionOptions.prototype.projection; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.MousePositionOptions.prototype.render; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.MousePositionOptions.prototype.target; - - -/** - * Markup for undefined coordinates. Default is `` (empty string). - * @type {string|undefined} - * @api - */ -olx.control.MousePositionOptions.prototype.undefinedHTML; - - /** * @typedef {{collapsed: (boolean|undefined), * collapseLabel: (string|Element|undefined), diff --git a/externs/xol.js b/externs/xol.js index 4dcb5a9ae3..2f75f9813b 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,17 +1,4 @@ -/** - * @typedef {Object} control_MousePositionOptions - * @property {string|undefined} className CSS class name. Default is `ol-mouse-position`. - * @property {module:ol/coordinate~CoordinateFormat|undefined} coordinateFormat Coordinate format. - * @property {ol.ProjectionLike} projection Projection. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @property {string|undefined} undefinedHTML Markup for undefined coordinates. Default is `` (empty string). - */ - - /** * @typedef {Object} control_OverviewMapOptions * @property {boolean|undefined} collapsed Whether the control should start collapsed or not (expanded). diff --git a/src/ol/control/MousePosition.js b/src/ol/control/MousePosition.js index 0909395070..5fc94ade3c 100644 --- a/src/ol/control/MousePosition.js +++ b/src/ol/control/MousePosition.js @@ -21,6 +21,23 @@ const PROJECTION = 'projection'; const COORDINATE_FORMAT = 'coordinateFormat'; +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS class name. Default is + * `'ol-mouse-position'`. + * @property {module:ol/coordinate~CoordinateFormat|undefined} coordinateFormat + * Coordinate format. + * @property {ol.ProjectionLike} projection Projection. + * @property {function(ol.MapEvent)|undefined} render Function called when the + * control should be re-rendered. This is called in a `requestAnimationFrame` + * callback. + * @property {Element|string|undefined} target Specify a target if you want the + * control to be rendered outside of the map's viewport. + * @property {string|undefined} undefinedHTML Markup for undefined coordinates. + * Default is `''` (empty string). + */ + + /** * @classdesc * A control to show the 2D coordinates of the mouse cursor. By default, these @@ -30,7 +47,7 @@ const COORDINATE_FORMAT = 'coordinateFormat'; * * @constructor * @extends {ol.control.Control} - * @param {olx.control.MousePositionOptions=} opt_options Mouse position + * @param {module:ol/control/MousePosition~Options=} opt_options Mouse position * options. * @api */ From de9d9ffce1bac848a8a159e9828dcfad29db5d62 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:17:45 -0600 Subject: [PATCH 08/14] Throw an error with more detail in publish.js and remove olx.control --- config/jsdoc/info/publish.js | 95 +++++++++++++++++++----------------- externs/olx.js | 7 --- 2 files changed, 49 insertions(+), 53 deletions(-) diff --git a/config/jsdoc/info/publish.js b/config/jsdoc/info/publish.js index 9e42a6a6d3..e1d514265c 100644 --- a/config/jsdoc/info/publish.js +++ b/config/jsdoc/info/publish.js @@ -2,8 +2,8 @@ * @fileoverview Generates JSON output based on exportable symbols (those with * an api tag) and boolean defines (with a define tag and a default value). */ -var assert = require('assert'); -var path = require('path'); +const assert = require('assert'); +const path = require('path'); /** @@ -15,7 +15,7 @@ var path = require('path'); exports.publish = function(data, opts) { function getTypes(data) { - var types = []; + const types = []; data.forEach(function(name) { types.push(name.replace(/^function$/, 'Function')); }); @@ -24,43 +24,43 @@ exports.publish = function(data, opts) { // get all doclets with the "api" property or define (excluding events) or // with olx namespace - var classes = {}; - var docs = data( - [ - {define: {isObject: true}}, - function() { - if (this.kind == 'class') { - if (!('extends' in this) || typeof this.api == 'boolean') { - classes[this.longname] = this; - return true; - } + const classes = {}; + const docs = data( + [ + {define: {isObject: true}}, + function() { + if (this.kind == 'class') { + if (!('extends' in this) || typeof this.api == 'boolean') { + classes[this.longname] = this; + return true; } - return (typeof this.api == 'boolean' || - this.meta && (/[\\\/]externs$/).test(this.meta.path)); } - ], - {kind: {'!is': 'file'}}, - {kind: {'!is': 'event'}}).get(); + return (typeof this.api == 'boolean' || + this.meta && (/[\\\/]externs$/).test(this.meta.path)); + } + ], + {kind: {'!is': 'file'}}, + {kind: {'!is': 'event'}}).get(); // get symbols data, filter out those that are members of private classes - var symbols = []; - var defines = []; - var typedefs = []; - var externs = []; - var base = []; - var augments = {}; - var symbolsByName = {}; + const symbols = []; + const defines = []; + const typedefs = []; + const externs = []; + let base = []; + const augments = {}; + const symbolsByName = {}; docs.filter(function(doc) { - var include = true; - var constructor = doc.memberof; + let include = true; + const constructor = doc.memberof; if (constructor && constructor.substr(-1) === '_' && constructor.indexOf('module:') === -1) { assert.strictEqual(doc.inherited, true, - 'Unexpected export on private class: ' + doc.longname); + 'Unexpected export on private class: ' + doc.longname); include = false; } return include; }).forEach(function(doc) { - var isExterns = (/[\\\/]externs$/).test(doc.meta.path); + const isExterns = (/[\\\/]externs$/).test(doc.meta.path); if (isExterns && doc.longname.indexOf('olx.') === 0) { if (doc.kind == 'typedef') { typedefs.push({ @@ -68,12 +68,15 @@ exports.publish = function(data, opts) { types: ['{}'] }); } else { - var typedef = typedefs[typedefs.length - 1]; - var type = typedef.types[0]; + const typedef = typedefs[typedefs.length - 1]; + if (!typedef) { + throw new Error(`Expected to see a typedef before ${doc.longname} at ${doc.meta.filename}:${doc.meta.lineno}`); + } + const type = typedef.types[0]; typedef.types[0] = type - .replace(/\}$/, ', ' + doc.longname.split('#')[1] + + .replace(/\}$/, ', ' + doc.longname.split('#')[1] + ': (' + getTypes(doc.type.names).join('|') + ')}') - .replace('{, ', '{'); + .replace('{, ', '{'); } } else if (doc.define) { defines.push({ @@ -88,7 +91,7 @@ exports.publish = function(data, opts) { types: getTypes(doc.type.names) }); } else { - var symbol = { + const symbol = { name: doc.longname, kind: doc.kind, description: doc.classdesc || doc.description, @@ -104,9 +107,9 @@ exports.publish = function(data, opts) { symbol.types = getTypes(doc.type.names); } if (doc.params) { - var params = []; + const params = []; doc.params.forEach(function(param) { - var paramInfo = { + const paramInfo = { name: param.name }; params.push(paramInfo); @@ -141,10 +144,10 @@ exports.publish = function(data, opts) { }); } - var target = isExterns ? externs : (doc.api ? symbols : base); - var existingSymbol = symbolsByName[symbol.name]; + const target = isExterns ? externs : (doc.api ? symbols : base); + const existingSymbol = symbolsByName[symbol.name]; if (existingSymbol) { - var idx = target.indexOf(existingSymbol); + const idx = target.indexOf(existingSymbol); target.splice(idx, 1); } target.push(symbol); @@ -168,13 +171,13 @@ exports.publish = function(data, opts) { return new Promise(function(resolve, reject) { process.stdout.write( - JSON.stringify({ - symbols: symbols, - defines: defines, - typedefs: typedefs, - externs: externs, - base: base - }, null, 2)); + JSON.stringify({ + symbols: symbols, + defines: defines, + typedefs: typedefs, + externs: externs, + base: base + }, null, 2)); }); }; diff --git a/externs/olx.js b/externs/olx.js index b8952a324d..4d051eca9d 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,13 +5,6 @@ let olx; -/** - * Namespace. - * @type {Object} - */ -olx.control; - - /** * @typedef {{collapsed: (boolean|undefined), * collapseLabel: (string|Element|undefined), From 6cebaf2665a4d2cf72afc09ea6582e4dcea4a4d3 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:21:24 -0600 Subject: [PATCH 09/14] Move OverviewMapOptions to ol/control/OverviewMap --- externs/olx.js | 93 ----------------------------------- externs/xol.js | 21 -------- src/ol/control/OverviewMap.js | 28 ++++++++++- 3 files changed, 27 insertions(+), 115 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 4d051eca9d..a6ed968a46 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,99 +5,6 @@ let olx; -/** - * @typedef {{collapsed: (boolean|undefined), - * collapseLabel: (string|Element|undefined), - * collapsible: (boolean|undefined), - * label: (string|Element|undefined), - * layers: (Array.|ol.Collection.|undefined), - * render: (function(ol.MapEvent)|undefined), - * target: (Element|string|undefined), - * tipLabel: (string|undefined), - * view: (ol.View|undefined)}} - */ -olx.control.OverviewMapOptions; - - -/** - * Whether the control should start collapsed or not (expanded). - * Default to `true`. - * @type {boolean|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.collapsed; - - -/** - * Text label to use for the expanded overviewmap button. Default is `«`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.collapseLabel; - - -/** - * Whether the control can be collapsed or not. Default to `true`. - * @type {boolean|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.collapsible; - - -/** - * Text label to use for the collapsed overviewmap button. Default is `»`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.label; - - -/** - * Layers for the overview map. If not set, then all main map layers are used - * instead. - * @type {Array.|ol.Collection.|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.layers; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.render; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.target; - - -/** - * Text label to use for the button tip. Default is `Overview map` - * @type {string|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.tipLabel; - - -/** - * Custom view for the overview map. If not provided, a default view with - * an EPSG:3857 projection will be used. - * @type {ol.View|undefined} - * @api - */ -olx.control.OverviewMapOptions.prototype.view; - - /** * @typedef {{className: (string|undefined), * minWidth: (number|undefined), diff --git a/externs/xol.js b/externs/xol.js index 2f75f9813b..eaaf01a57f 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,25 +1,4 @@ -/** - * @typedef {Object} control_OverviewMapOptions - * @property {boolean|undefined} collapsed Whether the control should start collapsed or not (expanded). - * Default to `true`. - * @property {string|Element|undefined} collapseLabel Text label to use for the expanded overviewmap button. Default is `«`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {boolean|undefined} collapsible Whether the control can be collapsed or not. Default to `true`. - * @property {string|Element|undefined} label Text label to use for the collapsed overviewmap button. Default is `»`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {Array.|ol.Collection.|undefined} layers Layers for the overview map. If not set, then all main map layers are used - * instead. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @property {string|undefined} tipLabel Text label to use for the button tip. Default is `Overview map` - * @property {ol.View|undefined} view Custom view for the overview map. If not provided, a default view with - * an EPSG:3857 projection will be used. - */ - - /** * @typedef {Object} control_ScaleLineOptions * @property {string|undefined} className CSS Class name. Default is `ol-scale-line`. diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 274523bae1..382a394a6b 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -36,12 +36,38 @@ const MAX_RATIO = 0.75; const MIN_RATIO = 0.1; +/** + * @typedef {Object} Options + * @property {boolean|undefined} collapsed Whether the control should start collapsed + * or not (expanded). Default to `true`. + * @property {string|Element|undefined} collapseLabel Text label to use for the + * expanded overviewmap button. Default is `'«'`. Instead of text, also an element + * (e.g. a `span` element) can be used. + * @property {boolean|undefined} collapsible Whether the control can be collapsed + * or not. Default to `true`. + * @property {string|Element|undefined} label Text label to use for the collapsed + * overviewmap button. Default is `'»'`. Instead of text, also an element + * (e.g. a `span` element) can be used. + * @property {Array.|ol.Collection.|undefined} layers + * Layers for the overview map. If not set, then all main map layers are used + * instead. + * @property {function(ol.MapEvent)|undefined} render Function called when the control + * should be re-rendered. This is called in a `requestAnimationFrame` callback. + * @property {Element|string|undefined} target Specify a target if you want the control + * to be rendered outside of the map's viewport. + * @property {string|undefined} tipLabel Text label to use for the button tip. Default + * is `'Overview map'`. + * @property {ol.View|undefined} view Custom view for the overview map. If not provided, + * a default view with an EPSG:3857 projection will be used. + */ + + /** * Create a new control with a map acting as an overview map for an other * defined map. * @constructor * @extends {ol.control.Control} - * @param {olx.control.OverviewMapOptions=} opt_options OverviewMap options. + * @param {module:ol/control/OverviewMap~Options=} opt_options OverviewMap options. * @api */ const OverviewMap = function(opt_options) { From 464e2e0f0fe5c12627571222d630f579529eb69a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:25:32 -0600 Subject: [PATCH 10/14] Move ScaleLineOptions to ol/control/ScaleLine --- externs/olx.js | 52 ------------------------------------- externs/xol.js | 12 --------- src/ol/control/ScaleLine.js | 14 +++++++++- 3 files changed, 13 insertions(+), 65 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index a6ed968a46..7962f2eaf8 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,58 +5,6 @@ let olx; -/** - * @typedef {{className: (string|undefined), - * minWidth: (number|undefined), - * render: (function(ol.MapEvent)|undefined), - * target: (Element|string|undefined), - * units: (ol.control.ScaleLineUnits|string|undefined)}} - */ -olx.control.ScaleLineOptions; - - -/** - * CSS Class name. Default is `ol-scale-line`. - * @type {string|undefined} - * @api - */ -olx.control.ScaleLineOptions.prototype.className; - - -/** - * Minimum width in pixels. Default is `64`. - * @type {number|undefined} - * @api - */ -olx.control.ScaleLineOptions.prototype.minWidth; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.ScaleLineOptions.prototype.render; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.ScaleLineOptions.prototype.target; - - -/** - * Units. Default is `metric`. - * @type {ol.control.ScaleLineUnits|string|undefined} - * @api - */ -olx.control.ScaleLineOptions.prototype.units; - - /** * @typedef {{duration: (number|undefined), * className: (string|undefined), diff --git a/externs/xol.js b/externs/xol.js index eaaf01a57f..d59ab43254 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,16 +1,4 @@ -/** - * @typedef {Object} control_ScaleLineOptions - * @property {string|undefined} className CSS Class name. Default is `ol-scale-line`. - * @property {number|undefined} minWidth Minimum width in pixels. Default is `64`. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @property {ol.control.ScaleLineUnits|string|undefined} units Units. Default is `metric`. - */ - - /** * @typedef {Object} control_RotateOptions * @property {string|undefined} className CSS class name. Default is `ol-rotate`. diff --git a/src/ol/control/ScaleLine.js b/src/ol/control/ScaleLine.js index 15efa83991..3de1e823f5 100644 --- a/src/ol/control/ScaleLine.js +++ b/src/ol/control/ScaleLine.js @@ -25,6 +25,18 @@ const UNITS = 'units'; const LEADING_DIGITS = [1, 2, 5]; +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS Class name. Default is `'ol-scale-line'`. + * @property {number|undefined} minWidth Minimum width in pixels. Default is `64`. + * @property {function(ol.MapEvent)|undefined} render Function called when the control + * should be re-rendered. This is called in a `requestAnimationFrame` callback. + * @property {Element|string|undefined} target Specify a target if you want the control + * to be rendered outside of the map's viewport. + * @property {ol.control.ScaleLineUnits|string|undefined} units Units. Default is `'metric'`. + */ + + /** * @classdesc * A control displaying rough y-axis distances, calculated for the center of the @@ -37,7 +49,7 @@ const LEADING_DIGITS = [1, 2, 5]; * * @constructor * @extends {ol.control.Control} - * @param {olx.control.ScaleLineOptions=} opt_options Scale line options. + * @param {module:ol/control/ScaleLine~Options=} opt_options Scale line options. * @api */ const ScaleLine = function(opt_options) { From 8da0f3b1be2221dcb0e3b5925d1afe7b04ffb88f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:27:49 -0600 Subject: [PATCH 11/14] Move RotateOptions to ol/control/Rotate --- externs/olx.js | 81 ---------------------------------------- externs/xol.js | 17 --------- src/ol/control/Rotate.js | 21 ++++++++++- 3 files changed, 20 insertions(+), 99 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 7962f2eaf8..41bd1edd78 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,87 +5,6 @@ let olx; -/** - * @typedef {{duration: (number|undefined), - * className: (string|undefined), - * label: (string|Element|undefined), - * tipLabel: (string|undefined), - * target: (Element|string|undefined), - * render: (function(ol.MapEvent)|undefined), - * resetNorth: (function()|undefined), - * autoHide: (boolean|undefined)}} - */ -olx.control.RotateOptions; - - -/** - * CSS class name. Default is `ol-rotate`. - * @type {string|undefined} - * @api - */ -olx.control.RotateOptions.prototype.className; - - -/** - * Text label to use for the rotate button. Default is `⇧`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.RotateOptions.prototype.label; - - -/** - * Text label to use for the rotate tip. Default is `Reset rotation` - * @type {string|undefined} - * @api - */ -olx.control.RotateOptions.prototype.tipLabel; - - -/** - * Animation duration in milliseconds. Default is `250`. - * @type {number|undefined} - * @api - */ -olx.control.RotateOptions.prototype.duration; - - -/** - * Hide the control when rotation is 0. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.control.RotateOptions.prototype.autoHide; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.RotateOptions.prototype.render; - - -/** - * Function called when the control is clicked. This will override the - * default resetNorth. - * @type {function()|undefined} - * @api - */ -olx.control.RotateOptions.prototype.resetNorth; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.RotateOptions.prototype.target; - - /** * @typedef {{duration: (number|undefined), * className: (string|undefined), diff --git a/externs/xol.js b/externs/xol.js index d59ab43254..ada3af15d8 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,21 +1,4 @@ -/** - * @typedef {Object} control_RotateOptions - * @property {string|undefined} className CSS class name. Default is `ol-rotate`. - * @property {string|Element|undefined} label Text label to use for the rotate button. Default is `⇧`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} tipLabel Text label to use for the rotate tip. Default is `Reset rotation` - * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. - * @property {boolean|undefined} autoHide Hide the control when rotation is 0. Default is `true`. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @property {function()|undefined} resetNorth Function called when the control is clicked. This will override the - * default resetNorth. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - */ - - /** * @typedef {Object} control_ZoomOptions * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. diff --git a/src/ol/control/Rotate.js b/src/ol/control/Rotate.js index 328d388902..6505958d60 100644 --- a/src/ol/control/Rotate.js +++ b/src/ol/control/Rotate.js @@ -9,6 +9,25 @@ import {listen} from '../events.js'; import EventType from '../events/EventType.js'; import {inherits} from '../index.js'; + +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS class name. Default is `'ol-rotate'`. + * @property {string|Element|undefined} label Text label to use for the rotate button. + * Default is `'⇧'`. Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|undefined} tipLabel Text label to use for the rotate tip. Default is + * `'Reset rotation'` + * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. + * @property {boolean|undefined} autoHide Hide the control when rotation is 0. Default is `true`. + * @property {function(ol.MapEvent)|undefined} render Function called when the control should + * be re-rendered. This is called in a `requestAnimationFrame` callback. + * @property {function()|undefined} resetNorth Function called when the control is clicked. + * This will override the default `resetNorth`. + * @property {Element|string|undefined} target Specify a target if you want the control to be + * rendered outside of the map's viewport. + */ + + /** * @classdesc * A button control to reset rotation to 0. @@ -17,7 +36,7 @@ import {inherits} from '../index.js'; * * @constructor * @extends {ol.control.Control} - * @param {olx.control.RotateOptions=} opt_options Rotate options. + * @param {module:ol/control/Rotate~Options=} opt_options Rotate options. * @api */ const Rotate = function(opt_options) { From 9b4ed8aaf358fbde85dac89f6ef036f0322cf919 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:29:57 -0600 Subject: [PATCH 12/14] Move ZoomOptions to ol/control/Zoom --- externs/olx.js | 80 ------------------------------------------ externs/xol.js | 16 --------- src/ol/control/Zoom.js | 21 ++++++++++- 3 files changed, 20 insertions(+), 97 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 41bd1edd78..6ea0e80913 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,86 +5,6 @@ let olx; -/** - * @typedef {{duration: (number|undefined), - * className: (string|undefined), - * zoomInLabel: (string|Element|undefined), - * zoomOutLabel: (string|Element|undefined), - * zoomInTipLabel: (string|undefined), - * zoomOutTipLabel: (string|undefined), - * delta: (number|undefined), - * target: (Element|string|undefined)}} - */ -olx.control.ZoomOptions; - - -/** - * Animation duration in milliseconds. Default is `250`. - * @type {number|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.duration; - - -/** - * CSS class name. Default is `ol-zoom`. - * @type {string|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.className; - - -/** - * Text label to use for the zoom-in button. Default is `+`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.zoomInLabel; - - -/** - * Text label to use for the zoom-out button. Default is `-`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.zoomOutLabel; - - -/** - * Text label to use for the button tip. Default is `Zoom in` - * @type {string|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.zoomInTipLabel; - - -/** - * Text label to use for the button tip. Default is `Zoom out` - * @type {string|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.zoomOutTipLabel; - - -/** - * The zoom delta applied on each click. - * @type {number|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.delta; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.ZoomOptions.prototype.target; - - /** * @typedef {{className: (string|undefined), * duration: (number|undefined), diff --git a/externs/xol.js b/externs/xol.js index ada3af15d8..7f887bf640 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,20 +1,4 @@ -/** - * @typedef {Object} control_ZoomOptions - * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. - * @property {string|undefined} className CSS class name. Default is `ol-zoom`. - * @property {string|Element|undefined} zoomInLabel Text label to use for the zoom-in button. Default is `+`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|Element|undefined} zoomOutLabel Text label to use for the zoom-out button. Default is `-`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} zoomInTipLabel Text label to use for the button tip. Default is `Zoom in` - * @property {string|undefined} zoomOutTipLabel Text label to use for the button tip. Default is `Zoom out` - * @property {number|undefined} delta The zoom delta applied on each click. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - */ - - /** * @typedef {Object} control_ZoomSliderOptions * @property {string|undefined} className CSS class name. diff --git a/src/ol/control/Zoom.js b/src/ol/control/Zoom.js index 1d4c9f4be5..46866ef5ad 100644 --- a/src/ol/control/Zoom.js +++ b/src/ol/control/Zoom.js @@ -8,6 +8,25 @@ import Control from '../control/Control.js'; import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; import {easeOut} from '../easing.js'; + +/** + * @typedef {Object} Options + * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. + * @property {string|undefined} className CSS class name. Default is `'ol-zoom'`. + * @property {string|Element|undefined} zoomInLabel Text label to use for the zoom-in + * button. Default is `'+'`. Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|Element|undefined} zoomOutLabel Text label to use for the zoom-out button. + * Default is `'-'`. Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|undefined} zoomInTipLabel Text label to use for the button tip. Default is + * `'Zoom in'`. + * @property {string|undefined} zoomOutTipLabel Text label to use for the button tip. Default is + * `'Zoom out'`. + * @property {number|undefined} delta The zoom delta applied on each click. + * @property {Element|string|undefined} target Specify a target if you want the control to be + * rendered outside of the map's viewport. + */ + + /** * @classdesc * A control with 2 buttons, one for zoom in and one for zoom out. @@ -16,7 +35,7 @@ import {easeOut} from '../easing.js'; * * @constructor * @extends {ol.control.Control} - * @param {olx.control.ZoomOptions=} opt_options Zoom options. + * @param {module:ol/control/Zoom~Options=} opt_options Zoom options. * @api */ const Zoom = function(opt_options) { From 4c7a07e4b839e3ff13d5461c222081a106b7e712 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:31:40 -0600 Subject: [PATCH 13/14] Move ZoomSliderOptions to ol/control/ZoomSlider --- externs/olx.js | 51 ------------------------------------ externs/xol.js | 11 -------- src/ol/control/ZoomSlider.js | 13 ++++++++- 3 files changed, 12 insertions(+), 63 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 6ea0e80913..78122dae45 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,57 +5,6 @@ let olx; -/** - * @typedef {{className: (string|undefined), - * duration: (number|undefined), - * maxResolution: (number|undefined), - * minResolution: (number|undefined), - * render: (function(ol.MapEvent)|undefined)}} - */ -olx.control.ZoomSliderOptions; - - -/** - * CSS class name. - * @type {string|undefined} - * @api - */ -olx.control.ZoomSliderOptions.prototype.className; - - -/** - * Animation duration in milliseconds. Default is `200`. - * @type {number|undefined} - * @api - */ -olx.control.ZoomSliderOptions.prototype.duration; - - -/** - * Maximum resolution. - * @type {number|undefined} - * @api - */ -olx.control.ZoomSliderOptions.prototype.maxResolution; - - -/** - * Minimum resolution. - * @type {number|undefined} - * @api - */ -olx.control.ZoomSliderOptions.prototype.minResolution; - - -/** - * Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - * @type {function(ol.MapEvent)|undefined} - * @api - */ -olx.control.ZoomSliderOptions.prototype.render; - - /** * @typedef {{className: (string|undefined), * target: (Element|string|undefined), diff --git a/externs/xol.js b/externs/xol.js index 7f887bf640..c173c6a3bc 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,15 +1,4 @@ -/** - * @typedef {Object} control_ZoomSliderOptions - * @property {string|undefined} className CSS class name. - * @property {number|undefined} duration Animation duration in milliseconds. Default is `200`. - * @property {number|undefined} maxResolution Maximum resolution. - * @property {number|undefined} minResolution Minimum resolution. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should be re-rendered. This is called - * in a requestAnimationFrame callback. - */ - - /** * @typedef {Object} control_ZoomToExtentOptions * @property {string|undefined} className Class name. Default is `ol-zoom-extent`. diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index 2685b7abf1..0663b9c90a 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -25,6 +25,17 @@ const Direction = { }; +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS class name. + * @property {number|undefined} duration Animation duration in milliseconds. Default is `200`. + * @property {number|undefined} maxResolution Maximum resolution. + * @property {number|undefined} minResolution Minimum resolution. + * @property {function(ol.MapEvent)|undefined} render Function called when the control + * should be re-rendered. This is called in a `requestAnimationFrame` callback. + */ + + /** * @classdesc * A slider type of control for zooming. @@ -35,7 +46,7 @@ const Direction = { * * @constructor * @extends {ol.control.Control} - * @param {olx.control.ZoomSliderOptions=} opt_options Zoom slider options. + * @param {module:ol/control/ZoomSlider~Options=} opt_options Zoom slider options. * @api */ const ZoomSlider = function(opt_options) { From 328910049d5ee9d1ac9bbab065cab203c567684a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 11:34:09 -0600 Subject: [PATCH 14/14] Move ZoomToExtentOptions to ol/control/ZoomToExtent --- externs/olx.js | 60 ---------------------------------- externs/xol.js | 13 -------- src/ol/control/ZoomToExtent.js | 17 +++++++++- 3 files changed, 16 insertions(+), 74 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 78122dae45..dfb5834b12 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,66 +5,6 @@ let olx; -/** - * @typedef {{className: (string|undefined), - * target: (Element|string|undefined), - * label: (string|Element|undefined), - * tipLabel: (string|undefined), - * extent: (ol.Extent|undefined)}} - */ -olx.control.ZoomToExtentOptions; - - -/** - * Class name. Default is `ol-zoom-extent`. - * @type {string|undefined} - * @api - */ -olx.control.ZoomToExtentOptions.prototype.className; - - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - * @api - */ -olx.control.ZoomToExtentOptions.prototype.target; - - -/** - * Text label to use for the button. Default is `E`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @type {string|Element|undefined} - * @api - */ -olx.control.ZoomToExtentOptions.prototype.label; - - -/** - * Text label to use for the button tip. Default is `Zoom to extent` - * @type {string|undefined} - * @api - */ -olx.control.ZoomToExtentOptions.prototype.tipLabel; - - -/** - * The extent to zoom to. If undefined the validity extent of the view - * projection is used. - * @type {ol.Extent|undefined} - * @api - */ -olx.control.ZoomToExtentOptions.prototype.extent; - - -/** - * Namespace. - * @type {Object} - */ -olx.format; - - /** * @typedef {{dataProjection: ol.ProjectionLike, * extent: (ol.Extent|undefined), diff --git a/externs/xol.js b/externs/xol.js index c173c6a3bc..3869f024f6 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,17 +1,4 @@ -/** - * @typedef {Object} control_ZoomToExtentOptions - * @property {string|undefined} className Class name. Default is `ol-zoom-extent`. - * @property {Element|string|undefined} target Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @property {string|Element|undefined} label Text label to use for the button. Default is `E`. - * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} tipLabel Text label to use for the button tip. Default is `Zoom to extent` - * @property {ol.Extent|undefined} extent The extent to zoom to. If undefined the validity extent of the view - * projection is used. - */ - - /** * @typedef {Object} format_ReadOptions * @property {ol.ProjectionLike} dataProjection Projection of the data we are reading. If not provided, the projection will diff --git a/src/ol/control/ZoomToExtent.js b/src/ol/control/ZoomToExtent.js index 022021c202..b32f05b50a 100644 --- a/src/ol/control/ZoomToExtent.js +++ b/src/ol/control/ZoomToExtent.js @@ -7,6 +7,21 @@ import EventType from '../events/EventType.js'; import Control from '../control/Control.js'; import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; + +/** + * @typedef {Object} Options + * @property {string|undefined} className Class name. Default is `'ol-zoom-extent'`. + * @property {Element|string|undefined} target Specify a target if you want the control + * to be rendered outside of the map's viewport. + * @property {string|Element|undefined} label Text label to use for the button. Default + * is `'E'`. Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string|undefined} tipLabel Text label to use for the button tip. Default + * is `'Zoom to extent'`. + * @property {ol.Extent|undefined} extent The extent to zoom to. If undefined the validity + * extent of the view projection is used. + */ + + /** * @classdesc * A button control which, when pressed, changes the map view to a specific @@ -14,7 +29,7 @@ import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; * * @constructor * @extends {ol.control.Control} - * @param {olx.control.ZoomToExtentOptions=} opt_options Options. + * @param {module:ol/control/ZoomToExtent~Options=} opt_options Options. * @api */ const ZoomToExtent = function(opt_options) {