[OpenLayers-Users] animate panning problem
Pierre GIRAUD
bluecarto at gmail.com
Wed Oct 8 07:25:57 EDT 2008
What about calling map.panTo which should do the job for you ?
http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.panTo
Regards,
Pierre
On Wed, Oct 8, 2008 at 12:36 PM, Simo D <simone.dalmasso at gmail.com> wrote:
>
> Hi, I'm trying to use an animated panning on a map using OpenLayers.Tween.
> What I want is that the map recenter where I've clicked. The animation works
> but the movement is exagerate and strange. My code is:
> var tween, events;
>
> tween = new OpenLayers.Tween(OpenLayers.Easing.Linear.easeIn);
>
> events = new OpenLayers.Events(null,
> OpenLayers.Util.getElement('map'), null, true);
> events.register("click", null, moveMap);
>
> function moveMap(e) {
> var viewport = OpenLayers.Util.getElement('map');
> var mapCenter = map.getPixelFromLonLat(map.getCenter());
> var viewportPosition = OpenLayers.Util.pagePosition(viewport);
> e.xy = events.getMousePosition(e);
> var from = {
> x: mapCenter.x+viewportPosition[0],
> y: mapCenter.y+viewportPosition[1]
> };
> var to = {
> x: e.xy.x,
> y: e.xy.y
> }
>
> var callbacks = {
> eachStep: function(value) {
> map.setCenter(map.getLonLatFromPixel(new
> OpenLayers.Pixel(value.x-viewportPosition[0],
> value.y-viewportPosition[1])));
> }
> }
>
> var duration = 50;
>
> tween.start(from, to, duration, {callbacks: callbacks});
>
> }
>
> Thanks for any help.
>
> Simone
> --
> View this message in context: http://www.nabble.com/animate-panning-problem-tp19876306p19876306.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list