diff --git a/lib/OpenLayers/Strategy/BBOX.js b/lib/OpenLayers/Strategy/BBOX.js index 36354ccb12..8ae78958aa 100644 --- a/lib/OpenLayers/Strategy/BBOX.js +++ b/lib/OpenLayers/Strategy/BBOX.js @@ -153,7 +153,8 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { return null; } var bounds = this.layer.map.getExtent(); - if(!this.layer.projection.equals(this.layer.map.getProjectionObject())) { + if(bounds && !this.layer.projection.equals( + this.layer.map.getProjectionObject())) { bounds = bounds.clone().transform( this.layer.map.getProjectionObject(), this.layer.projection ); diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index 60e190d2a4..746c915a33 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -284,8 +284,17 @@ strategies: [strategy] }); + // Make sure to test the case of a vector layer needing to be + // reprojected while the map is not yet centered + var layerReproject = new OpenLayers.Layer.Vector(null, { + protocol: new OpenLayers.Protocol(), + strategies: [new OpenLayers.Strategy.BBOX()], + projection: 'EPSG:900913' + }); + var map = new OpenLayers.Map("map"); map.addLayer(dummy); + map.addLayer(layerReproject); map.setCenter(new OpenLayers.LonLat(0, 0)); map.addLayer(layer);