Commit a change to the Strategy/Fixed to behave more like GeoRSS/Text/GML
layers, and not load by default if the layer is not visible. Includes tests. Default Behavior can be changed with 'OpenLayers.Strategy.Fixed.prototype.preload=true;'. With review from elemoine, comments from tschaub, review from me. Patch by Edgemaster. (Closes #1852) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8775 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -14,6 +14,14 @@
|
||||
* - <OpenLayers.Strategy>
|
||||
*/
|
||||
OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
|
||||
/**
|
||||
* APIProperty: preload
|
||||
* {Boolean} Load data before layer made visible. Enabling this may result
|
||||
* in considerable overhead if your application loads many data layers
|
||||
* that are not visible by default. Default is true.
|
||||
*/
|
||||
preload: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Strategy.Fixed
|
||||
@@ -37,8 +45,7 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
|
||||
/**
|
||||
* Method: activate
|
||||
* Activate the strategy: reads all features from the protocol and add them
|
||||
* to the layer.
|
||||
* Activate the strategy: load data or add listener to load when visible
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} True if the strategy was successfully activated or false if
|
||||
@@ -46,14 +53,33 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
*/
|
||||
activate: function() {
|
||||
if(OpenLayers.Strategy.prototype.activate.apply(this, arguments)) {
|
||||
this.layer.protocol.read({
|
||||
callback: this.merge,
|
||||
scope: this
|
||||
});
|
||||
if(this.layer.visibility == true || this.preload) {
|
||||
this.load();
|
||||
} else {
|
||||
this.layer.events.on({
|
||||
"visibilitychanged": this.load,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: load
|
||||
* Tells protocol to load data and unhooks the visibilitychanged event
|
||||
*/
|
||||
load: function() {
|
||||
this.layer.protocol.read({
|
||||
callback: this.merge,
|
||||
scope: this
|
||||
});
|
||||
this.layer.events.un({
|
||||
"visibilitychanged": this.load,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: merge
|
||||
|
||||
Reference in New Issue
Block a user