[OpenLayers-Users] animate panning problem
Simo D
simone.dalmasso at gmail.com
Wed Oct 8 06:36:13 EDT 2008
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.
More information about the Users
mailing list