diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index cfdc81b205..06f50a7c4a 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -249,14 +249,14 @@ class Overlay extends BaseObject { /** * Get the map associated with this overlay. - * @return {import("./PluggableMap.js").default|undefined} The map that the + * @return {import("./PluggableMap.js").default|null} The map that the * overlay is part of. * @observable * @api */ getMap() { - return /** @type {import("./PluggableMap.js").default|undefined} */ ( - this.get(Property.MAP) + return /** @type {import("./PluggableMap.js").default|null} */ ( + this.get(Property.MAP) || null ); } @@ -378,8 +378,8 @@ class Overlay extends BaseObject { /** * Set the map to be associated with this overlay. - * @param {import("./PluggableMap.js").default|undefined} map The map that the - * overlay is part of. + * @param {import("./PluggableMap.js").default|null} map The map that the + * overlay is part of. Pass `null` to just remove the overlay from the current map. * @observable * @api */ diff --git a/src/ol/control/Control.js b/src/ol/control/Control.js index b94f705b8d..2dde885ae8 100644 --- a/src/ol/control/Control.js +++ b/src/ol/control/Control.js @@ -69,7 +69,7 @@ class Control extends BaseObject { /** * @private - * @type {import("../PluggableMap.js").default} + * @type {import("../PluggableMap.js").default|null} */ this.map_ = null; @@ -98,7 +98,7 @@ class Control extends BaseObject { /** * Get the map associated with this control. - * @return {import("../PluggableMap.js").default|undefined} Map. + * @return {import("../PluggableMap.js").default|null} Map. * @api */ getMap() { @@ -107,9 +107,10 @@ class Control extends BaseObject { /** * Remove the control from its current map and attach it to the new map. + * Pass `null` to just remove the control from the current map. * Subclasses may set up event handlers to get notified about changes to * the map here. - * @param {import("../PluggableMap.js").default} [map] Map. + * @param {import("../PluggableMap.js").default|null} map Map. * @api */ setMap(map) { @@ -121,7 +122,7 @@ class Control extends BaseObject { } this.listenerKeys.length = 0; this.map_ = map; - if (this.map_) { + if (map) { const target = this.target_ ? this.target_ : map.getOverlayContainerStopEvent(); diff --git a/src/ol/control/FullScreen.js b/src/ol/control/FullScreen.js index 429c1bfc90..2ed725b96c 100644 --- a/src/ol/control/FullScreen.js +++ b/src/ol/control/FullScreen.js @@ -281,9 +281,10 @@ class FullScreen extends Control { /** * Remove the control from its current map and attach it to the new map. + * Pass `null` to just remove the control from the current map. * Subclasses may set up event handlers to get notified about changes to * the map here. - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. * @api */ setMap(map) { diff --git a/src/ol/control/MousePosition.js b/src/ol/control/MousePosition.js index e95a4b3116..8568f55148 100644 --- a/src/ol/control/MousePosition.js +++ b/src/ol/control/MousePosition.js @@ -212,9 +212,10 @@ class MousePosition extends Control { /** * Remove the control from its current map and attach it to the new map. + * Pass `null` to just remove the control from the current map. * Subclasses may set up event handlers to get notified about changes to * the map here. - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. * @api */ setMap(map) { diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 140c3afa5e..c127ffcd1c 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -267,9 +267,10 @@ class OverviewMap extends Control { /** * Remove the control from its current map and attach it to the new map. + * Pass `null` to just remove the control from the current map. * Subclasses may set up event handlers to get notified about changes to * the map here. - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. * @api */ setMap(map) { diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index 93ebc8c7c1..c86a58f9b5 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -161,9 +161,10 @@ class ZoomSlider extends Control { /** * Remove the control from its current map and attach it to the new map. + * Pass `null` to just remove the control from the current map. * Subclasses may set up event handlers to get notified about changes to * the map here. - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. * @api */ setMap(map) { diff --git a/src/ol/layer/Layer.js b/src/ol/layer/Layer.js index 0c55fdc460..d788f3e7ab 100644 --- a/src/ol/layer/Layer.js +++ b/src/ol/layer/Layer.js @@ -47,7 +47,7 @@ import {listen, unlistenByKey} from '../events.js'; * @property {SourceType} [source] Source for this layer. If not provided to the constructor, * the source can be set by calling {@link module:ol/layer/Layer~Layer#setSource layer.setSource(source)} after * construction. - * @property {import("../PluggableMap.js").default} [map] Map. + * @property {import("../PluggableMap.js").default|null} [map] Map. * @property {RenderFunction} [render] Render function. Takes the frame state as input and is expected to return an * HTML element. Will overwrite the default rendering for the layer. * @property {Object} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`. @@ -71,7 +71,7 @@ import {listen, unlistenByKey} from '../events.js'; /** * @classdesc * Base class from which all layer types are derived. This should only be instantiated - * in the case where a custom layer is be added to the map with a custom `render` function. + * in the case where a custom layer is added to the map with a custom `render` function. * Such a function can be specified in the `options` object, and is expected to return an HTML element. * * A visual representation of raster or vector map data. @@ -268,7 +268,7 @@ class Layer extends BaseLayer { /** * For use inside the library only. - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. */ setMapInternal(map) { this.set(LayerProperty.MAP, map); @@ -276,7 +276,7 @@ class Layer extends BaseLayer { /** * For use inside the library only. - * @return {import("../PluggableMap.js").default} Map. + * @return {import("../PluggableMap.js").default|null} Map. */ getMapInternal() { return this.get(LayerProperty.MAP); @@ -291,7 +291,7 @@ class Layer extends BaseLayer { * * To add the layer to a map and have it managed by the map, use * {@link module:ol/Map~Map#addLayer} instead. - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. * @api */ setMap(map) { diff --git a/src/ol/render/Box.js b/src/ol/render/Box.js index 4b09e98033..d09fb0b99f 100644 --- a/src/ol/render/Box.js +++ b/src/ol/render/Box.js @@ -29,7 +29,7 @@ class RenderBox extends Disposable { /** * @private - * @type {import("../PluggableMap.js").default} + * @type {import("../PluggableMap.js").default|null} */ this.map_ = null; @@ -68,7 +68,7 @@ class RenderBox extends Disposable { } /** - * @param {import("../PluggableMap.js").default} map Map. + * @param {import("../PluggableMap.js").default|null} map Map. */ setMap(map) { if (this.map_) {