Hi, That is happening because you're probably modifying what's returned by map.getCenter(). It's a bug in OL 2.7 that the object returned by getCenter() is the same the map uses internally. So if you change it, you're changing the center of the map.
To work you have to clone the result of getCenter() before using it: var center = map.getCenter().clone(); Now you can use center as you wish. Regards, João Duarte, SAPO Maps, http://maps.sapo.pt -----Original Message----- From: users-boun...@openlayers.org [mailto:users-boun...@openlayers.org] On Behalf Of brancusi Sent: segunda-feira, 9 de Fevereiro de 2009 12:20 To: users@openlayers.org Subject: [OpenLayers-Users] getCenter() in moveend handler problems Hiya I've created a moveend listener using; map.events.register("moveend",null,myeventhandler); and myeventhandler works fine. BUT if myeventhandler includes the code map.getCenter() to determine where the user might have dragged to, I find that as soon as I then try to drag again, the map resets to the position it was in before the eventhandler was called so you can never actually combine multiple drags to move around the map. If I use the navigation up down left right default controls, what happens is that the map moves (say) left, myeventhandler is called, and then the map moves back to where it was before the control was hit. If I remove the call to map.getCenter() then everything performs as expected. Does anyone know what the issue with calling getCenter() inside an eventhandler might be? Is there a better way to find out the current center of the map after a moveend event? TIA brancusi -- View this message in context: http://n2.nabble.com/getCenter%28%29-in-moveend-handler-problems-tp2296931p2 296931.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users