Improve some nullable map types

Closes #13326
This commit is contained in:
EvertEt
2022-02-04 09:53:58 +01:00
parent 5cfb634d89
commit 15de4bb5ab
8 changed files with 22 additions and 17 deletions

View File

@@ -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|undefined|null} map The map that the
* overlay is part of. Pass `null` to just remove the overlay from the current map.
* @observable
* @api
*/

View File

@@ -69,7 +69,7 @@ class Control extends BaseObject {
/**
* @private
* @type {import("../PluggableMap.js").default}
* @type {import("../PluggableMap.js").default|undefined|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|undefined|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();

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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<string, *>} [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) {

View File

@@ -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_) {