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

Eric Lemoine eric.lemoine at camptocamp.com
Sat Mar 13 15:06:17 EST 2010


On Sat, Mar 13, 2010 at 7:06 PM, Oliver Tonnhofer <olt at bogosoft.com> wrote:
> Hi everyone,
>
> I was playing with the jQuery plugin idea and I am not really sure if a plugin is the right way for doing this.
>
> All existing jQuery plugins are - more or less - just playing with DOM objects. Hide that, fade this in, add this event, etc.  But we want to work with another library, we don't need access to the DOM elements where we added our maps, we need access to the actual map object (OpenLayer or our own geojquery map objects).
>
> I don't see how this can be implemented in an elegant way when we just want to write a plugin.
>
> Let me give you an example with some code I have[1]:
>
> $('#map').map({
>  size: [400, 400],
>  zoom: 7,
>  center: [8.19884, 53.1495],
>  layers: [$.map.tms({host:"http://osm.omniscale.net/proxy/tiles/", layer:"osm_EPSG900913"})]
> });
>
> Pretty simple. I just created a map inside the #map element. But how do I interact with the map? $('#map') gives me a jQuery object where I can manipulate all attributes from the DOM object, but not the actual map. We can add the OpenLayers map or some geojQuery object as .data() to the element, but $('#map').data('map').center(lonlat) is rather quirky.
>
> One solution would be to add another jQuery method for everything we intend to do with our map.
>
> $('#map').center(lonlat);
> $('#map').add_layer(...);
>
> That would work, but it would also pollute the $-namespace. PHP developers might like that but I'm strongly against that. ;)
>
> Maybe I'm missing something, please enlighten me :)
>
> [1] http://bitbucket.org/olt/geojquery-playground/src/

Hi Oliver.

How do you like <http://code.google.com/p/jquery-googlemap/>? Code is
available at <http://code.google.com/p/jquery-googlemap/source/browse/trunk/googlemaps.js>.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Geojquery mailing list