diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index f861721c59..96744b4dd2 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -496,13 +496,16 @@ OpenLayers.Map = OpenLayers.Class({ this.projection.projCode : this.projection; OpenLayers.Util.applyDefaults(this, OpenLayers.Projection.defaults[projCode]); - // allow extents to be arrays + // allow extents and center to be arrays if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) { this.maxExtent = new OpenLayers.Bounds(this.maxExtent); } if (this.restrictedExtent && !(this.restrictedExtent instanceof OpenLayers.Bounds)) { this.restrictedExtent = new OpenLayers.Bounds(this.restrictedExtent); } + if (this.center && !(this.center instanceof OpenLayers.LonLat)) { + this.center = new OpenLayers.LonLat(this.center); + } // initialize layers array this.layers = []; diff --git a/tests/Control/Permalink.html b/tests/Control/Permalink.html index 4b07d3e2bb..843cdbf181 100644 --- a/tests/Control/Permalink.html +++ b/tests/Control/Permalink.html @@ -321,6 +321,29 @@ map.layers[1].setVisibility(false); t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink'); } + + function test_arrayCenter(t) { + t.plan(1); + var err; + try { + var map = new OpenLayers.Map({ + layers: [new OpenLayers.Layer(null, {isBaseLayer: true})], + controls: [ + new OpenLayers.Control.Permalink({anchor: true}) + ], + center: [0, 0], + zoom: 1 + }); + } catch (e) { + err = e; + } + if (err) { + t.fail("Map construction failure: " + err.message); + } else { + t.ok(true, "Map construction works"); + } + } +