In this commit 7325742, I have add a jQuery like interface for binding and triggering events. The idea is that classes will interact with each other like this (for example panning in the layer class)
this.map().on(geo.event.pan, function (arg) {
if (arg.layer !== this) {
this.trigger(geo.event.pan, arg);
}
});
this.on(geo.event.pan, function (arg) {
// layer specific implementation here
this.map().trigger(geo.event.pan, arg);
});
The only problem is that this kind of propagation through the tree will have to be coded for every event type. I'm wondering if it might be useful to add standard parent
/children
attributes to the object, then the map
would copy its layers
into children
and layer
would put the map
in parent
and the renderer
in children
, etc. This way we could implement this generically in geo.object
. Also, we would want to bind the triggerer to this
in the handler to prevent circular propagation. What does everyone think?
There are other features that could be implemented as well like namespacing of handlers, but I think that could be added later if needed.