[OpenLayers-Dev] smooth pan (animated)

Christopher Schmidt crschmidt at metacarta.com
Wed Jan 16 11:10:31 EST 2008


On Wed, Jan 16, 2008 at 04:42:06PM +0100, Pierre GIRAUD wrote:
> 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.

I'd say that the name 'dragging' is a poor choice, but that the idea
isn't that different from 'noEvent': the goal is to say "Don't do a
bunch of stuff that you could do, because we're going to send another
setCenter Real Soon Now -- so don't call events, or move the foobar, or
do that other thing, because you're just going to have to do it again,
and it won't make much difference."

With that interpretation, is noEvent really that different from
dragging? I'd like to understand how, if possible. 

> With a new 'noEvent' parameter, I can continue to call setCenter on
> each step without triggering too many events.

I think a cleaner setCenter implementation is well deserved at this
point, and we should ponder creating one.

> 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.

I'm going to pull a Schaub here, and suggest something rather radical:

We should split setCenter into two methods. We have all these various
callers of setCenter, and we don't have a way to differentiate between
'external' and 'internal' at the moment. I think that we should split
that into two functions:
 * setCenter is the external API used by users -- it has only two params
   (lonlat,zoom) and it then calls...
 * moveTo, internally, which takes a cleaner set of args: probably
   lonlat, zoom, {options} -- which has the current options embedded
   into it, and allows us to add in options for, for example, 'tween' or
   what have you.

We then change all the internal callers to use moveTo, and the external
callers can continue to use setCenter. 

Problems:
 * If users have written their own pieces of code which use setCenter,
   and depend on the stuff in the args, they will break.
     * Possible solution: Allow the setCenter call to continue to have
       the four args, and translate them internally to the new calling
       structure of moveTo.

Things this helps:
 * Determining whether the caller is internal or external. steCenter
   will set a flag in the options to say 'called externally', and we can
   look at that -- so you don't have recursive issues, since you only
   start the tween on things that were 'called externally' rather than
   internally.
  
Maybe this doesn't actually help, and it just seems like it does to me
-- thoughts?   

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list