Store the original map options into 'options' property
This commit is contained in:
@@ -239,6 +239,12 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
*/
|
*/
|
||||||
panRatio: 1.5,
|
panRatio: 1.5,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: options
|
||||||
|
* {Object} The options object passed to the class constructor. Read-only.
|
||||||
|
*/
|
||||||
|
options: null,
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -480,6 +486,9 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
this.theme = OpenLayers._getScriptLocation() +
|
this.theme = OpenLayers._getScriptLocation() +
|
||||||
'theme/default/style.css';
|
'theme/default/style.css';
|
||||||
|
|
||||||
|
// backup original options
|
||||||
|
this.options = OpenLayers.Util.extend({}, options);
|
||||||
|
|
||||||
// now override default options
|
// now override default options
|
||||||
OpenLayers.Util.extend(this, options);
|
OpenLayers.Util.extend(this, options);
|
||||||
|
|
||||||
@@ -731,6 +740,7 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
this.events.destroy();
|
this.events.destroy();
|
||||||
this.events = null;
|
this.events = null;
|
||||||
|
|
||||||
|
this.options = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2000,6 +2000,23 @@
|
|||||||
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
|
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_options(t) {
|
||||||
|
t.plan(2);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
t.eq(map.options, {}, 'map.options is empty with no options');
|
||||||
|
map.destroy();
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
resolutions: [1,2,3,5],
|
||||||
|
projection: "EPSG:4326",
|
||||||
|
units: 'm'
|
||||||
|
};
|
||||||
|
var map = new OpenLayers.Map('map', options);
|
||||||
|
t.eq(map.options, options, 'map.options is a copy of the constructor option');
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
function test_adjustZoom(t) {
|
function test_adjustZoom(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
|
|||||||
Reference in New Issue
Block a user