Strategy.Fixed should listen to refresh event, (Closes #1939), r=tschaub
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9164 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -299,7 +299,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
* the refresh event.
|
||||
*/
|
||||
refresh: function(obj) {
|
||||
if(this.inRange && this.visibility) {
|
||||
if(this.calculateInRange() && this.visibility) {
|
||||
this.events.triggerEvent("refresh", obj);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -53,6 +53,10 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
*/
|
||||
activate: function() {
|
||||
if(OpenLayers.Strategy.prototype.activate.apply(this, arguments)) {
|
||||
this.layer.events.on({
|
||||
"refresh": this.load,
|
||||
scope: this
|
||||
});
|
||||
if(this.layer.visibility == true || this.preload) {
|
||||
this.load();
|
||||
} else {
|
||||
@@ -66,16 +70,38 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: deactivate
|
||||
* Deactivate the strategy. Undo what is done in <activate>.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The strategy was successfully deactivated.
|
||||
*/
|
||||
deactivate: function() {
|
||||
var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);
|
||||
if(deactivated) {
|
||||
this.layer.events.un({
|
||||
"refresh": this.load,
|
||||
"visibilitychanged": this.load,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
return deactivated;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: load
|
||||
* Tells protocol to load data and unhooks the visibilitychanged event
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} options to pass to protocol read.
|
||||
*/
|
||||
load: function() {
|
||||
load: function(options) {
|
||||
this.layer.events.triggerEvent("loadstart");
|
||||
this.layer.protocol.read({
|
||||
this.layer.protocol.read(OpenLayers.Util.applyDefaults({
|
||||
callback: this.merge,
|
||||
scope: this
|
||||
});
|
||||
}, options));
|
||||
this.layer.events.un({
|
||||
"visibilitychanged": this.load,
|
||||
scope: this
|
||||
@@ -87,6 +113,7 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
* Add all features to the layer.
|
||||
*/
|
||||
merge: function(resp) {
|
||||
this.layer.destroyFeatures();
|
||||
var features = resp.features;
|
||||
if (features && features.length > 0) {
|
||||
var remote = this.layer.projection;
|
||||
|
||||
Reference in New Issue
Block a user