Allow center to be provided to map constructor without layers. r=bartvde (closes #2561)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10169 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -594,13 +594,12 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
|
|
||||||
// add any initial layers
|
// add any initial layers
|
||||||
if (options && options.layers) {
|
if (options && options.layers) {
|
||||||
this.addLayers(options.layers);
|
this.addLayers(options.layers);
|
||||||
}
|
// set center (and optionally zoom)
|
||||||
|
if (options.center) {
|
||||||
// set center (and optionally zoom)
|
// zoom can be undefined here
|
||||||
if (options && options.center) {
|
this.setCenter(options.center, options.zoom);
|
||||||
// zoom can be undefined here
|
}
|
||||||
this.setCenter(options.center, options.zoom);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1557,19 +1557,19 @@
|
|||||||
var map, msg;
|
var map, msg;
|
||||||
|
|
||||||
|
|
||||||
// try setting center without layers, this is not supported
|
// try setting center without layers, this has no effect
|
||||||
var failed = false;
|
var failed = false;
|
||||||
try {
|
try {
|
||||||
map = new OpenLayers.Map({
|
map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map",
|
||||||
center: new OpenLayers.LonLat(1, 2)
|
center: new OpenLayers.LonLat(1, 2)
|
||||||
});
|
});
|
||||||
msg = "center set with no layers";
|
msg = "center option without layers has no effect";
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failed = true;
|
failed = true;
|
||||||
msg = "center cannot be set without layers";
|
msg = "center option without layers throws error";
|
||||||
}
|
}
|
||||||
t.ok(failed, msg);
|
t.ok(!failed, msg);
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user