Skip to content

Commit

Permalink
Merge pull request openlayers#468 from bartvde/bboxstrategy
Browse files Browse the repository at this point in the history
Fix visibility and inRange issues with the BBOX strategy (r=@elemoine)
  • Loading branch information
Bart van den Eijnden committed May 15, 2012
2 parents 4e42dec + 44f9b81 commit adcf5bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
15 changes: 3 additions & 12 deletions lib/OpenLayers/Strategy/BBOX.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,11 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
if(activated) {
this.layer.events.on({
"moveend": this.update,
scope: this
});
this.layer.events.on({
"refresh": this.update,
"visibilitychanged": this.update,
scope: this
});
if(this.layer.visibility === true && this.layer.inRange === true) {
this.update();
} else {
this.layer.events.on({
"visibilitychanged": this.update,
scope: this
});
}
this.update();
}
return activated;
},
Expand Down Expand Up @@ -134,7 +125,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
update: function(options) {
var mapBounds = this.getMapBounds();
if (mapBounds !== null && ((options && options.force) ||
this.invalidBounds(mapBounds))) {
(this.layer.visibility && this.layer.calculateInRange() && this.invalidBounds(mapBounds)))) {
this.calculateBounds(mapBounds);
this.resolution = this.layer.map.getResolution();
this.triggerRead(options);
Expand Down
7 changes: 6 additions & 1 deletion tests/Strategy/BBOX.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@

// Test fix for Ticket #3142
function test_layerLoadedAfterBeingAdded(t) {
t.plan(2);
t.plan(3);

var dummy = new OpenLayers.Layer(null, {isBaseLayer: true});

Expand Down Expand Up @@ -341,6 +341,11 @@
// test that the strategy bounds were set
t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");
t.eq(layerOutOfRange.strategies[0].bounds, null, "Data not requested if layer is out of range");

layerOutOfRange.setVisibility(false);
layerOutOfRange.setVisibility(true);
t.eq(layerOutOfRange.strategies[0].bounds, null, "Data not requested if layer is out of range when switching visibility");

map.destroy();
}

Expand Down

0 comments on commit adcf5bb

Please sign in to comment.