diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index ae695bdd6a..8ea1d1e6a1 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -271,9 +271,19 @@ OpenLayers.Map = OpenLayers.Class({ * (end) */ initialize: function (div, options) { + + // Simple-type defaults are set in class definition. + // Now set complex-type defaults + this.tileSize = new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH, + OpenLayers.Map.TILE_HEIGHT); - //set the default options - this.setOptions(options); + this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90); + + this.theme = OpenLayers._getScriptLocation() + + 'theme/default/style.css'; + + // now override default options + OpenLayers.Util.extend(this, options); this.id = OpenLayers.Util.createUniqueID("OpenLayers.Map_"); @@ -422,19 +432,6 @@ OpenLayers.Map = OpenLayers.Class({ * options - {Object} Hashtable of options to tag to the map */ setOptions: function(options) { - - // Simple-type defaults are set in class definition. - // Now set complex-type defaults - this.tileSize = new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH, - OpenLayers.Map.TILE_HEIGHT); - - this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90); - - this.theme = OpenLayers._getScriptLocation() + - 'theme/default/style.css'; - - // now add the options declared by the user - // (these will override defaults) OpenLayers.Util.extend(this, options); }, diff --git a/tests/test_Map.html b/tests/test_Map.html index 2835366ff5..8ae2fdffce 100644 --- a/tests/test_Map.html +++ b/tests/test_Map.html @@ -33,6 +33,16 @@ t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" ); } + function test_Map_setOptions(t) { + t.plan(2); + map = new OpenLayers.Map('map', {maxExtent: new OpenLayers.Bounds(100, 200, 300, 400)}); + map.setOptions({theme: 'foo'}); + + t.eq(map.theme, 'foo', "theme is correctly set by setOptions"); + t.ok(map.maxExtent.equals(new OpenLayers.Bounds(100, 200, 300, 400)), + "maxExtent is correct after calling setOptions"); + } + function test_02_Map_center(t) { t.plan(3); map = new OpenLayers.Map('map');