Allowing layers, center, and zoom to be set in the layer constructor. r=ahocevar (closes #2480)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10044 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -486,6 +486,9 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
// now override default options
|
||||
OpenLayers.Util.extend(this, options);
|
||||
|
||||
// initialize layers array
|
||||
this.layers = [];
|
||||
|
||||
this.id = OpenLayers.Util.createUniqueID("OpenLayers.Map_");
|
||||
|
||||
this.div = OpenLayers.Util.getElement(div);
|
||||
@@ -564,8 +567,6 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
document.getElementsByTagName('head')[0].appendChild(cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
this.layers = [];
|
||||
|
||||
if (this.controls == null) {
|
||||
if (OpenLayers.Control != null) { // running full or lite?
|
||||
@@ -590,6 +591,17 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
|
||||
// always call map.destroy()
|
||||
OpenLayers.Event.observe(window, 'unload', this.unloadDestroy);
|
||||
|
||||
// add any initial layers
|
||||
if (options && options.layers) {
|
||||
this.addLayers(options.layers);
|
||||
}
|
||||
|
||||
// set center (and optionally zoom)
|
||||
if (options && options.center) {
|
||||
// zoom can be undefined here
|
||||
this.setCenter(options.center, options.zoom);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user