Simplify events and store listeners only in one place
This commit is contained in:
@@ -80,9 +80,7 @@ class LayerGroup extends BaseLayer {
|
||||
*/
|
||||
this.listenerKeys_ = {};
|
||||
|
||||
listen(this,
|
||||
getChangeEventType(Property.LAYERS),
|
||||
this.handleLayersChanged_, this);
|
||||
this.addEventListener(getChangeEventType(Property.LAYERS), this.handleLayersChanged_);
|
||||
|
||||
if (layers) {
|
||||
if (Array.isArray(layers)) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/layer/Heatmap
|
||||
*/
|
||||
import {listen} from '../events.js';
|
||||
import {getChangeEventType} from '../Object.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import VectorLayer from './Vector.js';
|
||||
@@ -83,9 +82,7 @@ class Heatmap extends VectorLayer {
|
||||
*/
|
||||
this.gradient_ = null;
|
||||
|
||||
listen(this,
|
||||
getChangeEventType(Property.GRADIENT),
|
||||
this.handleGradientChanged_, this);
|
||||
this.addEventListener(getChangeEventType(Property.GRADIENT), this.handleGradientChanged_);
|
||||
|
||||
this.setGradient(options.gradient ? options.gradient : DEFAULT_GRADIENT);
|
||||
|
||||
|
||||
@@ -121,9 +121,7 @@ class Layer extends BaseLayer {
|
||||
this.setMap(options.map);
|
||||
}
|
||||
|
||||
listen(this,
|
||||
getChangeEventType(LayerProperty.SOURCE),
|
||||
this.handleSourcePropertyChange_, this);
|
||||
this.addEventListener(getChangeEventType(LayerProperty.SOURCE), this.handleSourcePropertyChange_);
|
||||
|
||||
const source = options.source ? /** @type {SourceType} */ (options.source) : null;
|
||||
this.setSource(source);
|
||||
|
||||
Reference in New Issue
Block a user