Don't override tileSize, maxExtent and theme when calling
Map.setOptions(). Thanks pspencer for the review. (Closes #1206) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5505 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -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);
|
||||
},
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user