Merge pull request #235 from bartvde/bbox
add noAbort option to OpenLayers.Strategy.BBOX (r=@ahocevar)
This commit is contained in:
@@ -124,9 +124,12 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
|||||||
* Callback function called on "moveend" or "refresh" layer events.
|
* Callback function called on "moveend" or "refresh" layer events.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* options - {Object} An object with a property named "force", this
|
* options - {Object} Optional object whose properties will determine
|
||||||
* property references a boolean value indicating if new data
|
* the behaviour of this Strategy
|
||||||
* must be incondtionally read.
|
*
|
||||||
|
* Valid options include:
|
||||||
|
* force - {Boolean} if true, new data must be unconditionally read.
|
||||||
|
* noAbort - {Boolean} if true, do not abort previous requests.
|
||||||
*/
|
*/
|
||||||
update: function(options) {
|
update: function(options) {
|
||||||
var mapBounds = this.getMapBounds();
|
var mapBounds = this.getMapBounds();
|
||||||
@@ -218,7 +221,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
|||||||
* returned by the layer protocol.
|
* returned by the layer protocol.
|
||||||
*/
|
*/
|
||||||
triggerRead: function(options) {
|
triggerRead: function(options) {
|
||||||
if (this.response) {
|
if (this.response && !(options && options.noAbort === true)) {
|
||||||
this.layer.protocol.abort(this.response);
|
this.layer.protocol.abort(this.response);
|
||||||
this.layer.events.triggerEvent("loadend");
|
this.layer.events.triggerEvent("loadend");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_update(t) {
|
function test_update(t) {
|
||||||
t.plan(5);
|
t.plan(7);
|
||||||
|
|
||||||
// Create a dummy layer that can act as the map base layer.
|
// Create a dummy layer that can act as the map base layer.
|
||||||
// This will be unnecessary if #1921 is addressed (allowing
|
// This will be unnecessary if #1921 is addressed (allowing
|
||||||
@@ -43,9 +43,10 @@
|
|||||||
var strategy = new OpenLayers.Strategy.BBOX({
|
var strategy = new OpenLayers.Strategy.BBOX({
|
||||||
ratio: 1 // makes for easier comparison to map bounds
|
ratio: 1 // makes for easier comparison to map bounds
|
||||||
});
|
});
|
||||||
|
var log = [];
|
||||||
var layer = new OpenLayers.Layer.Vector(null, {
|
var layer = new OpenLayers.Layer.Vector(null, {
|
||||||
isBaseLayer: true,
|
isBaseLayer: true,
|
||||||
protocol: new OpenLayers.Protocol(),
|
protocol: new OpenLayers.Protocol({abort: function(response) { log.push(response); }}),
|
||||||
strategies: [strategy]
|
strategies: [strategy]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,7 +62,14 @@
|
|||||||
* should be removed when the issue(s) described in #1835 are addressed.
|
* should be removed when the issue(s) described in #1835 are addressed.
|
||||||
*/
|
*/
|
||||||
strategy.update({force: true});
|
strategy.update({force: true});
|
||||||
|
strategy.response = {};
|
||||||
|
strategy.update({force: true});
|
||||||
|
t.eq(log.length, 1, "Response aborted");
|
||||||
|
log = [];
|
||||||
|
strategy.update({force: true});
|
||||||
|
strategy.update({force: true, noAbort: true});
|
||||||
|
t.eq(log.length, 0, "Response not aborted when noAbort is true");
|
||||||
|
|
||||||
// test that the strategy bounds were set
|
// test that the strategy bounds were set
|
||||||
t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");
|
t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user