[OpenLayers-Dev] Shouldn't getCenter return a clone?

mikani gina.m.dang at lmco.com
Mon Jul 13 01:54:50 EDT 2009


Example on how to fix this?  cloning the setCenter.  I've noticed this too
when I was expected to set it back to the original map

Christopher Schmidt-2 wrote:
> 
> On Wed, Jan 14, 2009 at 03:44:06PM -0000, Joao Duarte wrote:
>> Hi,
>> 
>>  
>> 
>> While I was developing my application, I got a strange behavior while
>> using
>> map.getCenter() and map.getExtent().
>> 
>>  
>> 
>> I was calling map.getCenter() and modifying the value I got in return.
>> Then
>> the map.getExtent() returned a strange bounding box.
>> 
>>  
>> 
>> After looking at the getCenter method of OpenLayers.Map, I found that
>> what’s
>> being returned is this.center directly, instead of a clone.
>> 
>>  
>> 
>> Shouldn’t getCenter return a clone to prevent modifications on the return
>> value from the user, like for example getSize?
> 
> This is fixed in OL SVN. You can workarund this in your application by
> always .clone()ing the returned setCenter for now, or upgrade to SVN.
> 
> -- Chris
> 
>>  
>> 
>> Best regards,
>> 
>>  
>> 
>> João Duarte
>> 
>>  <http://maps.sapo.pt> http://maps.sapo.pt
>> 
>>  
>> 
> 
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
> 
> 
> -- 
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> 
> 

-- 
View this message in context: http://n2.nabble.com/Shouldn%27t-getCenter-return-a-clone--tp2157467p3249000.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.



More information about the Dev mailing list