[OpenLayers-Dev] panning enhancements

Pierre GIRAUD bluecarto at gmail.com
Mon Jun 16 08:41:15 EDT 2008


Hello,

Once again here are some thoughts about enhancements to the panning in
OpenLayers.

Some time ago, one user (Tono) complained about issues with panning
being slow on old machines and proposed to fix this by modifying the
panMap method and introduce a timeout so that map is moved every 25
ms.
http://trac.openlayers.org/ticket/1509

I must admit that I also find that, in some cases, dragging the map is
not as smooth as I would expect. In particular, when we want to put an
OpenLayers map into a complex Ext layout, the map panning is often
jerky, at least on my computer.

By digging into it myself, I opened firebug and profiled the pan of a
map whose div is intentionally put into a (relatively) complex HTML
code. The profiler tells me that the most called method is
getMousePosition with more than 50%. This is really huge, I think.

I'm convinced that there could be something done and I feel confident
with my first tests.

Please take a look at
http://dev.openlayers.org/sandbox/camptocamp/getmouseposition/examples/getmouseposition.html.

In this example, I rewrote OL.Events.getMousePosition to avoid
expensive calculations and cache some values. Indeed, in my opinion,
scrollLeft/scrollTop and clientLeft/clientTop are relatively static.
I also think that we have enough events available for window or
document to manage modifications on those values if required.

I launched the profiler again and getMousePosition is now the 8th or
9th most called method and takes only 3 or 4% of the process. This
sounds better.

Please give me feedbacks on this. I may be completely wrong, don't
hesitate to yell at me if this is the case.

Regards

Pierre



More information about the Dev mailing list