Improve types and docs for getStyle/setStyle

This commit is contained in:
Andreas Hocevar
2020-06-11 13:52:50 +02:00
parent 1ef103ed66
commit 04bc9ff0df
3 changed files with 26 additions and 22 deletions

View File

@@ -43,8 +43,9 @@ import {
* is defined by the z-index of the layer, the `zIndex` of the style and the render order of features.
* Higher z-index means higher priority. Within the same z-index, a feature rendered before another has
* higher priority.
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
* {@link module:ol/style} for default style which will be used if this is not defined.
* @property {import("../style/Style.js").StyleLike|null} [style] Layer style. When set to `null`, only
* features that have their own style will be rendered. See {@link module:ol/style} for default style
* which will be used if this is not set.
* @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will
* be recreated during animations. This means that no vectors will be shown clipped, but the
* setting will have a performance impact for large amounts of vector data. When set to `false`,
@@ -181,8 +182,7 @@ class BaseVectorLayer extends Layer {
/**
* Get the style for features. This returns whatever was passed to the `style`
* option at construction or to the `setStyle` method.
* @return {import("../style/Style.js").StyleLike}
* Layer style.
* @return {import("../style/Style.js").StyleLike|null|undefined} Layer style.
* @api
*/
getStyle() {
@@ -225,17 +225,17 @@ class BaseVectorLayer extends Layer {
/**
* Set the style for features. This can be a single style object, an array
* of styles, or a function that takes a feature and resolution and returns
* an array of styles. If it is `undefined` the default style is used. If
* it is `null` the layer has no style (a `null` style), so only features
* that have their own styles will be rendered in the layer. See
* an array of styles. If set to `null`, the layer has no style (a `null` style),
* so only features that have their own styles will be rendered in the layer. Call
* `setStyle()` without arguments to reset to the default style. See
* {@link module:ol/style} for information on the default style.
* @param {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction|null|undefined} style Layer style.
* @param {(import("../style/Style.js").StyleLike|null)=} opt_style Layer style.
* @api
*/
setStyle(style) {
this.style_ = style !== undefined ? style : createDefaultStyle;
setStyle(opt_style) {
this.style_ = opt_style !== undefined ? opt_style : createDefaultStyle;
this.styleFunction_ =
style === null ? undefined : toStyleFunction(this.style_);
opt_style === null ? undefined : toStyleFunction(this.style_);
this.changed();
}
}