[OpenLayers-Dev] Shouldn't getCenter return a clone?
Christopher Schmidt
crschmidt at metacarta.com
Mon Jul 13 07:32:45 EDT 2009
On Sun, Jul 12, 2009 at 10:54:50PM -0700, mikani wrote:
>
> 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
Er, perhaps something in my message was unclear, but "Fixed in SVN" is
now "Fixed in OL 2.8."
-- Chris
> 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
> >> 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
> > _______________________________________________
> > 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.
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
--
Christopher Schmidt
MetaCarta
More information about the Dev
mailing list