[OpenLayers-Dev] smooth pan (animated)

Pierre GIRAUD bluecarto at gmail.com
Wed Jan 16 10:42:06 EST 2008


While trying to get further on this code, I'm facing some problems I
would like to tell you.

The new PanTo method creates in some cases (lonlat to pan to is in the
current extent) a Tween object and calls setCenter on each step of the
animation.

Tim thought it would be better if we could have an 'animated' argument
added to the setCenter method signature. The tween object would be
instanciated in there. This would be great. However, the setCenter
method appears to be a real mess to me now because it tests a big
amount of different parameters (dragging, zoomChanged, etc...) . And I
don't really know how I will be able deal with recursive calls if
needed.
One other thing is that setCenter can be called to recenter the map to
new coordinates but also to another zoom level. If zoom level changes,
I don't really think we need to pan the map with an animation effect
(regardless to the transition effect proposed by Paul).
This is the main reason why I created a new specific panTo method that
only allows to recenter the map at the same zoom level. (It exists in
google API).

One other problem though : while playing the animation, on each step,
the map.setCenter method is called. This way, map events (movestart,
move, and moveend) are triggered several times. This may be weird if
the application has listeners registered on those events.
In the map manual (with mouse) drag control, we prevent those events
to be triggered by calling setCenter with a specific boolean (and
optional) "dragging" parameter. Some may say, "what about using this
paremeter ?". Because, as already reported by Eric [1], this dragging
parameter is probably not well documented and it has other
implications. He's proposition to have a new 'noEvent' parameter suits
my needs.
With a new 'noEvent' parameter, I can continue to call setCenter on
each step without triggering too many events.

If this is clear enough, I would be pleased if you can give me your
opinion on that. If it isn't, don't hesitate to ask for more
explanations.

Regards,
Pierre

[1] - http://trac.openlayers.org/ticket/967



On Dec 21, 2007 6:12 PM, Pierre GIRAUD <bluecarto at gmail.com> wrote:
> Hi all,
>
> Beginning the review of the great code already written to handle the
> google-like popups, I figured out that there was many different thing
> addressed there.
> In the code graciously provided by Tim Coulter (and written with the
> help of many other guys), different features are mixed and I think
> this would be better if we get into trunk one at a time.
>
> One first functionnality I found was the map slide. This is
> specifically used to get the popup entirely visible but this smooth
> panning thing is something many people has been asking for for long
> [1].
> I worked on this and I want to propose what follows.
>
> First, I imagined having a panTo method allow user to pan to a new
> given center. Like in google API, I wanted this pan to be smooth only
> if the new center is in the current visible extent. (quite easy).
>
> For the transition effect, I relied on the Robert Penner's famous
> Tween and Easing algorithms. Given an easing mode (linear, exponential
> ...), two objects (from and to) with one or more properties, a time
> interval and a number of steps, it returns intermediate objects with
> updated properties.
> This transition handler is imagined to be used for different purposes.
> For example, it could also be used to manage the popup size update.
> Paul (and other folks) are probably interested in testing it for the
> transition zoom effect. This might simplify code.
>
> An working example is already available [3].
>
> I'm looking for feedbacks.
>
> Regards,
> Pierre
>
> [1] http://trac.openlayers.org/ticket/110
> [2] http://www.robertpenner.com/easing/
> [3] http://dev.openlayers.org/sandbox/camptocamp/panto/examples/tween.html
>



More information about the Dev mailing list