[OpenLayers-Dev] Shouldn't getCenter return a clone?
Christopher Schmidt
crschmidt at metacarta.com
Wed Jan 14 11:01:46 EST 2009
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 whats
> being returned is this.center directly, instead of a clone.
>
>
>
> Shouldnt 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
More information about the Dev
mailing list