Merge pull request #11174 from ahocevar/set-get-style-types-docs
Improve types and docs for getStyle/setStyle
This commit is contained in:
+11
-8
@@ -178,7 +178,7 @@ class Feature extends BaseObject {
|
|||||||
/**
|
/**
|
||||||
* Get the feature's style. Will return what was provided to the
|
* Get the feature's style. Will return what was provided to the
|
||||||
* {@link module:ol/Feature~Feature#setStyle} method.
|
* {@link module:ol/Feature~Feature#setStyle} method.
|
||||||
* @return {import("./style/Style.js").StyleLike} The feature style.
|
* @return {import("./style/Style.js").StyleLike|undefined} The feature style.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getStyle() {
|
getStyle() {
|
||||||
@@ -234,16 +234,19 @@ class Feature extends BaseObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the style for the feature. This can be a single style object, an array
|
* Set the style for the feature to override the layer style. This can be a
|
||||||
* of styles, or a function that takes a resolution and returns an array of
|
* single style object, an array of styles, or a function that takes a
|
||||||
* styles. If it is `null` the feature has no style (a `null` style).
|
* resolution and returns an array of styles. To unset the feature style, call
|
||||||
* @param {import("./style/Style.js").StyleLike} style Style for this feature.
|
* `setStyle()` without arguments or a falsey value.
|
||||||
|
* @param {import("./style/Style.js").StyleLike=} opt_style Style for this feature.
|
||||||
* @api
|
* @api
|
||||||
* @fires module:ol/events/Event~BaseEvent#event:change
|
* @fires module:ol/events/Event~BaseEvent#event:change
|
||||||
*/
|
*/
|
||||||
setStyle(style) {
|
setStyle(opt_style) {
|
||||||
this.style_ = style;
|
this.style_ = opt_style;
|
||||||
this.styleFunction_ = !style ? undefined : createStyleFunction(style);
|
this.styleFunction_ = !opt_style
|
||||||
|
? undefined
|
||||||
|
: createStyleFunction(opt_style);
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,10 @@ const SelectEventType = {
|
|||||||
* in the map and should return `true` for layers that you want to be
|
* in the map and should return `true` for layers that you want to be
|
||||||
* selectable. If the option is absent, all visible layers will be considered
|
* selectable. If the option is absent, all visible layers will be considered
|
||||||
* selectable.
|
* selectable.
|
||||||
* @property {import("../style/Style.js").StyleLike} [style]
|
* @property {import("../style/Style.js").StyleLike|null} [style]
|
||||||
* Style for the selected features. By default the default edit style is used
|
* Style for the selected features. By default the default edit style is used
|
||||||
* (see {@link module:ol/style}).
|
* (see {@link module:ol/style}). Set to `null` if this interaction should not apply
|
||||||
|
* any style changes for selected features.
|
||||||
* If set to a falsey value, the selected feature's style will not change.
|
* If set to a falsey value, the selected feature's style will not change.
|
||||||
* @property {import("../events/condition.js").Condition} [removeCondition] A function
|
* @property {import("../events/condition.js").Condition} [removeCondition] A function
|
||||||
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
|
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
|
||||||
@@ -367,7 +368,7 @@ class Select extends Interaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {import("../style/Style.js").default|Array.<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction|null} Select style.
|
* @return {import("../style/Style.js").StyleLike|null} Select style.
|
||||||
*/
|
*/
|
||||||
getStyle() {
|
getStyle() {
|
||||||
return this.style_;
|
return this.style_;
|
||||||
|
|||||||
+11
-11
@@ -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.
|
* 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 z-index means higher priority. Within the same z-index, a feature rendered before another has
|
||||||
* higher priority.
|
* higher priority.
|
||||||
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
|
* @property {import("../style/Style.js").StyleLike|null} [style] Layer style. When set to `null`, only
|
||||||
* {@link module:ol/style} for default style which will be used if this is not defined.
|
* 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
|
* @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
|
* 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`,
|
* 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`
|
* Get the style for features. This returns whatever was passed to the `style`
|
||||||
* option at construction or to the `setStyle` method.
|
* option at construction or to the `setStyle` method.
|
||||||
* @return {import("../style/Style.js").StyleLike}
|
* @return {import("../style/Style.js").StyleLike|null|undefined} Layer style.
|
||||||
* Layer style.
|
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getStyle() {
|
getStyle() {
|
||||||
@@ -225,17 +225,17 @@ class BaseVectorLayer extends Layer {
|
|||||||
/**
|
/**
|
||||||
* Set the style for features. This can be a single style object, an array
|
* 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
|
* 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
|
* an array of styles. If set to `null`, the layer has no style (a `null` style),
|
||||||
* it is `null` the layer has no style (a `null` style), so only features
|
* so only features that have their own styles will be rendered in the layer. Call
|
||||||
* that have their own styles will be rendered in the layer. See
|
* `setStyle()` without arguments to reset to the default style. See
|
||||||
* {@link module:ol/style} for information on the default style.
|
* {@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
|
* @api
|
||||||
*/
|
*/
|
||||||
setStyle(style) {
|
setStyle(opt_style) {
|
||||||
this.style_ = style !== undefined ? style : createDefaultStyle;
|
this.style_ = opt_style !== undefined ? opt_style : createDefaultStyle;
|
||||||
this.styleFunction_ =
|
this.styleFunction_ =
|
||||||
style === null ? undefined : toStyleFunction(this.style_);
|
opt_style === null ? undefined : toStyleFunction(this.style_);
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user