New eventListeners APIProperty for OpenLayers.Tile.
Same behavior as Map.eventListeners or Layer.eventListeners.
New listeners can be registered using the options parameter:
new OpenLayers.Tile.Image(layer, position, bounds, null, size, {
eventListeners: {
loadstart: function(evt) {
// ...
},
loadend: function(evt) {
// ...
}
}
});
This commit is contained in:
@@ -38,6 +38,15 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
*/
|
||||
events: null,
|
||||
|
||||
/**
|
||||
* APIProperty: eventListeners
|
||||
* {Object} If set as an option at construction, the eventListeners
|
||||
* object will be registered with <OpenLayers.Events.on>. Object
|
||||
* structure must be a listeners object as shown in the example for
|
||||
* the events.on method.
|
||||
*/
|
||||
eventListeners: null,
|
||||
|
||||
/**
|
||||
* Property: id
|
||||
* {String} null
|
||||
@@ -109,10 +118,13 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
|
||||
//give the tile a unique id based on its BBOX.
|
||||
this.id = OpenLayers.Util.createUniqueID("Tile_");
|
||||
|
||||
this.events = new OpenLayers.Events(this);
|
||||
|
||||
OpenLayers.Util.extend(this, options);
|
||||
|
||||
this.events = new OpenLayers.Events(this);
|
||||
if (this.eventListeners instanceof Object) {
|
||||
this.events.on(this.eventListeners);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -139,7 +151,11 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
this.size = null;
|
||||
this.position = null;
|
||||
|
||||
if (this.eventListeners) {
|
||||
this.events.un(this.eventListeners);
|
||||
}
|
||||
this.events.destroy();
|
||||
this.eventListeners = null;
|
||||
this.events = null;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user