[geojquery] To plug in or not to plug in?

Christoph Baudson (Wheregroup) christoph.baudson at wheregroup.com
Mon Mar 15 05:28:31 EDT 2010


Volker Mische schrieb:
> Oliver Tonnhofer wrote:
>  
>> On 13.03.2010, at 21:48, Volker Mische wrote:
>>    
>>> the way I have imagined it is like gquery does it. Once you apply the
>>> map object, you are not in the DOM world any more. Any future call in
>>> the chain will be applied to the map. Here's an example:
>>>
>>> $('#map').map({someoptions}).center(lonlat);
>>> [...]
>>> $('#map').map({someoptions}).center(lonlat).dom().hide();
>>>       
>> Ok, that looks not to bad. How do you think we retrieve the map 
>> object again later? We could store the object with .data() and return 
>> this object on subsequent .map() calls.
>>
>> $('#map').map({someoptions})
>> // later
>> $('#map').map().center(lonlat);
>>     
>
> Yes, the data should be internally stored with data(). Just like jQuery
> UI does it.
>   


This is already a very promising discussion, thanks to everyone involved.

I just wanted to share an aspect of how jQuery is used in Mapbender. 
There is a plugin "mapbender", like "map" in the example above. Called 
without any parameters, it behaves like Volker explained above, it 
returns the JS object stored via data(), not the jQuery collection.

However, sometimes we found it useful to to have a method actually 
return values, which would prevent chaining. We have added the option to 
pass a function to the plugin, which is executed within the scope of the 
Mapbender object, so you could write code like this

$('#map').mapbender(function () {
   var foo = this.bar(); // "this" refers to the JS map object
   // etc.
}).hide();

The upside for us was to be able to execute more complex code within the 
closure, and still be able to chain. I'm not sure if it's suitable for 
GeoJQuery, or good style in general, but we are comfortable with it.

Personally I dislike the UI style of operating on a plugin, like

.datepicker( 'dialog' , date , [onSelect] , [settings] , [pos] )

I find it clumsy, but I may not have understood the full effect of doing 
it this way. Maybe some of you have.

The Mapbender Plugin follows the "GeoJQuery UI" approach, so I would be 
especially interested in this, not saying that I wouldn't be interested 
in the "GeoJQuery Core" approach :-)

Christoph


>  
>> It would be cool to have working CSS selectors like
>> $('#map #mylayer').hide(). It might work some custom selectors 
>> $('#map :layer("mylayer")').layer().disable()
>>     
>
> Custom selectors should be easily possible, though I haven't used them
> myself.
>
> Cheers,
>   Volker
>
> _______________________________________________
> Geojquery mailing list
> Geojquery at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geojquery
>   


-- 

----------------------------------

Aufwind durch Wissen!

Qualifizierte OpenSource-Schulungen
bei der www.foss-academy.eu

----------------------------------
_______________________________________

W h e r e G r o u p GmbH & Co. KG

Siemensstraße 8
53121 Bonn
Germany

Christoph Baudson
Anwendungsentwickler

Fon: +49 (0)228 / 90 90 38 - 15
Fax: +49 (0)228 / 90 90 38 - 11
christoph.baudson at wheregroup.com
www.wheregroup.com
Amtsgericht Bonn, HRA 6788
_______________________________________

Komplementärin:
WhereGroup Verwaltungs GmbH
vertreten durch:
Olaf Knopp, Peter Stamm
_______________________________________



More information about the Geojquery mailing list