map.getCenter() should return a cloned center, so that (for example)
transforming the center doesn't break the map. patch by edgemaster, r=me, (Closes #1853) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8410 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1330,7 +1330,11 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
* {<OpenLayers.LonLat>}
|
||||
*/
|
||||
getCenter: function () {
|
||||
return this.center;
|
||||
var center = null;
|
||||
if (this.center) {
|
||||
center = this.center.clone();
|
||||
}
|
||||
return center;
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user