make setOptions work for restrictedExtent change, like it was before #3062. r=bartvde (closes #3144)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11608 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-03-02 11:09:24 +00:00
parent fb5f081ea6
commit 2a12176915
2 changed files with 28 additions and 2 deletions

View File

@@ -739,7 +739,13 @@ OpenLayers.Map = OpenLayers.Class({
* options - {Object} Hashtable of options to tag to the map
*/
setOptions: function(options) {
var updatePxExtent = this.minPx &&
options.restrictedExtent != this.restrictedExtent;
OpenLayers.Util.extend(this, options);
// force recalculation of minPx and maxPx
updatePxExtent && this.moveTo(this.getCachedCenter(), this.zoom, {
forceZoomChange: true
});
},
/**

View File

@@ -1052,7 +1052,7 @@
}
function test_Map_restrictedExtent(t) {
t.plan(24);
t.plan(25);
var extent = new OpenLayers.Bounds(-180, -90, 180, 90);
var options = {
maxResolution: "auto"
@@ -1147,8 +1147,28 @@
"map extent not restricted with null restrictedExtent for se");
map.destroy();
extent = new OpenLayers.Bounds(8, 44.5, 19, 50);
var options = {
restrictedExtent: extent
};
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'}
);
map.addLayers([wms]);
map.zoomToExtent(extent);
map.zoomIn();
map.setOptions({restrictedExtent: null});
map.pan(-250, -250);
t.ok((map.getExtent().bottom == 48.3486328125 && map.getExtent().left == 7.45751953125), "Expected extent when toggling restrictedExtent");
map.destroy();
}
function test_Map_getResolutionForZoom(t) {
t.plan(2);
var map = new OpenLayers.Map("map");