Merge pull request #918 from twpayne/source-change-events

Source change events
This commit is contained in:
Tom Payne
2013-08-21 07:40:54 -07:00
2 changed files with 19 additions and 0 deletions

View File

@@ -28,6 +28,9 @@ ol.layer.Layer = function(options) {
*/
this.source_ = options.source;
goog.events.listen(this.source_, goog.events.EventType.CHANGE,
this.handleSourceChange_, false, this);
if (!this.source_.isReady()) {
goog.events.listenOnce(this.source_, goog.events.EventType.LOAD,
this.handleSourceLoad_, false, this);
@@ -78,6 +81,14 @@ ol.layer.Layer.prototype.getSource = function() {
};
/**
* @private
*/
ol.layer.Layer.prototype.handleSourceChange_ = function() {
this.dispatchChangeEvent();
};
/**
* @private
*/

View File

@@ -49,6 +49,14 @@ ol.source.Source = function(options) {
goog.inherits(ol.source.Source, goog.events.EventTarget);
/**
* @protected
*/
ol.source.Source.prototype.dispatchChangeEvent = function() {
this.dispatchEvent(goog.events.EventType.CHANGE);
};
/**
* @protected
*/