diff --git a/src/ol/Map.js b/src/ol/Map.js index f214283fd0..99d5ab3577 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -3,7 +3,7 @@ */ import {inherits} from './index.js'; import PluggableMap from './PluggableMap.js'; -import {defaults as defaultControls} from './control.js'; +import {defaults as defaultControls} from './control/util.js'; import {defaults as defaultInteractions} from './interaction.js'; import {assign} from './obj.js'; import CanvasImageLayerRenderer from './renderer/canvas/ImageLayer.js'; diff --git a/src/ol/control.js b/src/ol/control.js index aafb064e39..0073a308d8 100644 --- a/src/ol/control.js +++ b/src/ol/control.js @@ -1,10 +1,6 @@ /** * @module ol/control */ -import Collection from './Collection.js'; -import Attribution from './control/Attribution.js'; -import Rotate from './control/Rotate.js'; -import Zoom from './control/Zoom.js'; export {default as Attribution} from './control/Attribution.js'; export {default as Control} from './control/Control.js'; @@ -15,61 +11,4 @@ export {default as ScaleLine} from './control/ScaleLine.js'; export {default as Zoom} from './control/Zoom.js'; export {default as ZoomSlider} from './control/ZoomSlider.js'; export {default as ZoomToExtent} from './control/ZoomToExtent.js'; - - -/** - * @typedef {Object} DefaultsOptions - * @property {boolean} [attribution=true] Include - * {@link module:ol/control/Attribution~Attribution}. - * @property {module:ol/control/Attribution~Options} [attributionOptions] - * Options for {@link module:ol/control/Attribution~Attribution}. - * @property {boolean} [rotate=true] Include - * {@link module:ol/control/Rotate~Rotate}. - * @property {module:ol/control/Rotate~Options} [rotateOptions] Options - * for {@link module:ol/control/Rotate~Rotate}. - * @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}. - * @property {module:ol/control/Zoom~Options} [zoomOptions] Options for - * {@link module:ol/control/Zoom~Zoom}. - * @api - */ - - -/** - * Set of controls included in maps by default. Unless configured otherwise, - * this returns a collection containing an instance of each of the following - * controls: - * * {@link module:ol/control/Zoom~Zoom} - * * {@link module:ol/control/Rotate~Rotate} - * * {@link module:ol/control/Attribution~Attribution} - * - * @param {module:ol/control~DefaultsOptions=} opt_options - * Defaults options. - * @return {module:ol/Collection.} - * Controls. - * @api - */ -export function defaults(opt_options) { - - const options = opt_options ? opt_options : {}; - - const controls = new Collection(); - - const zoomControl = options.zoom !== undefined ? options.zoom : true; - if (zoomControl) { - controls.push(new Zoom(options.zoomOptions)); - } - - const rotateControl = options.rotate !== undefined ? options.rotate : true; - if (rotateControl) { - controls.push(new Rotate(options.rotateOptions)); - } - - const attributionControl = options.attribution !== undefined ? - options.attribution : true; - if (attributionControl) { - controls.push(new Attribution(options.attributionOptions)); - } - - return controls; - -} +export {defaults} from './control/util.js'; diff --git a/src/ol/control/util.js b/src/ol/control/util.js new file mode 100644 index 0000000000..bfb7400c54 --- /dev/null +++ b/src/ol/control/util.js @@ -0,0 +1,61 @@ +import Collection from '../Collection.js'; +import Attribution from './Attribution.js'; +import Rotate from './Rotate.js'; +import Zoom from './Zoom.js'; + + +/** + * @typedef {Object} DefaultsOptions + * @property {boolean} [attribution=true] Include + * {@link module:ol/control/Attribution~Attribution}. + * @property {module:ol/control/Attribution~Options} [attributionOptions] + * Options for {@link module:ol/control/Attribution~Attribution}. + * @property {boolean} [rotate=true] Include + * {@link module:ol/control/Rotate~Rotate}. + * @property {module:ol/control/Rotate~Options} [rotateOptions] Options + * for {@link module:ol/control/Rotate~Rotate}. + * @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}. + * @property {module:ol/control/Zoom~Options} [zoomOptions] Options for + * {@link module:ol/control/Zoom~Zoom}. + * @api + */ + + +/** + * Set of controls included in maps by default. Unless configured otherwise, + * this returns a collection containing an instance of each of the following + * controls: + * * {@link module:ol/control/Zoom~Zoom} + * * {@link module:ol/control/Rotate~Rotate} + * * {@link module:ol/control/Attribution~Attribution} + * + * @param {module:ol/control/util~DefaultsOptions=} opt_options + * Defaults options. + * @return {module:ol/Collection.} + * Controls. + * @api + */ +export function defaults(opt_options) { + + const options = opt_options ? opt_options : {}; + + const controls = new Collection(); + + const zoomControl = options.zoom !== undefined ? options.zoom : true; + if (zoomControl) { + controls.push(new Zoom(options.zoomOptions)); + } + + const rotateControl = options.rotate !== undefined ? options.rotate : true; + if (rotateControl) { + controls.push(new Rotate(options.rotateOptions)); + } + + const attributionControl = options.attribution !== undefined ? + options.attribution : true; + if (attributionControl) { + controls.push(new Attribution(options.attributionOptions)); + } + + return controls; +}