diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index c640895dd6..1d059fee6c 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1330,7 +1330,11 @@ OpenLayers.Map = OpenLayers.Class({ * {} */ getCenter: function () { - return this.center; + var center = null; + if (this.center) { + center = this.center.clone(); + } + return center; }, diff --git a/tests/Map.html b/tests/Map.html index 5e864f6f2b..fc53af7530 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -100,7 +100,7 @@ } function test_Map_center(t) { - t.plan(7); + t.plan(8); map = new OpenLayers.Map('map'); var baseLayer = new OpenLayers.Layer.WMS("Test Layer", "http://octo.metacarta.com/cgi-bin/mapserv?", @@ -128,6 +128,8 @@ t.ok( lonlat.equals(zero), "map center is correct after calling zoomToFullExtent" ); */ + map.getCenter().lon = 10; + t.ok( map.getCenter().equals(ll), "map.getCenter returns a clone of map.center"); } function test_Map_zoomend_event (t) {