[MapQuery] Make it possible to add event listeners to the map options?

Volker Mische volker.mische at gmail.com
Thu Mar 8 06:21:05 EST 2012


Soon you will be able to add listeners as a hash:

map.bind({
  addlayer: function() {},
  removelayer: function() {}
});

I'd vote 0 for adding binds to the map objects.

So do other people like or hate it?

Cheers,
  Volker


On 03/07/2012 11:49 AM, Christian Wygoda wrote:
> One can easily ship around this, but I'm used to give my listeners as
> part of the options from both OpenLayers as well as jQuery. And as long
> as one does not add listeners, i'd still be JSON, right?
> 
> This would make stuff like this possible:
> 
> var map = $('#foo').mapQuery({
>   layers: layers,
>   listeners: {
>     'mqAddLayer': function() {}
>   },
>   /* ... */
> });
> 
> (I'd prefer to have the listeners in an hash...)
> 
> Now I have to do
> 
> var map = $('#foo).mapQuery({
>   /* ... */
> });
> map.events.bind('mqLayerAdd', function() {});
> map.layers(layers);
> 
> Would it hurt?
> 
> Cheers,
>   C
> 
> On Wed, Mar 7, 2012 at 11:29 AM, Volker Mische <volker.mische at gmail.com
> <mailto:volker.mische at gmail.com>> wrote:
> 
>     On 03/07/2012 10:20 AM, Christian Wygoda wrote:
>     > Hi,
>     >
>     > I am contemplating the idea of passing event listeners to the map
>     options...
>     > Then one could pass a listener for the mqLayerAdd event plus layers in
>     > the map options.
>     >
>     > Does that sound reasonable?
>     >
>     > Cheers,
>     >   C
> 
>     I currently work on the event handling (every evening atm, hence I'm
>     getting somewhere).
> 
>     I haven't yet thought much about, how much things we put into the map
>     options. But I think it would be nice, if it would be just JSON and not
>     full JavaScript. This way you could easily get the options from some
>     server. It's not JSON only atm IIRC, but we might want to change it?
> 
>     What is the reason to put it into the initialisation?
> 
>     I think it's simpler and also more expressive if you do it with some
>     binds after the map was initialised. Rather than having one big
>     configuration thing.
> 
>     Cheers,
>      Volker
> 
> 
> 
> 
> _______________________________________________
> MapQuery mailing list
> MapQuery at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapquery



More information about the MapQuery mailing list